Merge "Add devuser to the specified group(s)"

This commit is contained in:
Zuul
2026-01-29 22:49:27 +00:00
committed by Gerrit Code Review
4 changed files with 15 additions and 0 deletions

View File

@@ -13,6 +13,12 @@ DIB_DEV_USER_USERNAME
:Default: devuser
:Description: Username for the created user.
DIB_DEV_USER_GROUPS
:Required: No
:Default: No
:Description: Additional groups (comma separated if many) for the created
user (groups should already exist).
DIB_DEV_USER_SHELL
:Required: No
:Default: System default (The useradd default is used)

View File

@@ -1,4 +1,5 @@
export DIB_DEV_USER_USERNAME=${DIB_DEV_USER_USERNAME:-devuser}
export DIB_DEV_USER_GROUPS=${DIB_DEV_USER_GROUPS:-}
export DIB_DEV_USER_SHELL=${DIB_DEV_USER_SHELL:-}
export DIB_DEV_USER_PWDLESS_SUDO=${DIB_DEV_USER_PWDLESS_SUDO:-}
export DIB_DEV_USER_AUTHORIZED_KEYS=${DIB_DEV_USER_AUTHORIZED_KEYS:-}

View File

@@ -11,6 +11,9 @@ if [ -n "${DIB_DEV_USER_SHELL}" ]; then
user_shell_args="-s ${DIB_DEV_USER_SHELL}"
fi
useradd -m ${DIB_DEV_USER_USERNAME} $user_shell_args
if [ -n "${DIB_DEV_USER_GROUPS}" ]; then
usermod -a -G ${DIB_DEV_USER_GROUPS} ${DIB_DEV_USER_USERNAME}
fi
set +x
if [ -n "${DIB_DEV_USER_PASSWORD}" ]; then
echo "Setting password."

View File

@@ -0,0 +1,5 @@
---
features:
- |
The newly created devuser now can be added to the specified group(s) with
new variable ``DIB_DEV_USER_GROUPS``. Groups should already exist.