Prva inacica paketa za Debian wheezy distribuciju.
[webalizer-cn.git] / debian / postinst
index 6d76d60..2203c52 100755 (executable)
@@ -35,6 +35,8 @@ WCONFBAK=`basename $WCONF`
 oldreporttitle="usage statistics for"
 reporttitle="Statistika pristupa za"
 
+customized=0
+need_restart=0
 
 if [ -f "$WCONF" ]; then
 
@@ -46,7 +48,9 @@ if [ -f "$WCONF" ]; then
     # Check for OutputDir
     temp=`awk 'tolower($1) == "outputdir" { print $2; }' $WCONF | tail -n 1`
     if [ "$temp" != "$WDIR" ]; then
+        cp_echo "CN: Found custom OutputDir value: $temp"
         db_set webalizer/directory "$temp" || true
+        customized=1
     fi
 
     # Check for ReportTitle
@@ -58,9 +62,11 @@ 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."
+    customized=1
 fi
 
 db_stop || true
@@ -68,26 +74,34 @@ db_stop || true
 
 # Check Apache2 web server configuration and reload Apache2 web server.
 #
-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!"
+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 [ ! -f "$WHTPASSWD" ]; then
-    passwd="$(makepasswd --chars 8)"
-    htpasswd -bcm $WHTPASSWD admin $passwd 2> /dev/null
-    cp_echo ""
-    cp_echo "CN: Webalizer URL is http://`hostname -f`/stats/"
-    cp_echo "CN:            User: admin"
-    cp_echo "CN:        Password: $passwd"
-    cp_echo ""
-    cp_echo "CN: Use \"htpasswd -m $WHTPASSWD admin\" to change it."
+if [ $customized -eq 0 ]; then
+    if [ ! -f "$WHTPASSWD" ]; then
+        passwd="$(makepasswd --chars 8)"
+        htpasswd -bcm $WHTPASSWD admin $passwd 2> /dev/null
+        cp_echo ""
+        cp_echo "CN: Webalizer URL is http://`hostname -f`/stats/"
+        cp_echo "CN:            User: admin"
+        cp_echo "CN:        Password: $passwd"
+        cp_echo ""
+        cp_echo "CN: Use \"htpasswd -m $WHTPASSWD admin\" to change it."
+    else
+        cp_echo "CN: File $WHTPASSWD already exists."
+    fi
+else
+    cp_echo "CN: Skipping file $WHTPASSWD"
 fi
 
 # Mail root.