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"
41 if [ -f "$WCONF" ]; then
44 if cp_check_and_backup "$WCONF"; then
45 cp_echo "CN: Old $WCONF saved as \"/var/backups/$WCONFBAK.bak\"."
49 temp=`awk 'tolower($1) == "outputdir" { print $2; }' $WCONF | tail -n 1`
50 if [ "$temp" != "$WDIR" ]; then
51 cp_echo "CN: Found custom OutputDir value: $temp"
52 db_set webalizer/directory "$temp" || true
56 # Check for ReportTitle
57 temp=`awk 'tolower($1) == "reporttitle" { for(i=2; i<NF; i++) \
58 printf("%s ", tolower($i)); print tolower($(NF)) }' $WCONF | tail -n 1`
59 if [ "$temp" = "$oldreporttitle" ]; then
60 temp_re="^[[:space:]]*ReportTitle[[:space:]]*${oldreporttitle}$"
61 cp_check_and_sed "." \
62 "s/$temp_re/ReportTitle ${reporttitle}/I" \
64 db_set webalizer/doc_title "$reporttitle" || true
68 cp_echo "CN: Configuration file $WCONF is missing."
75 # Check Apache2 web server configuration and reload Apache2 web server.
77 if [ $need_restart -eq 1 ]; then
78 if apache2ctl configtest 2>/dev/null; then
79 invoke-rc.d apache2 force-reload || true
81 # Something is broken.
82 cp_echo "CN: Your Apache2 configuration is broken."
83 cp_echo "CN: Please, check the service after the installation finishes!"
88 # Generate e-mail message with informations (username and password).
90 if [ $customized -eq 0 ]; then
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."
101 cp_echo "CN: File $WHTPASSWD already exists."
104 cp_echo "CN: Skipping file $WHTPASSWD"
111 # dh_installdeb will replace this with shell code automatically
112 # generated by other debhelper scripts.