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