Prva inacica paketa za Debian jessie distribuciju.
[webalizer-cn.git] / debian / postinst
index 2203c52..9c07c04 100755 (executable)
@@ -10,12 +10,12 @@ case "$1" in
     ;;
 
     abort-upgrade|abort-remove|abort-deconfigure)
-    exit 0
+        exit 0
     ;;
 
     *)
-    echo "postinst called with unknown argument \`$1'" >&2
-    exit 0
+        echo "postinst called with unknown argument \`$1'" >&2
+        exit 0
     ;;
 esac
 
@@ -32,17 +32,53 @@ WDIR="/var/www/webalizer"
 WHTPASSWD="$WDIR/.htpasswd"
 WCONF="/etc/webalizer/webalizer.conf"
 WCONFBAK=`basename $WCONF`
+
 oldreporttitle="usage statistics for"
 reporttitle="Statistika pristupa za"
-
 customized=0
-need_restart=0
+
+
+if [ -e /usr/share/apache2/apache2-maintscript-helper ]; then
+    . /usr/share/apache2/apache2-maintscript-helper
+
+    webalizer_enable() {
+        cp_echo "CN: Enabling $PKG configuration for Apache2."
+        return 0
+    }
+else
+    cp_echo "CN: Could not load Apache 2.4 maintainer script helper."
+
+    webalizer_enable() {
+        return 1
+    }
+fi
+
+webalizer_error() {
+    cp_echo "CN: Error while trying to enable $PKG configuration for Apache2."
+}
+
+mv_conffile()
+{
+    local oldconffile="$1"
+    local newconffile="$2"
+
+    rm -f $oldconffile.dpkg-remove
+    [ -e "$oldconffile" ] || return 0
+
+    cp_echo "CN: Preserving user changes to $newconffile (renamed from $oldconffile)."
+    mv -f "$newconffile" "$newconffile.dpkg-new"
+    mv -f "$oldconffile" "$newconffile"
+}
+
+
+mv_conffile /etc/apache2/conf.d/$PKG.conf \
+    /etc/apache2/conf-available/$PKG.conf
 
 if [ -f "$WCONF" ]; then
 
     # Backup first.
     if cp_check_and_backup "$WCONF"; then
-        cp_echo "CN: Old $WCONF saved as \"/var/backups/$WCONFBAK.bak\"."
+        cp_echo "CN: Old $WCONF saved as /var/backups/$WCONFBAK.bak."
     fi
 
     # Check for OutputDir
@@ -62,7 +98,6 @@ if [ -f "$WCONF" ]; then
             "s/$temp_re/ReportTitle    ${reporttitle}/I" \
             "$WCONF" || true
         db_set webalizer/doc_title "$reporttitle" || true
-        need_restart=1
     fi
 else
     cp_echo "CN: Configuration file $WCONF is missing."
@@ -72,19 +107,6 @@ fi
 db_stop || true
 
 
-# Check Apache2 web server configuration and reload Apache2 web server.
-#
-if [ $need_restart -eq 1 ]; then
-    if apache2ctl configtest 2>/dev/null; then
-        invoke-rc.d apache2 force-reload || true
-    else
-        # Something is broken.
-        cp_echo "CN: Your Apache2 configuration is broken."
-        cp_echo "CN: Please, check the service after the installation finishes!"
-    fi
-fi
-
-
 # Generate e-mail message with informations (username and password).
 #
 if [ $customized -eq 0 ]; then
@@ -104,13 +126,15 @@ else
     cp_echo "CN: Skipping file $WHTPASSWD"
 fi
 
+#DEBHELPER#
+
+if ! apache2ctl configtest >/dev/null 2>&1; then
+    cp_echo "CN: Your Apache2 configuration seems to be broken."
+    cp_echo "CN: Please, check the service after the installation finishes!"
+fi
+
 # Mail root.
 #
 cp_mail "$PKG"
 
-# dh_installdeb will replace this with shell code automatically
-# generated by other debhelper scripts.
-
-#DEBHELPER#
-
 exit 0