From a4124d7e99d0c954c5201889bdbda8e75ab34ac6 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Thu, 24 Apr 2025 21:10:04 +0200 Subject: [PATCH] pkg: adjust this a bit making it possible to shift the user UID and GID if needed #8521 --- +POST_INSTALL | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/+POST_INSTALL b/+POST_INSTALL index 88d5baed2..c9536cde1 100644 --- a/+POST_INSTALL +++ b/+POST_INSTALL @@ -4,20 +4,22 @@ UID=789 GROUP=${USER} GID=${UID} -if ! ${PW} groupshow ${GROUP} >/dev/null 2>&1; then - echo "Creating group '${GROUP}' with gid '${GID}'" - ${PW} groupadd ${GROUP} -g ${GID} -else - echo "Using existing group '${GROUP}'" +PW_ARG=add +if ${PW} groupshow ${GROUP} >/dev/null 2>&1; then + PW_ARG=mod fi -if ! ${PW} usershow ${USER} >/dev/null 2>&1; then - echo "Creating user '${USER}' with uid '${UID}'" - ${PW} useradd ${USER} -u ${UID} -g ${GID} -c "World Wide Web Only" -d /nonexistent -s /usr/sbin/nologin -else - echo "Using existing user '${USER}'" +echo "Creating group '${GROUP}' with gid '${GID}'" +${PW} group${PW_ARG} ${GROUP} -g ${GID} + +PW_ARG=add +if ${PW} usershow ${USER} >/dev/null 2>&1; then + PW_ARG=mod fi +echo "Creating user '${USER}' with uid '${UID}'" +${PW} user${PW_ARG} ${USER} -u ${UID} -g ${GID} -c "World Wide Web Only" -d /nonexistent -s /usr/sbin/nologin + echo "Updating /etc/shells" cp /etc/shells /etc/shells.bak (grep -v /usr/local/sbin/opnsense-shell /etc/shells.bak; \