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
27 # Include CARNet functions
28 . /usr/share/carnet-tools/functions.sh
31 WDIR="/var/www/webalizer"
32 WHTPASSWD="$WDIR/.htpasswd"
33 WCONF="/etc/webalizer/webalizer.conf"
34 WCONFBAK=`basename $WCONF`
35 oldreporttitle="usage statistics for"
36 reporttitle="Statistika pristupa za"
39 if [ -f "$WCONF" ]; then
42 if cp_check_and_backup "$WCONF"; then
43 cp_echo "CN: Old $WCONF saved as \"/var/backups/$WCONFBAK.bak\"."
47 temp=`awk 'tolower($1) == "outputdir" { print $2; }' $WCONF | tail -n 1`
48 if [ "$temp" != "$WDIR" ]; then
49 db_set webalizer/directory "$temp" || true
52 # Check for ReportTitle
53 temp=`awk 'tolower($1) == "reporttitle" { for(i=2; i<NF; i++) \
54 printf("%s ", tolower($i)); print tolower($(NF)) }' $WCONF | tail -n 1`
55 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 apache2ctl configtest 2>/dev/null; then
72 invoke-rc.d apache2 force-reload || true
74 # Something is broken.
75 cp_echo "CN: Your Apache2 configuration is broken."
76 cp_echo "CN: Please, check the service after the installation finishes!"
80 # Generate e-mail message with informations (username and password).
82 if [ ! -f "$WHTPASSWD" ]; then
83 passwd="$(makepasswd --chars 8)"
84 htpasswd -bcm $WHTPASSWD admin $passwd 2> /dev/null
86 cp_echo "CN: Webalizer URL is http://`hostname -f`/stats/"
87 cp_echo "CN: User: admin"
88 cp_echo "CN: Password: $passwd"
90 cp_echo "CN: Use \"htpasswd -m $WHTPASSWD admin\" to change it."
97 # dh_installdeb will replace this with shell code automatically
98 # generated by other debhelper scripts.