blob: 50c89e140ac6916953f032d08565c1507637b1a3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
#!/bin/sh
# preinst script for freeside
#
# see: dh_installdeb(1)
set -e
# summary of how this script can be called:
# * <new-preinst> `install'
# * <new-preinst> `install' <old-version>
# * <new-preinst> `upgrade' <old-version>
# * <old-preinst> `abort-upgrade' <new-version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
case "$1" in
install|upgrade)
# If the package has default file it could be sourced, so that
# the local admin can overwrite the defaults
[ -f "/etc/default/freeside" ] && . /etc/default/freeside
# Sane defaults:
[ -z "$FREESIDE_HOME" ] && FREESIDE_HOME=/home/freeside
[ -z "$FREESIDE_USER" ] && FREESIDE_USER=freeside
[ -z "$FREESIDE_NAME" ] && FREESIDE_NAME="Freeside"
[ -z "$FREESIDE_GROUP" ] && FREESIDE_GROUP=freeside
[ -z "$RT_GROUP" ] && RT_GROUP=rt
# Groups that the user will be added to, if undefined, then none.
ADDGROUP="rt"
# create user to avoid running server as root
# 1. create group if not existing
if ! getent group | grep -q "^$FREESIDE_GROUP:" -; then
echo -n "Adding group $FREESIDE_GROUP.."
addgroup --quiet --system $FREESIDE_GROUP 2>/dev/null ||true
echo "..done"
fi
if ! getent group | grep -q "^$RT_GROUP:" -; then
echo -n "Adding group $RT_GROUP.."
addgroup --quiet --system $RT_GROUP 2>/dev/null ||true
echo "..done"
fi
# 2. create homedir if not existing
test -d $FREESIDE_HOME || mkdir $FREESIDE_HOME
# 3. create user if not existing
if ! getent passwd | grep -q "^$FREESIDE_USER:" -; then
echo -n "Adding system user $FREESIDE_USER.."
adduser --quiet \
--system \
--ingroup $FREESIDE_GROUP \
--shell /bin/sh \
--no-create-home \
--disabled-password \
$FREESIDE_USER 2>/dev/null || true
echo "..done"
fi
# 4. adjust passwd entry
usermod -c "$FREESIDE_NAME" \
-d $FREESIDE_HOME \
-g $FREESIDE_GROUP \
$FREESIDE_USER
# 5. adjust file and directory permissions
if ! dpkg-statoverride --list $FREESIDE_HOME >/dev/null
then
chown -R $FREESIDE_USER:adm $FREESIDE_HOME
chmod u=rwx,g=rxs,o= $FREESIDE_HOME
fi
# 6. Add the user to the ADDGROUP group
if test -n $ADDGROUP
then
if ! groups $FREESIDE_USER | cut -d: -f2 | \
grep -qw $ADDGROUP -; then
adduser $FREESIDE_USER $ADDGROUP
fi
fi
;;
abort-upgrade)
;;
*)
echo "preinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
exit 0
|