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 "$WCONF"; 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++) \
53 printf("%s ", tolower($i)); print tolower($(NF)) }' $WCONF | tail -n 1`
54 if [ "$temp" = "$oldreporttitle" ]; then
56 temp_re="^[[:space:]]*ReportTitle[[:space:]]*${oldreporttitle}$"
57 cp_check_and_sed "." \
58 "s/$temp_re/ReportTitle ${reporttitle}/I" \
60 db_set webalizer/doc_title "$reporttitle" || true
63 cp_echo "CN: Configuration file $WCONF is missing."
69 # Check Apache2 web server configuration and reload Apache2 web server.
71 if /usr/sbin/apache2ctl configtest 2>/dev/null; then
73 # Reload Apache2 web server.
74 if [ -x "/etc/init.d/apache2" ]; then
75 if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
76 invoke-rc.d apache2 reload || true
78 /etc/init.d/apache2 reload || true
83 # Something is broken.
84 cp_echo "CN: Your Apache2 configuration is broken."
85 cp_echo "CN: Please, check the service after the installation finishes!"
89 # Generate e-mail message with informations (username and password).
91 if [ ! -f "$WHTPASSWD" ]; then
92 passwd=`makepasswd --chars 8`
93 htpasswd -bcm $WHTPASSWD admin $passwd 2> /dev/null
95 cp_echo "CN: Webalizer URL is http://`hostname -f`/stats/"
96 cp_echo "CN: User: admin"
97 cp_echo "CN: Password: $passwd"
99 cp_echo "CN: Use \"htpasswd -m $WHTPASSWD admin\" to change it."