1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-12-13 03:03:15 +00:00
freebsd-ports/net-p2p/transmission-daemon/pkg-install
2009-06-19 17:18:02 +00:00

47 lines
989 B
Bash

#!/bin/sh
case $2 in
POST-INSTALL)
USER=transmission
GROUP=${USER}
UID=921
GID=${UID}
PW=/usr/sbin/pw
CHMOD=/bin/chmod
CHOWN=/usr/sbin/chown
MKDIR=/bin/mkdir
THOME=${PKG_PREFIX}/etc/${USER}/home
if ${PW} group show "${GROUP}" 2>/dev/null; then
echo "You already have a group \"${GROUP}\", so I will use it."
else
if ${PW} groupadd ${GROUP} -g ${GID}; then
echo "Added group \"${GROUP}\"."
else
echo "Adding group \"${GROUP}\" failed..."
exit 1
fi
fi
if ${PW} user show "${USER}" 2>/dev/null; then
echo "You already have a user \"${USER}\", so I will use it."
else
if ${PW} useradd ${USER} -u ${UID} -g ${GROUP} -h - \
-d "${THOME}" -s /usr/sbin/nologin -c "Transmission Daemon User"
then
echo "Added user \"${USER}\"."
else
echo "Adding user \"${USER}\" failed..."
exit 1
fi
fi
${MKDIR} -p ${THOME}/Downloads
${CHOWN} root:${GROUP} ${THOME}
${CHOWN} ${USER}:${GROUP} ${THOME}/Downloads
${CHMOD} 1770 ${THOME}
exit 0
;;
esac