Pojava greske u slucaju da datoteka /etc/inetd.conf ne postoji.
[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 # chk_conf_tag ()
19 #
20 #   Check if configuration file has CARNet package info lines.
21 #   return:  $RET => 0 - tagged
22 #                    1 - file does not exists
23 #                    2 - file exists, but it is not tagged
24 #
25 chk_conf_tag () {
26     local conf_file
27     conf_file="$1"
28     RET=1
29
30     if [ -f "$conf_file" ]; then
31         if egrep -q "^## Begin - Generated by CARNet package ${PKG}$" "$conf_file"; then
32             RET=0
33         else
34             RET=2
35         fi
36     fi
37 }
38
39 # Configure poppassd to refuse connection from all hosts
40 # but localhost (127.0.0.1).
41 #
42 if [ ! -f /etc/hosts.deny ]; then
43     touch /etc/hosts.deny
44 fi
45 if ! egrep -q '^poppassd:' /etc/hosts.deny; then
46     echo "poppassd: ALL" | cp-update "$PKG" /etc/hosts.deny
47 fi
48 if [ ! -f /etc/hosts.allow ]; then
49     touch /etc/hosts.allow
50 fi
51 if ! egrep -q '^poppassd:' /etc/hosts.allow; then
52     echo "poppassd: 127.0.0.1" | cp-update "$PKG" /etc/hosts.allow
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     squirrelmail-configure --install-plugin change_pass
60 fi
61
62
63 # Convert poppassd service from inetd.conf to xinetd.conf type.
64 # Service configuration is saved in /etc/xinetd.d/ directory.
65 #
66 chk_conf_tag /etc/xinetd.d/poppassd
67 if [ $RET -lt 2 ]; then
68     cp_echo "CN: Enabling poppassd in /etc/xinetd.d/poppassd"
69
70     if [ ! -d /etc/xinetd.d ]; then
71         mkdir -p /etc/xinetd.d/
72     fi
73     touch /etc/xinetd.d/poppassd.$$
74     cp-update "$PKG" /etc/xinetd.d/poppassd.$$ <<EOF
75 service poppassd
76 {
77         socket_type     = stream
78         protocol        = tcp
79         wait            = no
80         user            = root
81         server          = /usr/sbin/poppassd
82 }
83 EOF
84     cp_mv /etc/xinetd.d/poppassd.$$ /etc/xinetd.d/poppassd
85
86     need_restart=1
87 fi
88
89
90 # Restart xinetd if needed.
91 #
92 if [ $need_restart -eq 1 ]; then
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 #DEBHELPER#
108
109 exit 0