mirror of
https://git.FreeBSD.org/ports.git
synced 2024-12-27 05:10:36 +00:00
6f0142ba6a
- Make pkg-install script accept FLOWD_UID from environment PR: ports/137560 Submitted by: Mel Flynn <mel.flynn+fbsd.ports@mailing.thruhere.net> Approved by: Janos Mohacsi <mohacsi@niif.hu> (maintainer)
49 lines
886 B
Bash
49 lines
886 B
Bash
#!/bin/sh
|
|
#
|
|
# $FreeBSD$
|
|
#
|
|
# Based on cyrus-sasl2 port
|
|
#
|
|
# create 'flowd' user
|
|
#
|
|
|
|
create_user() {
|
|
USER=${FLOWD_USER}
|
|
GROUP=nobody
|
|
PW=/usr/sbin/pw
|
|
|
|
if [ -x /usr/sbin/nologin ]; then
|
|
shell=/usr/sbin/nologin
|
|
elif [ -x /sbin/nologin ]; then
|
|
shell=/sbin/nologin
|
|
else
|
|
shell=/nonexistent
|
|
fi
|
|
uhome="/var/empty"
|
|
if [ -z "${FLOWD_UID}" ]; then
|
|
uid=`${PW} usernext`;
|
|
uid=${uid%%:*}
|
|
else
|
|
uid=${FLOWD_UID}
|
|
fi
|
|
|
|
if ! ${PW} show user ${USER} -q >/dev/null; then
|
|
if ! ${PW} add user ${USER} -u ${uid} -g ${GROUP} -d "${uhome}" \
|
|
-c "flowd privilege separation user" -s "${shell}" -p "*" \
|
|
; then
|
|
e=$?
|
|
echo "*** Failed to add user \`${USER}'. Please add it manually."
|
|
exit ${e}
|
|
fi
|
|
echo "*** Added user \`${USER}' (id ${uid})"
|
|
else
|
|
echo "*** You already have user \`${USER} (id `id -u ${USER}`)'."
|
|
fi
|
|
}
|
|
|
|
case $2 in
|
|
POST-INSTALL)
|
|
create_user
|
|
;;
|
|
esac
|