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`
36 oldreporttitle="usage statistics for"
37 reporttitle="Statistika pristupa za"
41 if [ -e /usr/share/apache2/apache2-maintscript-helper ]; then
42 . /usr/share/apache2/apache2-maintscript-helper
45 cp_echo "CN: Enabling $PKG configuration for Apache2."
49 cp_echo "CN: Could not load Apache 2.4 maintainer script helper."
57 cp_echo "CN: Error while trying to enable $PKG configuration for Apache2."
62 local oldconffile="$1"
63 local newconffile="$2"
65 rm -f $oldconffile.dpkg-remove
66 [ -e "$oldconffile" ] || return 0
68 cp_echo "CN: Preserving user changes to $newconffile (renamed from $oldconffile)."
69 mv -f "$newconffile" "$newconffile.dpkg-new"
70 mv -f "$oldconffile" "$newconffile"
74 mv_conffile /etc/apache2/conf.d/$PKG.conf \
75 /etc/apache2/conf-available/$PKG.conf
77 if [ -f "$WCONF" ]; then
80 if cp_check_and_backup "$WCONF"; then
81 cp_echo "CN: Old $WCONF saved as /var/backups/$WCONFBAK.bak."
85 temp=`awk 'tolower($1) == "outputdir" { print $2; }' $WCONF | tail -n 1`
86 if [ "$temp" != "$WDIR" ]; then
87 cp_echo "CN: Found custom OutputDir value: $temp"
88 db_set webalizer/directory "$temp" || true
92 # Check for ReportTitle
93 temp=`awk 'tolower($1) == "reporttitle" { for(i=2; i<NF; i++) \
94 printf("%s ", tolower($i)); print tolower($(NF)) }' $WCONF | tail -n 1`
95 if [ "$temp" = "$oldreporttitle" ]; then
96 temp_re="^[[:space:]]*ReportTitle[[:space:]]*${oldreporttitle}$"
97 cp_check_and_sed "." \
98 "s/$temp_re/ReportTitle ${reporttitle}/I" \
100 db_set webalizer/doc_title "$reporttitle" || true
103 cp_echo "CN: Configuration file $WCONF is missing."
110 # Generate e-mail message with informations (username and password).
112 if [ $customized -eq 0 ]; then
113 if [ ! -f "$WHTPASSWD" ]; then
114 passwd="$(makepasswd --chars 8)"
115 htpasswd -bcm $WHTPASSWD admin $passwd 2> /dev/null
117 cp_echo "CN: Webalizer URL is http://`hostname -f`/stats/"
118 cp_echo "CN: User: admin"
119 cp_echo "CN: Password: $passwd"
121 cp_echo "CN: Use \"htpasswd -m $WHTPASSWD admin\" to change it."
123 cp_echo "CN: File $WHTPASSWD already exists."
126 cp_echo "CN: Skipping file $WHTPASSWD"
131 if ! apache2ctl configtest >/dev/null 2>&1; then
132 cp_echo "CN: Your Apache2 configuration seems to be broken."
133 cp_echo "CN: Please, check the service after the installation finishes!"