c1015ddc by Adam Heath

Handle the group not being GID=1000.

1 parent 57446c0e
......@@ -6,7 +6,7 @@ tool_uid="$(id -u tool)"
tool_gid="$(id -g tool)"
adjust_tool_uid_gid() {
declare usermod_args=()
declare usermod_args=() groupmod_args=()
declare -a new_groups=()
if [[ $MAP_UID ]]; then
......@@ -14,7 +14,9 @@ adjust_tool_uid_gid() {
fi
if [[ $MAP_GROUPS ]]; then
set -- $MAP_GROUPS
[[ $(id -g tool) -ne $1 ]] && usermod_args+=(-g $1)
if [[ $tool_gid -ne $1 ]]; then
groupmod_args=(-g "$1")
fi
shift
for group in "$@"; do
groupadd -g $group -o tool_$group
......@@ -25,6 +27,9 @@ adjust_tool_uid_gid() {
usermod_args+=(-aG "${new_groups[*]}")
fi
fi
if [[ ${#groupmod_args[*]} -gt 0 ]]; then
groupmod "${groupmod_args[@]}" tool
fi
if [[ ${#usermod_args[*]} -gt 0 ]]; then
usermod "${usermod_args[@]}" tool
fi
......