From d76db82aaa3446d38d4624b7671daf96cce6f1d9 Mon Sep 17 00:00:00 2001 From: uditaren Date: Fri, 27 Mar 2020 09:56:28 +0100 Subject: [PATCH] Ignore the user; change group of files inside docker --- groupmerge.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/groupmerge.sh b/groupmerge.sh index 5c1cfde..371be34 100755 --- a/groupmerge.sh +++ b/groupmerge.sh @@ -10,7 +10,9 @@ if [[ ! -e $1 || ! -e $2 ]]; then echo "Use groupfile1 as the basis and merges missing entries from groupfile2" fi -cat $1 +cat $1 | grep -v ":1000:" +# yes, group assignments of the host user will remain, but it won't hurt + echo "# merged entries:" cat $2 | while read grp; do name=$(echo $grp | cut -d ':' -f 1) @@ -20,6 +22,10 @@ cat $2 | while read grp; do line=$(cat $1 | grep -E "^$name:") if [[ $line == "" ]]; then - echo $name:$pass:$(($dgid + 2000)):$rest + ngid=$(($dgid + 2000)) + echo $name:$pass:$ngid:$rest + if [[ -e /.dockerenv ]]; then + find / -group $dgid -mount -exec chgrp ngid {} \; + fi fi done