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} GROUP=${USER}
GID=${UID} GID=${UID}
if ! ${PW} groupshow ${GROUP} >/dev/null 2>&1; then PW_ARG=add
echo "Creating group '${GROUP}' with gid '${GID}'" if ${PW} groupshow ${GROUP} >/dev/null 2>&1; then
${PW} groupadd ${GROUP} -g ${GID} PW_ARG=mod
else
echo "Using existing group '${GROUP}'"
fi fi
if ! ${PW} usershow ${USER} >/dev/null 2>&1; then echo "Creating group '${GROUP}' with gid '${GID}'"
echo "Creating user '${USER}' with uid '${UID}'" ${PW} group${PW_ARG} ${GROUP} -g ${GID}
${PW} useradd ${USER} -u ${UID} -g ${GID} -c "World Wide Web Only" -d /nonexistent -s /usr/sbin/nologin
else PW_ARG=add
echo "Using existing user '${USER}'" if ${PW} usershow ${USER} >/dev/null 2>&1; then
PW_ARG=mod
fi 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" echo "Updating /etc/shells"
cp /etc/shells /etc/shells.bak cp /etc/shells /etc/shells.bak
(grep -v /usr/local/sbin/opnsense-shell /etc/shells.bak; \ (grep -v /usr/local/sbin/opnsense-shell /etc/shells.bak; \