5 [ "$DEBIAN_SCRIPT_DEBUG" ] && set -vx
6 [ "$DEBIAN_SCRIPT_DEBUG" ] && set -vx
9 . /usr/share/debconf/confmodule
12 # Include CARNet Tools
13 . /usr/share/carnet-tools/functions.sh
16 WDIR="/var/www/webalizer"
17 WHTPASSWD="$WDIR/.htpasswd"
18 WCONF="/etc/webalizer/webalizer.conf"
19 WCONFBAK=`basename $WCONF`
21 oldreporttitle="usage statistics for"
22 reporttitle="Statistika pristupa za"
26 if [ -e /usr/share/apache2/apache2-maintscript-helper ]; then
27 . /usr/share/apache2/apache2-maintscript-helper
30 cp_echo "CN: Enabling $PKG configuration for Apache2."
34 cp_echo "CN: Could not load Apache 2.4 maintainer script helper."
42 cp_echo "CN: Error while trying to enable $PKG configuration for Apache2."
47 local oldconffile="$1"
48 local newconffile="$2"
50 rm -f $oldconffile.dpkg-remove
51 [ -e "$oldconffile" ] || return 0
53 cp_echo "CN: Preserving user changes to $newconffile (renamed from $oldconffile)."
54 mv -f "$newconffile" "$newconffile.dpkg-new"
55 mv -f "$oldconffile" "$newconffile"
59 mv_conffile /etc/apache2/conf.d/$PKG.conf /etc/apache2/conf-available/$PKG.conf
61 if [ -f "$WCONF" ]; then
63 if cp_check_and_backup "$WCONF"; then
64 cp_echo "CN: Old $WCONF saved as /var/backups/$WCONFBAK.bak."
68 temp=`awk 'tolower($1) == "outputdir" { print $2; }' $WCONF | tail -n 1`
69 if [ "$temp" != "$WDIR" ]; then
70 cp_echo "CN: Found custom OutputDir value: $temp"
71 db_set webalizer/directory "$temp" || true
75 # Check for ReportTitle
76 temp=`awk 'tolower($1) == "reporttitle" { for(i=2; i<NF; i++) \
77 printf("%s ", tolower($i)); print tolower($(NF)) }' $WCONF | tail -n 1`
78 if [ "$temp" = "$oldreporttitle" ]; then
79 temp_re="^[[:space:]]*ReportTitle[[:space:]]*${oldreporttitle}$"
80 cp_check_and_sed "." \
81 "s/$temp_re/ReportTitle ${reporttitle}/I" \
83 db_set webalizer/doc_title "$reporttitle" || true
86 cp_echo "CN: Configuration file $WCONF is missing."
93 # Generate e-mail message with informations (username and password).
95 if [ $customized -eq 0 ]; then
96 if [ ! -f "$WHTPASSWD" ]; then
97 passwd="$(makepasswd --chars 8)"
98 htpasswd -bcm $WHTPASSWD admin $passwd 2> /dev/null
100 cp_echo "CN: Webalizer URL is http://`hostname -f`/stats/"
101 cp_echo "CN: User: admin"
102 cp_echo "CN: Password: $passwd"
104 cp_echo "CN: Use \"htpasswd -m $WHTPASSWD admin\" to change it."
106 cp_echo "CN: File $WHTPASSWD already exists."
109 cp_echo "CN: Skipping file $WHTPASSWD"
114 if ! apache2ctl configtest >/dev/null 2>&1; then
115 cp_echo "CN: Your Apache2 configuration seems to be broken."
116 cp_echo "CN: Please, check the service after the installation finishes!"