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"
21 # Configure poppassd to refuse connection from all hosts
22 # but localhost (127.0.0.1).
24 if [ ! -f /etc/hosts.deny ]; then
27 if ! egrep -q '^poppassd:' /etc/hosts.deny; then
28 echo "poppassd: ALL" | cp-update "$PKG" /etc/hosts.deny
30 if [ ! -f /etc/hosts.allow ]; then
31 touch /etc/hosts.allow
33 if ! egrep -q '^poppassd:' /etc/hosts.allow; then
34 echo "poppassd: 127.0.0.1" | cp-update "$PKG" /etc/hosts.allow
38 # First of all, do the backup.
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
48 if [ $done_backup -eq 1 ]; then
49 cp_echo "CN: Backup is located in directory: /var/backups/$PKG/"
53 # Remove change_pass configuration files if earlier version is
56 if [ "$2" ] && dpkg --compare-versions $2 lt 3.0-1; then
58 cp_echo "CN: This version of change_pass plugin contains major changes."
59 for cpconf_file in $SQCPCONF $CPCONF; do
60 if [ -f "$cpconf_file" ] || [ -L "$cpconf_file" ]; then
62 cp_echo "CN: Removed old $cpconf_file"
68 # Check for change_pass configuration files and notify user about
69 # minimum password length configuration.
71 if egrep -q '^\$plugins\[[0-9]+\][\ ]*=[\ ]*'\''change_pass'\' "$SQCONF"; then
72 /usr/sbin/squirrelmail-configure --remove-plugin change_pass
75 if [ ! -f "$SQCPCONF" ]; then
77 if [ -f "$CPCONF" ]; then
78 cp -f "$CPCONF" "$SQCPCONF"
79 cp_echo "CN: $CPCONF copied to $SQCPCONF"
82 # Configuration file does not exist.
83 cp_echo "CN: Generating new file $SQCPCONF"
84 cat > "$SQCPCONF" <<EOF
86 // The default server is the configured IMAP server
87 #\$poppass_server = 'localhost';
89 // The default port is 106
90 #\$poppass_port = 106;
92 \$min_pass_length = 8;
93 \$max_pass_length = 9999999;
100 ln -sf "$SQCPCONF" "$CPCONF"
102 if [ $min_pass_changed -eq 1 ]; then
103 cp_echo "CN: Minimum password length has been set to 8 characters."
107 # Enable change_pass plugin in SquirrelMail config.php.
109 if ! egrep -q '^\$plugins\[[0-9]+\][\ ]*=[\ ]*'\''change_pass'\' "$SQCONF"; then
110 /usr/sbin/squirrelmail-configure --install-plugin change_pass
114 # Convert poppassd service from inetd.conf to xinetd.conf type.
115 # Service configuration is saved in /etc/xinetd.d/ directory.
117 if [ -x /etc/init.d/xinetd -a -d /etc/xinetd.d -a -x /usr/sbin/itox ]; then
119 if egrep -q '^poppassd' /etc/inetd.conf && \
120 [ ! -f /etc/xinetd.d/poppassd ]; then
122 cp_echo "CN: Enabling poppassd in /etc/xinetd.d/poppassd"
124 touch /etc/xinetd.d/poppassd.$$
125 grep "^poppassd" /etc/inetd.conf | \
126 itox -daemon_dir /usr/sbin | cp-update "$PKG" /etc/xinetd.d/poppassd.$$
127 cp_mv /etc/xinetd.d/poppassd.$$ /etc/xinetd.d/poppassd
134 # Restart xinetd if needed.
136 if [ $need_restart -eq 1 ]; then
138 if [ -x "/etc/init.d/xinetd" ]; then
139 if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
140 invoke-rc.d xinetd restart || exit $?
142 /etc/init.d/xinetd restart || exit $?