3 if ! ([ "$1" = "configure" ] ||
[ "$1" = "reconfigure" ]); then
7 # Some useful variables
11 ADDUSER
="/usr/sbin/adduser"
12 USERDEL
="/usr/sbin/userdel"
13 USERADD
="/usr/sbin/useradd"
14 GROUPDEL
="/usr/sbin/groupdel"
15 GROUPMOD
="/usr/sbin/groupmod"
17 HOOKSDIR
="/etc/ocsigenserver/update.d"
20 # 1. Get current uid and gid if user exists.
22 if $ID $OCSIGEN > /dev
/null
2>&1; then
23 IUID
=`$ID --user $OCSIGEN`
24 IGID
=`$ID --group $OCSIGEN`
31 # 2. Ensure that no standard account or group will remain before adding the
33 if [ "$IUID" = "NONE" ] ||
[ $IUID -ge 1000 ]; then # we must do sth :)
34 if ! [ "$IUID" = "NONE" ] && [ $IUID -ge 1000 ]; then
35 # user exists but isn't a system user... delete it.
41 # 3. Add the system account.
42 # Issue a warning if it fails.
43 if $GROUPMOD $OCSIGEN > /dev
/null
2>&1; then
44 # group already exists, use --ingroup
45 if ! $ADDUSER --system --disabled-password --disabled-login --home /var
/lib
/ocsigenserver
--no-create-home --ingroup $OCSIGEN $OCSIGEN; then
46 echo "The adduser command failed."
49 if ! $ADDUSER --system --disabled-password --disabled-login --home /var
/lib
/ocsigenserver
--no-create-home --group $OCSIGEN; then
50 echo "The adduser command failed."
57 # 4.1 Change ownership of directory.
58 $CHOWN -R $OCSIGEN:$OCSIGEN /var
/lib
/ocsigenserver
/
59 $CHMOD 750 /var
/lib
/ocsigenserver
/
62 # 4.2 Create log directory and empty log if needed
63 LOGDIR
="/var/log/ocsigenserver"
64 LOGFILE
="${LOGDIR}/access.log"
66 $CHOWN $OCSIGEN:$OCSIGEN $LOGDIR
68 if [ ! -f $LOGFILE ]; then
70 $CHOWN $OCSIGEN:$OCSIGEN $LOGFILE
73 # The empty log is a workaround to logrotate complaining about
74 # inexistent logs (see #550324)
77 # 5. Call update hooks
78 if [ -d $HOOKSDIR ]; then
79 echo "Running hooks in $HOOKSDIR..."
80 if ! run-parts
--exit-on-error $HOOKSDIR; then
81 echo "Some hook failed, you should have a look!"
85 echo "No hook to run in $HOOKSDIR."
89 # 6. Call default debhelper scripts.