set -e
[ "$DEBIAN_SCRIPT_DEBUG" ] && set -vx
+[ "$DEBIAN_SCRIPT_DEBUG" ] && set -vx
-case "$1" in
- configure)
- # continue below
- ;;
-
- abort-upgrade|abort-remove|abort-deconfigure)
- exit 0
- ;;
-
- *)
- echo "postinst called with unknown argument \`$1'" >&2
- exit 0
- ;;
-esac
-
-
-# Load debconf
+# Load Debconf
. /usr/share/debconf/confmodule
db_version 2.0
-# Include CARNet functions
+# Include CARNet Tools
. /usr/share/carnet-tools/functions.sh
PKG="webalizer-cn"
if [ -e /usr/share/apache2/apache2-maintscript-helper ]; then
- . /usr/share/apache2/apache2-maintscript-helper
+ . /usr/share/apache2/apache2-maintscript-helper
- webalizer_enable() {
- cp_echo "CN: Enabling $PKG configuration for Apache2."
- return 0
- }
+ webalizer_enable() {
+ cp_echo "CN: Enabling $PKG configuration for Apache2."
+ return 0
+ }
else
- cp_echo "CN: Could not load Apache 2.4 maintainer script helper."
+ cp_echo "CN: Could not load Apache 2.4 maintainer script helper."
- webalizer_enable() {
- return 1
- }
+ webalizer_enable() {
+ return 1
+ }
fi
webalizer_error() {
- cp_echo "CN: Error while trying to enable $PKG configuration for Apache2."
+ cp_echo "CN: Error while trying to enable $PKG configuration for Apache2."
}
mv_conffile()
{
- local oldconffile="$1"
- local newconffile="$2"
+ local oldconffile="$1"
+ local newconffile="$2"
- rm -f $oldconffile.dpkg-remove
- [ -e "$oldconffile" ] || return 0
+ rm -f $oldconffile.dpkg-remove
+ [ -e "$oldconffile" ] || return 0
- cp_echo "CN: Preserving user changes to $newconffile (renamed from $oldconffile)."
- mv -f "$newconffile" "$newconffile.dpkg-new"
- mv -f "$oldconffile" "$newconffile"
+ cp_echo "CN: Preserving user changes to $newconffile (renamed from $oldconffile)."
+ mv -f "$newconffile" "$newconffile.dpkg-new"
+ mv -f "$oldconffile" "$newconffile"
}
-mv_conffile /etc/apache2/conf.d/$PKG.conf \
- /etc/apache2/conf-available/$PKG.conf
+mv_conffile /etc/apache2/conf.d/$PKG.conf /etc/apache2/conf-available/$PKG.conf
if [ -f "$WCONF" ]; then
-
- # Backup first.
- if cp_check_and_backup "$WCONF"; then
- cp_echo "CN: Old $WCONF saved as /var/backups/$WCONFBAK.bak."
- fi
-
- # Check for OutputDir
- temp=`awk 'tolower($1) == "outputdir" { print $2; }' $WCONF | tail -n 1`
- if [ "$temp" != "$WDIR" ]; then
- cp_echo "CN: Found custom OutputDir value: $temp"
- db_set webalizer/directory "$temp" || true
- customized=1
- fi
-
- # Check for ReportTitle
- temp=`awk 'tolower($1) == "reporttitle" { for(i=2; i<NF; i++) \
- printf("%s ", tolower($i)); print tolower($(NF)) }' $WCONF | tail -n 1`
- if [ "$temp" = "$oldreporttitle" ]; then
- temp_re="^[[:space:]]*ReportTitle[[:space:]]*${oldreporttitle}$"
- cp_check_and_sed "." \
- "s/$temp_re/ReportTitle ${reporttitle}/I" \
- "$WCONF" || true
- db_set webalizer/doc_title "$reporttitle" || true
- fi
-else
- cp_echo "CN: Configuration file $WCONF is missing."
+ # Backup first.
+ if cp_check_and_backup "$WCONF"; then
+ cp_echo "CN: Old $WCONF saved as /var/backups/$WCONFBAK.bak."
+ fi
+
+ # Check for OutputDir
+ temp=`awk 'tolower($1) == "outputdir" { print $2; }' $WCONF | tail -n 1`
+ if [ "$temp" != "$WDIR" ]; then
+ cp_echo "CN: Found custom OutputDir value: $temp"
+ db_set webalizer/directory "$temp" || true
customized=1
+ fi
+
+ # Check for ReportTitle
+ temp=`awk 'tolower($1) == "reporttitle" { for(i=2; i<NF; i++) \
+ printf("%s ", tolower($i)); print tolower($(NF)) }' $WCONF | tail -n 1`
+ if [ "$temp" = "$oldreporttitle" ]; then
+ temp_re="^[[:space:]]*ReportTitle[[:space:]]*${oldreporttitle}$"
+ cp_check_and_sed "." \
+ "s/$temp_re/ReportTitle ${reporttitle}/I" \
+ "$WCONF" || true
+ db_set webalizer/doc_title "$reporttitle" || true
+ fi
+else
+ cp_echo "CN: Configuration file $WCONF is missing."
+ customized=1
fi
db_stop || true
# Generate e-mail message with informations (username and password).
#
if [ $customized -eq 0 ]; then
- if [ ! -f "$WHTPASSWD" ]; then
- passwd="$(makepasswd --chars 8)"
- htpasswd -bcm $WHTPASSWD admin $passwd 2> /dev/null
- cp_echo ""
- cp_echo "CN: Webalizer URL is http://`hostname -f`/stats/"
- cp_echo "CN: User: admin"
- cp_echo "CN: Password: $passwd"
- cp_echo ""
- cp_echo "CN: Use \"htpasswd -m $WHTPASSWD admin\" to change it."
- else
- cp_echo "CN: File $WHTPASSWD already exists."
- fi
+ if [ ! -f "$WHTPASSWD" ]; then
+ passwd="$(makepasswd --chars 8)"
+ htpasswd -bcm $WHTPASSWD admin $passwd 2> /dev/null
+ cp_echo ""
+ cp_echo "CN: Webalizer URL is http://`hostname -f`/stats/"
+ cp_echo "CN: User: admin"
+ cp_echo "CN: Password: $passwd"
+ cp_echo ""
+ cp_echo "CN: Use \"htpasswd -m $WHTPASSWD admin\" to change it."
+ else
+ cp_echo "CN: File $WHTPASSWD already exists."
+ fi
else
- cp_echo "CN: Skipping file $WHTPASSWD"
+ cp_echo "CN: Skipping file $WHTPASSWD"
fi
#DEBHELPER#
if ! apache2ctl configtest >/dev/null 2>&1; then
- cp_echo "CN: Your Apache2 configuration seems to be broken."
- cp_echo "CN: Please, check the service after the installation finishes!"
+ cp_echo "CN: Your Apache2 configuration seems to be broken."
+ cp_echo "CN: Please, check the service after the installation finishes!"
fi
# Mail root.