1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-12-19 03:52:17 +00:00
freebsd-ports/databases/gnats4/pkg-install
Dag-Erling Smørgrav 7977c0ecab Miscellaneous installation improvements, including (but not limited to)
preserving pre-existing configuration and data.
2003-10-09 01:17:43 +00:00

48 lines
1.4 KiB
Bash

#!/bin/sh
#
# $FreeBSD$
#
ECHO_CMD=echo
GREP=/usr/bin/grep
PW=/usr/sbin/pw
FTPUSERS=/etc/ftpusers
GNATSDBDIR=%%GNATSDBDIR%%
case $2 in
PRE-INSTALL)
if [ ! -x ${PW} ]; then
${ECHO_CMD} "Your system is missing the \`pw' command."
exit 1
fi
if ${PW} usershow -n gnats >/dev/null 2>&1; then
if [ "`pw usershow -n gnats | awk -F: '{print $9}'`" != "${GNATSDBDIR}" ]; then
${PW} usermod -n gnats -d "${GNATSDBDIR}" 2>/dev/null
${ECHO_CMD} "===> Account \`gnats' updated."
fi
else
if ${PW} useradd -n gnats -u 61 -g 1 -d "${GNATSDBDIR}" \
-c "GNATS database owner" -h -; then
${GREP} -qs '^gnats$' ${FTPUSERS} || ${ECHO_CMD} gnats >> ${FTPUSERS}
${ECHO_CMD} "===> Account \`gnats' created."
else
${ECHO_CMD}
${ECHO_CMD} "The FreeBSD standard userid for gnats is 61, but this system"
${ECHO_CMD} "has already a different account with this userid:"
${ECHO_CMD}
${PW} usershow -u 61 -P
${ECHO_CMD}
${ECHO_CMD} "You can either delete this account (which may be dangerous) with"
${ECHO_CMD} " ${PW} userdel -u 61"
${ECHO_CMD} "or add the gnats user with an other userid with"
${ECHO_CMD} " ${PW} useradd -n gnats -g daemon \\"
${ECHO_CMD} " -d ${GNATSDBDIR} -c 'GNATS database owner' -h -"
${ECHO_CMD} "and retry installing this package"
${ECHO_CMD}
exit 1
fi
fi
;;
esac