2 # preinst script for freeside
4 # see: dh_installdeb(1)
8 # summary of how this script can be called:
9 # * <new-preinst> `install'
10 # * <new-preinst> `install' <old-version>
11 # * <new-preinst> `upgrade' <old-version>
12 # * <old-preinst> `abort-upgrade' <new-version>
13 # for details, see http://www.debian.org/doc/debian-policy/ or
14 # the debian-policy package
20 # If the package has default file it could be sourced, so that
21 # the local admin can overwrite the defaults
23 [ -f "/etc/default/freeside" ] && . /etc/default/freeside
27 [ -z "$FREESIDE_HOME" ] && FREESIDE_HOME=/home/freeside
28 [ -z "$FREESIDE_USER" ] && FREESIDE_USER=freeside
29 [ -z "$FREESIDE_NAME" ] && FREESIDE_NAME="Freeside"
30 [ -z "$FREESIDE_GROUP" ] && FREESIDE_GROUP=freeside
32 [ -z "$RT_GROUP" ] && RT_GROUP=rt
34 # Groups that the user will be added to, if undefined, then none.
37 # create user to avoid running server as root
38 # 1. create group if not existing
39 if ! getent group | grep -q "^$FREESIDE_GROUP:" -; then
40 echo -n "Adding group $FREESIDE_GROUP.."
41 addgroup --quiet --system $FREESIDE_GROUP 2>/dev/null ||true
44 if ! getent group | grep -q "^$RT_GROUP:" -; then
45 echo -n "Adding group $RT_GROUP.."
46 addgroup --quiet --system $RT_GROUP 2>/dev/null ||true
49 # 2. create homedir if not existing
50 test -d $FREESIDE_HOME || mkdir $FREESIDE_HOME
51 # 3. create user if not existing
52 if ! getent passwd | grep -q "^$FREESIDE_USER:" -; then
53 echo -n "Adding system user $FREESIDE_USER.."
56 --ingroup $FREESIDE_GROUP \
60 $FREESIDE_USER 2>/dev/null || true
63 # 4. adjust passwd entry
64 usermod -c "$FREESIDE_NAME" \
68 # 5. adjust file and directory permissions
69 if ! dpkg-statoverride --list $FREESIDE_HOME >/dev/null
71 chown -R $FREESIDE_USER:adm $FREESIDE_HOME
72 chmod u=rwx,g=rxs,o= $FREESIDE_HOME
74 # 6. Add the user to the ADDGROUP group
77 if ! groups $FREESIDE_USER | cut -d: -f2 | \
78 grep -qw $ADDGROUP -; then
79 adduser $FREESIDE_USER $ADDGROUP
88 echo "preinst called with unknown argument \`$1'" >&2
93 # dh_installdeb will replace this with shell code automatically
94 # generated by other debhelper scripts.