pkg: adjust this a bit making it possible to shift the user UID and GID if needed #8521

This commit is contained in:
Franco Fichtner 2025-04-24 21:10:04 +02:00
parent 2a935b7afa
commit a4124d7e99

View File

@ -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; \