* more debian build added.
[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 db_version 2.0
11
12 case "$1" in
13   configure)
14     if ! getent group citadel >/dev/null; then 
15                 groupadd citadel
16         fi
17         if ! getent passwd citadel >/dev/null; then 
18                 adduser --system --ingroup citadel --home /var/lib/citadel \
19                         --gecos "Citadel system user" --shell /bin/sh \
20                         --disabled-password citadel
21         fi
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, because of this gave us many errors in the past.
26         chown root:root /usr/sbin/chkpwd
27         chmod 4755 /usr/sbin/chkpwd
28
29         db_get citadel/Administrator && admin="$RET"
30         db_get citadel/ServerIPAddress && ip_addr="$RET"
31         db_get citadel/LoginType && enable_unix_auth="$RET"
32         if test "$enable_unix_auth" = "true"; then
33             export ENABLE_UNIX_AUTH=yes
34         else
35             export ENABLE_UNIX_AUTH=no
36         fi
37         export IP_ADDR=$ip_addr
38         export CITADEL=''
39         export CITADEL_INSTALLER=yes
40         export ACT_AS_MTA=no
41         export SYSADMIN_NAME=$admin
42         export CREATE_XINETD_ENTRY=no
43         export CREATE_INITTAB_ENTRY=no
44         export NO_INIT_SCRIPTS=yes
45
46         echo "applying your settings."
47         /usr/lib/citadel-server/setup -q
48
49         if test -S /var/run/citadel/citadel.socket; then 
50             /usr/sbin/sendcommand "DOWN"
51         fi
52
53         while test -S /var/run/citadel/citadel.socket; do 
54             sleep 1
55         done
56
57         db_stop
58         
59         ;;
60   abort-upgrade|abort-remove|abort-deconfigure)
61     ;;
62
63   *) echo "$0: didn't understand being called with \`$1'" 1>&2
64      exit 1;;
65 esac
66
67         #DEBHELPER#
68
69 exit 0