5 [ "$1" = "configure" ] || exit 0
6 [ $DEBIAN_SCRIPT_DEBUG ] && set -vx
9 PKG="squirrelmail-change-pass-cn"
10 SQCONF=/etc/squirrelmail/config.php
12 # Include CARNet functions
13 . /usr/share/carnet-tools/functions.sh
16 # Configure poppassd to refuse connection from all hosts
17 # but localhost (127.0.0.1).
19 if [ -e /etc/hosts.deny -a -e /etc/hosts.allow ]; then
21 if ! egrep -q '^poppassd:' /etc/hosts.deny; then
22 echo "poppassd: ALL" | cp-update "$PKG" /etc/hosts.deny
25 if ! egrep -q '^poppassd:' /etc/hosts.allow; then
26 echo "poppassd: 127.0.0.1" | cp-update "$PKG" /etc/hosts.allow
31 # Enable change_pass plugin in SquirrelMail config.php.
33 if ! egrep '^\$plugins\[[0-9]+\][\ ]*=[\ ]*'\''change_pass'\' "$SQCONF"; then
35 sq_last_plugin=`egrep '^\\$plugins\[[0-9]+\][\ ]*=[\ ]*'\' "$SQCONF" | sed 's/^.*\[//;s/\].*//' | sort -n | tail -n1` || true
37 if [ -n "$sq_last_plugin" ]; then
39 # Backup SquirrelMail configuration file.
40 cp_check_and_backup "$SQCONF"
42 change_pass_num=$sq_last_plugin
45 SQCONFTMP=`mktemp $SQCONF.tmp.XXXXXX`
47 echo -n "CN: Enabling SquirrelMail change_pass plugin in $SQCONF"
48 sed '/^$plugins\[.*'${sq_last_plugin}'\]/a $plugins['${change_pass_num}'] = '\''change_pass'\'';' "$SQCONF" > "$SQCONFTMP"
49 cp_mv "$SQCONFTMP" "$SQCONF"
56 # Convert poppassd service from inetd.conf to xinetd.conf type.
57 # Service configuration is saved in /etc/xinetd.d/ directory.
59 if [ -x /etc/init.d/xinetd -a -d /etc/xinetd.d -a -x /usr/sbin/itox ]; then
61 if egrep -q '^poppassd' /etc/inetd.conf && \
62 [ ! -e /etc/xinetd.d/poppassd ]; then
64 echo -n "CN: Enabling poppassd in /etc/xinetd.d/poppassd"
65 grep "^poppassd" /etc/inetd.conf | \
66 itox -daemon_dir /usr/sbin | cp-update "$PKG" /etc/xinetd.d/poppassd
73 # Restart xinetd if needed.
75 [ "$changed_config" ] && do=reload
76 pgrep -u root -f /usr/sbin/xinetd > /dev/null || do=start
80 if [ -x "/etc/init.d/xinetd" ]; then
81 if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
82 invoke-rc.d xinetd "$do" || exit $?
84 /etc/init.d/xinetd "$do" || exit $?