* added patches from Fathi boudra
[citadel.git] / citadel / debian / citadel-server.postinst
1 #! /bin/sh
2 # citadel-server.postinst
3 # by Wilfried Goesgens & Fathi Boudra
4
5 set -e
6
7 # Use debconf.
8 . /usr/share/debconf/confmodule
9
10
11 case "$1" in
12   configure)
13     if ! getent group citadel >/dev/null; then 
14                 groupadd citadel
15         fi
16         if ! getent passwd citadel >/dev/null; then 
17                 adduser --system --ingroup citadel --home /var/lib/citadel \
18                         --gecos "Citadel system user" --shell /bin/sh \
19                         --disabled-password citadel
20         fi
21         mkdir -p /etc/citadel
22         chown citadel:citadel /etc/citadel
23
24         #: !TODO: should network/systems  go to /etc/citadel?
25         mkdir -p \
26                 /var/lib/citadel/data/ \
27                 /var/lib/citadel/bio/ \
28                 /var/lib/citadel/bitbucket/ \
29                 /var/lib/citadel/files/ \
30                 /var/lib/citadel/images/ \
31                 /var/lib/citadel/info/ \
32                 /var/lib/citadel/userpics/ \
33                 /var/spool/citadel/network/spoolin \
34                 /var/spool/citadel/network/spoolout \
35                 /var/spool/citadel/network/spoolsystems 
36
37         chown -R citadel:citadel /var/lib/citadel /var/spool/citadel
38
39         chown root:root /usr/sbin/chkpwd
40         chmod 4755 /usr/sbin/chkpwd
41
42         db_get citadel/Administrator && admin="$RET"
43         db_get citadel/ServerIPAddress && ip_addr="$RET"
44         db_get citadel/LoginType && enable_unix_auth="$RET"
45         if test "$enable_unix_auth" = "true"; then
46             export ENABLE_UNIX_AUTH=yes
47         else
48             export ENABLE_UNIX_AUTH=no
49         fi
50         export IP_ADDR=$ip_addr
51         export CITADEL=''
52         export CITADEL_INSTALLER=yes
53         export ACT_AS_MTA=no
54         export SYSADMIN_NAME=$admin
55         export CREATE_XINETD_ENTRY=no
56         export CREATE_INITTAB_ENTRY=no
57         export NO_INIT_SCRIPTS=yes
58
59         echo "applying your settings."
60         /usr/lib/citadel-server/setup -q
61
62         if test -S /var/run/citadel/citadel.socket; then 
63             /usr/sbin/sendcommand "DOWN"
64         fi
65
66         while test -S /var/run/citadel/citadel.socket; do 
67             sleep 1
68         done
69
70         db_stop
71         
72         ;;
73   abort-upgrade|abort-remove|abort-deconfigure)
74     ;;
75
76   *) echo "$0: didn't understand being called with \`$1'" 1>&2
77      exit 1;;
78 esac
79
80         #DEBHELPER#
81
82 exit 0