Prilagodba paketa za Debian squeeze.
[squirrelmail-change-pass-cn.git] / debian / postinst
1 #!/bin/sh
2
3 set -e
4
5 [ "$1" = "configure" ] || exit 0
6 [ $DEBIAN_SCRIPT_DEBUG ] && set -vx
7
8 # Include CARNet functions
9 . /usr/share/carnet-tools/functions.sh
10
11 PKG="squirrelmail-change-pass-cn"
12 VERSION="3.1.0"
13 SQCONFDIR="/etc/squirrelmail"
14 SQCONF="$SQCONFDIR/config.php"
15 need_restart=0
16
17
18 # Configure poppassd to refuse connection from all hosts
19 # but localhost (127.0.0.1).
20 #
21 if [ ! -f /etc/hosts.deny ]; then
22     touch /etc/hosts.deny
23 fi
24 if ! egrep -q '^poppassd:' /etc/hosts.deny; then
25     echo "poppassd: ALL" | cp-update "$PKG" /etc/hosts.deny
26 fi
27 if [ ! -f /etc/hosts.allow ]; then
28     touch /etc/hosts.allow
29 fi
30 if ! egrep -q '^poppassd:' /etc/hosts.allow; then
31     echo "poppassd: 127.0.0.1" | cp-update "$PKG" /etc/hosts.allow
32 fi
33
34
35 # Enable change_pass plugin in SquirrelMail config.php.
36 #
37 if ! egrep -q '^\$plugins\[[0-9]+\][\ ]*=[\ ]*'\''change_pass'\' "$SQCONF"; then
38     squirrelmail-configure --install-plugin change_pass
39 fi
40
41
42 # Convert poppassd service from inetd.conf to xinetd.conf type.
43 # Service configuration is saved in /etc/xinetd.d/ directory.
44 #
45 if [ -x /etc/init.d/xinetd -a -d /etc/xinetd.d -a -x /usr/sbin/itox ]; then
46     if egrep -q '^poppassd' /etc/inetd.conf && \
47         [ ! -f /etc/xinetd.d/poppassd ]; then
48
49         cp_echo "CN: Enabling poppassd in /etc/xinetd.d/poppassd"
50
51         touch /etc/xinetd.d/poppassd.$$
52         grep "^poppassd" /etc/inetd.conf  | \
53             itox -daemon_dir /usr/sbin | cp-update "$PKG" /etc/xinetd.d/poppassd.$$
54         cp_mv /etc/xinetd.d/poppassd.$$ /etc/xinetd.d/poppassd
55
56         need_restart=1
57     fi
58 fi
59
60
61 # Restart xinetd if needed.
62 #
63 if [ $need_restart -eq 1 ]; then
64     if [ -x "/etc/init.d/xinetd" ]; then
65         if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
66             invoke-rc.d xinetd restart || exit $?
67         else
68             /etc/init.d/xinetd restart || exit $?
69         fi
70     fi
71 fi
72
73
74 # Mail root
75 #
76 cp_mail "$PKG"
77
78 #DEBHELPER#
79
80 exit 0