Tranzicijski paket za buduci prelazak na Debian Lenny.
[squirrelmail-cn.git] / debian / postinst
index d387dab..c53e5f0 100644 (file)
@@ -4,6 +4,9 @@ set -e
 
 [ "$DEBIAN_SCRIPT_DEBUG" ] && set -x 
 
+# Source debconf library.
+. /usr/share/debconf/confmodule
+
 case "$1" in
        configure)
                # continue below
@@ -43,6 +46,23 @@ mv_old_backups() {
        fi
 }
 
+# listconffiles ()
+#
+#   Recursively walks /etc/apache2/apache2.conf for Include directives.
+#   Returns all configfiles so defined.
+#
+function listconffiles () {
+
+        local i incs
+
+        incs=`awk 'tolower($1) == "include" { sub("/$","/*",$2); print $2; }' $1`
+        if [ -n "$incs" ]; then
+            for i in $incs; do
+                if [ -e "$i" ]; then echo "$i"; listconffiles "$i"; fi
+            done
+        fi
+}
+
 
 reload=""
 DATE=`date +%Y-%m-%d.%H:%M:%S`
@@ -110,10 +130,11 @@ sconf=/etc/apache2/sites-available/ssl
 # (directory /etc/apache2/conf.d/), but only if we are not present in 
 # Apache2 configuration at all.
 #
-# We're using listconffiles from apache-common Debian package. Yes, 
-# it works with Apache2 configurations too.
+# We're not using listconffiles from apache-common Debian package.
+# apache-common is no longer available in Debian Lenny. We're using
+# listconffiles() function instead.
 #
-apache2listconf=`/usr/share/apache/listconffiles -V $hconf | tr '\a' ' ' | grep "$CONF"` || true
+apache2listconf=`listconffiles "$hconf" | grep "$CONF"` || true
 apache2squirrel=`ls -l /etc/apache2/conf.d/ | grep "$CONF"` || true
 
 if [ -z "$apache2listconf" -a -z "$apache2squirrel" ]; then
@@ -145,13 +166,26 @@ seddef="/^[       ]*\\\$org_logo[         ]*=/s/sm_logo\.jpg/sm_carnet_logo.png/;
        /^[     ]*\\\$data_dir[         ]*=/s/\.\.\/data\//\/var\/lib\/squirrelmail\/data\//;
        "
 
-# Check for our uw-imap package; if it is installed, assume it's used.
+# Left frame size to 220px.
+# $default_left_size = '220';
+#
+db_get squirrelmail-cn/leftwidth || true
+if [ "$RET" = "true" ]; then
+  seddef="$seddef/^[   ]*\\\$default_left_size[        ]*=/s/'[0-9]*'/'220'/;
+       "
+fi
+
+# Change CSS file for Squirrelmail.
+# $theme_css = SM_PATH . 'themes/css/squirrelmail-cn.css';
 #
-if dpkg -l uw-imap-ssl-cn 2>/dev/null | grep -q '^ii'; then
-  seddef="$seddef/^[   ]*\\\$imap_server_type[         ]*=/ {s/cyrus/uw/;s/other/uw/;}
+db_get squirrelmail-cn/themecss || true
+if [ "$RET" = "true" ]; then
+  seddef="$seddef/^[   ]*\\\$theme_css[        ]*=/s/=.*/= SM_PATH . 'themes\/css\/squirrelmail-cn.css';/;
        "
 fi
 
+db_stop || true
+
 # Check for our dovecot package; if it is installed, assume it's used.
 #
 if dpkg -l dovecot-cn 2>/dev/null | grep -q '^ii'; then