5 [ "$DEBIAN_SCRIPT_DEBUG" ] && set -vx
12 abort-upgrade|abort-remove|abort-deconfigure)
17 echo "postinst called with unknown argument \`$1'" >&2
24 . /usr/share/debconf/confmodule
26 # Include CARNet functions
27 . /usr/share/carnet-tools/functions.sh
30 WDIR="/var/www/webalizer"
31 WHTPASSWD="$WDIR/.htpasswd"
32 WCONF="/etc/webalizer/webalizer.conf"
33 WCONFBAK=`basename $WCONF`
34 oldreporttitle="Usage Statistics for"
35 reporttitle="Statistika pristupa za"
38 if [ -f "$WCONF" ]; then
41 if cp_check_and_backup "$WCONFBAK"; then
42 cp_echo "CN: Old $WCONF saved as \"/var/backups/$WCONFBAK.bak\"."
46 temp=`awk 'tolower($1) == "outputdir" { print $2; }' $WCONF | tail -n 1`
47 if [ "$temp" != "$WDIR" ]; then
48 db_set webalizer/directory "$temp" || true
51 # Check for ReportTitle
52 temp=`awk 'tolower($1) == "reporttitle" { for(i=2; i<NF; i++) printf("%s ", $i); print $(NF) }' $WCONF | tail -n 1`
53 if [ "$temp" = "$oldreporttitle" ]; then
55 temp_re="^[[:space:]]*ReportTitle[[:space:]]*${oldreporttitle}$"
56 cp_check_and_sed "." \
57 "s/$temp_re/ReportTitle ${reporttitle}/I" \
59 db_set webalizer/doc_title "$reporttitle" || true
62 cp_echo "CN: Configuration file $WCONF is missing."
68 # Check Apache2 web server configuration and reload Apache2 web server.
70 if /usr/sbin/apache2ctl configtest 2>/dev/null; then
72 # Reload Apache2 web server.
73 if [ -x "/etc/init.d/apache2" ]; then
74 if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
75 invoke-rc.d apache2 reload || true
77 /etc/init.d/apache2 reload || true
82 # Something is broken.
83 cp_echo "CN: Your Apache2 configuration is broken."
84 cp_echo "CN: Please, check the service after the installation finishes!"
88 # Generate e-mail message with informations (username and password).
90 if [ ! -f "$WHTPASSWD" ]; then
91 passwd=`makepasswd --chars 8`
92 htpasswd -bcm $WHTPASSWD admin $passwd 2> /dev/null
94 cp_echo "CN: Webalizer URL is http://`hostname -f`/stats/"
95 cp_echo "CN: User: admin"
96 cp_echo "CN: Password: $passwd"
98 cp_echo "CN: Use \"htpasswd -m $WHTPASSWD admin\" to change it."