From 9e38736b93a6b737ecb53d1f41dadf45cbb22c1c Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Fri, 25 Oct 2019 00:19:07 +0200 Subject: Various stuff to pre-configure compute nodes --- roles/ands_scripts/templates/all/cron/maintain.j2 | 4 ++++ roles/ands_scripts/templates/all/scripts/subids.sh | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 roles/ands_scripts/templates/all/cron/maintain.j2 create mode 100644 roles/ands_scripts/templates/all/scripts/subids.sh (limited to 'roles/ands_scripts/templates/all') diff --git a/roles/ands_scripts/templates/all/cron/maintain.j2 b/roles/ands_scripts/templates/all/cron/maintain.j2 new file mode 100644 index 0000000..fdd4231 --- /dev/null +++ b/roles/ands_scripts/templates/all/cron/maintain.j2 @@ -0,0 +1,4 @@ +SHELL=/bin/bash +PATH=/sbin:/bin:/usr/sbin:/usr/bin +MAILTO=csa-darkserv@suren.me +*/15 * * * * root {{ ands_script_path }}/subids.sh diff --git a/roles/ands_scripts/templates/all/scripts/subids.sh b/roles/ands_scripts/templates/all/scripts/subids.sh new file mode 100644 index 0000000..a83baa0 --- /dev/null +++ b/roles/ands_scripts/templates/all/scripts/subids.sh @@ -0,0 +1,19 @@ +#! /bin/bash + +[ -f /etc/subuid ] || exit +[ -f /etc/subgid ] || exit + +users=$(getent group ipeusers | awk 'BEGIN { FS=":" } { print $4 }' | sed -e 's/,/\n/') +subuid=$(cat /etc/subuid | awk 'BEGIN { FS=":" } { print $1 }') +subgid=$(cat /etc/subgid | awk 'BEGIN { FS=":" } { print $1 }') + +subuid=$(echo -e "$users\n$subuid\n$subuid" | sort | uniq -u) +subgid=$(echo -e "$users\n$subgid\n$subgid" | sort | uniq -u) + +for user in $subuid; do + grep -qxF "$user" /etc/subuid || sed -i'' -e "\$a$user:100000:65536" /etc/subuid +done + +for user in $subgid; do + grep -qxF "$user" /etc/subgid || sed -i'' -e "\$a$user:100000:65536" /etc/subgid +done -- cgit v1.2.3