* some cleanup and debian code beautification (tab/space/indentation)
[citadel.git] / citadel / debian / citadel-server.postinst
1 #!/bin/sh
2 # postinst script for citadel-server
3
4 set -e
5
6 # source debconf stuff
7 . /usr/share/debconf/confmodule
8 db_version 2.0
9
10 case "$1" in
11     configure)
12         if ! getent group citadel >/dev/null; then 
13             groupadd citadel
14         fi
15
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
22         chown -R citadel:citadel /etc/citadel
23         chown -R citadel:citadel /var/lib/citadel /var/spool/citadel
24
25         # we're a bit paranoid here,
26         # because of this gave us many errors in the past.
27         chown root:root /usr/sbin/chkpwd
28         chmod 4755 /usr/sbin/chkpwd
29
30         db_get citadel/Administrator && admin="$RET"
31         db_get citadel/ServerIPAddress && ip_addr="$RET"
32         db_get citadel/LoginType && enable_unix_auth="$RET"
33
34         if test "$enable_unix_auth" = "true"; then
35             export ENABLE_UNIX_AUTH=yes
36         else
37             export ENABLE_UNIX_AUTH=no
38         fi
39
40         export IP_ADDR=$ip_addr
41         export CITADEL=''
42         export CITADEL_INSTALLER=yes
43         export ACT_AS_MTA=no
44         export SYSADMIN_NAME=$admin
45         export CREATE_XINETD_ENTRY=no
46         export CREATE_INITTAB_ENTRY=no
47         export NO_INIT_SCRIPTS=yes
48
49         echo "applying your settings."
50         /usr/lib/citadel-server/setup -q
51
52         if test -S /var/run/citadel/citadel.socket; then 
53             /usr/sbin/sendcommand "DOWN"
54         fi
55
56         while test -S /var/run/citadel/citadel.socket; do 
57             sleep 1
58         done
59
60         db_stop
61     ;;
62
63     abort-upgrade|abort-remove|abort-deconfigure)
64     ;;
65
66     *)
67         echo "postinst called with unknown argument \`$1'" >&2
68         exit 1
69     ;;
70 esac
71
72 #DEBHELPER#
73
74 exit 0