Novi izvorni kod change_pass dodatka (inacica 3.0).
[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
9 PKG="squirrelmail-change-pass-cn"
10 VERSION="3.0-1"
11 SQCONFDIR="/etc/squirrelmail"
12 SQCONF="$SQCONFDIR/config.php"
13 SQCPCONF="$SQCONFDIR/config_change_pass.php"
14 CPCONF="/usr/share/squirrelmail/plugins/change_pass/config.php"
15 need_restart=0
16
17
18 # Include CARNet functions
19 . /usr/share/carnet-tools/functions.sh
20
21
22 # Configure poppassd to refuse connection from all hosts
23 # but localhost (127.0.0.1).
24 #
25 if [ ! -f /etc/hosts.deny ]; then
26     touch /etc/hosts.deny
27 fi
28 if ! egrep -q '^poppassd:' /etc/hosts.deny; then
29     echo "poppassd: ALL" | cp-update "$PKG" /etc/hosts.deny
30 fi
31 if [ ! -f /etc/hosts.allow ]; then
32     touch /etc/hosts.allow
33 fi
34 if ! egrep -q '^poppassd:' /etc/hosts.allow; then
35     echo "poppassd: 127.0.0.1" | cp-update "$PKG" /etc/hosts.allow
36 fi
37
38
39 # Configure SquirrelMail change_pass plugin - using defaults,
40 # no configuration files.
41 #
42 if [ "$2" ] && dpkg --compare-versions $2 lt $VERSION; then
43     cp_echo "CN: This version of change_pass plugin contains major changes."
44     cp_echo "CN: For detailed description, see documentation in /usr/share/doc/$PKG/."
45 fi
46 if [ -f "$SQCPCONF" ]; then
47     mv -f "$SQCPCONF" "$SQCPCONF.cn-old"
48     cp_echo "CN: Old $SQCPCONF disabled and renamed to $SQCPCONF.cn-old."
49 fi
50 if [ -f "$CPCONF" ]; then
51     mv -f "$CPCONF" "$CPCONF.cn-old"
52     cp_echo "CN: Old $CPCONF disabled and renamed to $CPCONF.cn-old."
53 fi
54
55
56 # Enable change_pass plugin in SquirrelMail config.php.
57 #
58 if ! egrep -q '^\$plugins\[[0-9]+\][\ ]*=[\ ]*'\''change_pass'\' "$SQCONF"; then
59
60     if cp_check_and_backup "$SQCONF"; then
61         cp_echo "CN: Old $SQCONF saved as \"/var/backups/${SQCONF##*/}.bak\"."
62     fi
63
64     cp_echo "CN: Enabling SquirrelMail change_pass plugin in $SQCONF"
65     /usr/sbin/squirrelmail-configure --install-plugin change_pass
66 fi
67
68
69 # Convert poppassd service from inetd.conf to xinetd.conf type.
70 # Service configuration is saved in /etc/xinetd.d/ directory.
71 #
72 if [ -x /etc/init.d/xinetd -a -d /etc/xinetd.d -a -x /usr/sbin/itox ]; then
73
74   if egrep -q '^poppassd' /etc/inetd.conf && \
75      [ ! -f /etc/xinetd.d/poppassd ]; then
76
77         cp_echo "CN: Enabling poppassd in /etc/xinetd.d/poppassd"
78
79         touch /etc/xinetd.d/poppassd.$$
80         grep "^poppassd" /etc/inetd.conf  | \
81                 itox -daemon_dir /usr/sbin | cp-update "$PKG" /etc/xinetd.d/poppassd.$$
82         cp_mv /etc/xinetd.d/poppassd.$$ /etc/xinetd.d/poppassd
83
84         need_restart=1
85   fi
86 fi
87
88
89 # Restart xinetd if needed.
90 #
91 if [ $need_restart -eq 1 ]; then
92
93         if [ -x "/etc/init.d/xinetd" ]; then
94                 if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
95                         invoke-rc.d xinetd restart || exit $?
96                 else
97                         /etc/init.d/xinetd restart || exit $?
98                 fi
99         fi
100 fi
101
102
103 # Mail root
104 #
105 cp_mail "$PKG"
106
107 exit 0