5 [ "$1" = "configure" ] || exit 0
6 [ $DEBIAN_SCRIPT_DEBUG ] && set -vx
8 # Include CARNet functions
9 . /usr/share/carnet-tools/functions.sh
11 PKG="squirrelmail-change-pass-cn"
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"
20 # Configure poppassd to refuse connection from all hosts
21 # but localhost (127.0.0.1).
23 if [ ! -f /etc/hosts.deny ]; then
26 if ! egrep -q '^poppassd:' /etc/hosts.deny; then
27 echo "poppassd: ALL" | cp-update "$PKG" /etc/hosts.deny
29 if [ ! -f /etc/hosts.allow ]; then
30 touch /etc/hosts.allow
32 if ! egrep -q '^poppassd:' /etc/hosts.allow; then
33 echo "poppassd: 127.0.0.1" | cp-update "$PKG" /etc/hosts.allow
37 # First of all, do the backup.
40 for cpconf_file in $SQCPCONF $CPCONF; do
41 if [ -f "$cpconf_file" ] && [ ! -L "$cpconf_file" ]; then
42 cp_echo "CN: Doing backup for $cpconf_file"
43 cp_backup_conffile -d "/var/backups/$PKG" -p $cpconf_file
47 if [ $done_backup -eq 1 ]; then
48 cp_echo "CN: Backup is located in directory: /var/backups/$PKG/"
52 # Enable change_pass plugin in SquirrelMail config.php.
54 if ! egrep -q '^\$plugins\[[0-9]+\][\ ]*=[\ ]*'\''change_pass'\' "$SQCONF"; then
55 /usr/sbin/squirrelmail-configure --install-plugin change_pass
59 # Convert poppassd service from inetd.conf to xinetd.conf type.
60 # Service configuration is saved in /etc/xinetd.d/ directory.
62 if [ -x /etc/init.d/xinetd -a -d /etc/xinetd.d -a -x /usr/sbin/itox ]; then
64 if egrep -q '^poppassd' /etc/inetd.conf && \
65 [ ! -f /etc/xinetd.d/poppassd ]; then
67 cp_echo "CN: Enabling poppassd in /etc/xinetd.d/poppassd"
69 touch /etc/xinetd.d/poppassd.$$
70 grep "^poppassd" /etc/inetd.conf | \
71 itox -daemon_dir /usr/sbin | cp-update "$PKG" /etc/xinetd.d/poppassd.$$
72 cp_mv /etc/xinetd.d/poppassd.$$ /etc/xinetd.d/poppassd
79 # Restart xinetd if needed.
81 if [ $need_restart -eq 1 ]; then
83 if [ -x "/etc/init.d/xinetd" ]; then
84 if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
85 invoke-rc.d xinetd restart || exit $?
87 /etc/init.d/xinetd restart || exit $?