X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=blobdiff_plain;f=debian%2Fpostinst;h=9c07c04cdc8b62cc46a6c57ed39c413693997bdd;hb=65b0443e21141dfbc0e3523ad8c69ba7fc5af06a;hp=93fc429902c474a7821429f79998cb495dbda0db;hpb=f7033eaa1824362d69465a9ca29c6fd180efb713;p=webalizer-cn.git diff --git a/debian/postinst b/debian/postinst index 93fc429..9c07c04 100755 --- a/debian/postinst +++ b/debian/postinst @@ -5,23 +5,24 @@ set -e [ "$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 - ;; + configure) + # continue below + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + exit 0 + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 0 + ;; esac # Load debconf . /usr/share/debconf/confmodule +db_version 2.0 # Include CARNet functions . /usr/share/carnet-tools/functions.sh @@ -31,73 +32,106 @@ WDIR="/var/www/webalizer" WHTPASSWD="$WDIR/.htpasswd" WCONF="/etc/webalizer/webalizer.conf" WCONFBAK=`basename $WCONF` -oldreporttitle="Usage Statistics for" + +oldreporttitle="usage statistics for" reporttitle="Statistika pristupa za" +customized=0 -if [ -f "$WCONF" ]; then +if [ -e /usr/share/apache2/apache2-maintscript-helper ]; then + . /usr/share/apache2/apache2-maintscript-helper - # Backup first. - if cp_check_and_backup "$WCONFBAK"; 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 - db_set webalizer/directory "$temp" || true - fi - - # Check for ReportTitle - temp=`awk 'tolower($1) == "reporttitle" { for(i=2; i/dev/null; then - - # Reload Apache2 web server. - if [ -x "/etc/init.d/apache2" ]; then - if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then - invoke-rc.d apache2 reload || true - else - /etc/init.d/apache2 reload || true - fi - fi -else + 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" +} + + +mv_conffile /etc/apache2/conf.d/$PKG.conf \ + /etc/apache2/conf-available/$PKG.conf - # Something is broken. - cp_echo "CN: Your Apache2 configuration is broken." - cp_echo "CN: Please, check the service after the installation finishes!" +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 /dev/null - cp_echo "" - cp_echo "CN: Webalizer URL is http://`hostname -f`/stats/" - cp_echo "CN: User: admin" - cp_echo "CN: Password: $passwd" +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: Use \"htpasswd -m $WHTPASSWD admin\" to change it." + 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" 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!" +fi # Mail root. #