Uklonjen dio za modificiranje change_pass konfiguracije.
[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.0.2"
13 SQCONFDIR="/etc/squirrelmail"
14 SQCONF="$SQCONFDIR/config.php"
15 SQCPCONF="$SQCONFDIR/config_change_pass.php"
16 CPCONF="/usr/share/squirrelmail/plugins/change_pass/config.php"
17 need_restart=0
18 min_pass_changed=0
19
20
21 # Configure poppassd to refuse connection from all hosts
22 # but localhost (127.0.0.1).
23 #
24 if [ ! -f /etc/hosts.deny ]; then
25     touch /etc/hosts.deny
26 fi
27 if ! egrep -q '^poppassd:' /etc/hosts.deny; then
28     echo "poppassd: ALL" | cp-update "$PKG" /etc/hosts.deny
29 fi
30 if [ ! -f /etc/hosts.allow ]; then
31     touch /etc/hosts.allow
32 fi
33 if ! egrep -q '^poppassd:' /etc/hosts.allow; then
34     echo "poppassd: 127.0.0.1" | cp-update "$PKG" /etc/hosts.allow
35 fi
36
37
38 # First of all, do the backup.
39 #
40 done_backup=0
41 for cpconf_file in $SQCPCONF $CPCONF; do
42     if [ -f "$cpconf_file" ] && [ ! -L "$cpconf_file" ]; then
43         cp_echo "CN: Doing backup for $cpconf_file"
44         cp_backup_conffile -d "/var/backups/$PKG" -p $cpconf_file
45         done_backup=1
46     fi
47 done
48 if [ $done_backup -eq 1 ]; then
49     cp_echo "CN: Backup is located in directory: /var/backups/$PKG/"
50 fi
51
52
53 # Enable change_pass plugin in SquirrelMail config.php.
54 #
55 if ! egrep -q '^\$plugins\[[0-9]+\][\ ]*=[\ ]*'\''change_pass'\' "$SQCONF"; then
56     /usr/sbin/squirrelmail-configure --install-plugin change_pass
57 fi
58
59
60 # Convert poppassd service from inetd.conf to xinetd.conf type.
61 # Service configuration is saved in /etc/xinetd.d/ directory.
62 #
63 if [ -x /etc/init.d/xinetd -a -d /etc/xinetd.d -a -x /usr/sbin/itox ]; then
64
65     if egrep -q '^poppassd' /etc/inetd.conf && \
66         [ ! -f /etc/xinetd.d/poppassd ]; then
67
68         cp_echo "CN: Enabling poppassd in /etc/xinetd.d/poppassd"
69
70         touch /etc/xinetd.d/poppassd.$$
71         grep "^poppassd" /etc/inetd.conf  | \
72             itox -daemon_dir /usr/sbin | cp-update "$PKG" /etc/xinetd.d/poppassd.$$
73         cp_mv /etc/xinetd.d/poppassd.$$ /etc/xinetd.d/poppassd
74
75         need_restart=1
76     fi
77 fi
78
79
80 # Restart xinetd if needed.
81 #
82 if [ $need_restart -eq 1 ]; then
83
84     if [ -x "/etc/init.d/xinetd" ]; then
85         if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
86             invoke-rc.d xinetd restart || exit $?
87         else
88             /etc/init.d/xinetd restart || exit $?
89         fi
90     fi
91 fi
92
93
94 # Mail root
95 #
96 cp_mail "$PKG"
97
98 #DEBHELPER#
99
100 exit 0