File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -411,12 +411,16 @@ elif [ "${USERNAME}" = "none" ]; then
411411 USER_UID=0
412412 USER_GID=0
413413fi
414+
414415# Create or update a non-root user to match UID/GID.
415- group_name=" ${USERNAME} "
416+ group_name=$( getent group " $USER_GID " | cut -d: -f3)
417+ if [ -z " $group_name " ]; then
418+ # Group does not yet exist and will be created. Use the user name as group name.
419+ group_name=" ${USERNAME} "
420+ fi
416421if id -u ${USERNAME} > /dev/null 2>&1 ; then
417422 # User exists, update if needed
418423 if [ " ${USER_GID} " != " automatic" ] && [ " $USER_GID " != " $( id -g $USERNAME ) " ]; then
419- group_name=" $( id -gn $USERNAME ) "
420424 groupmod --gid $USER_GID ${group_name}
421425 usermod --gid $USER_GID $USERNAME
422426 fi
You can’t perform that action at this time.
0 commit comments