HEX
Server: Apache/2.4.62 (Debian)
System: Linux MIA-VPS-VM01781 5.10.0-32-amd64 #1 SMP Debian 5.10.223-1 (2024-08-10) x86_64
User: webmaster (1001)
PHP: 8.2.29
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/lib/dpkg/info/webalizer.postinst
#!/bin/sh
# postinst script for webalizer
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <postinst> `configure' <most-recently-configured-version>
#        * <old-postinst> `abort-upgrade' <new version>
#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
#          <new-version>
#        * <postinst> `abort-remove'
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#          <failed-install-package> <version> `removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
#

# bogus - though necessary - rule
. /usr/share/debconf/confmodule
db_version 2.0

case "$1" in
    configure)
      conffile="/etc/webalizer/webalizer.conf"
      db_get webalizer/create_conf || true
      CREATE_CONF="$RET"
      if [ "$CREATE_CONF" = "true" ]; then
        db_get webalizer/directory || true
        OUTPUTDIR="$RET"
        if [ -z "$OUTPUTDIR" ]; then
          echo "Fatal: No ouptut dir given, not creating webalizer configuration" >&2
          exit 1;
        else
          if [ ! -d $OUTPUTDIR ]; then
            if mkdir -p $OUTPUTDIR; then
              echo "$OUTPUTDIR created" >&2
            else
              echo "Something went wrong..." >&2
              exit 1;
            fi;
          fi
        fi

        db_get webalizer/doc_title || true
        REPORTTITLE="$RET";

        db_get webalizer/logfile || true
        LOGFILE="$RET";

        db_get webalizer/dnscache || true
        DNSCACHE="$RET";

        # create conffile if it doesn't exist yet
        template="/etc/webalizer/webalizer.conf.sample"
        if [ ! -f $conffile ]; then
          cat $template > $conffile
          WEBHOSTNAME=$(hostname)
          # uncomment the debconf-handled items
          sed -i \
            -e "s/^#HostName[ \t].*/HostName ${WEBHOSTNAME}/" \
            -e "s/^#OutputDir[ \t]/OutputDir /" \
            -e "s/^#ReportTitle[ \t]/ReportTitle /" \
            -e "s/^#LogFile[ \t]/LogFile /" \
            $conffile
        fi
        
        # Finally put these variables in /etc/webalizer/webalizer.conf using sed
        sed -i \
          -e "s|^OutputDir[ \t].*|OutputDir ${OUTPUTDIR}|" \
          -e "s/^ReportTitle[ \t].*/ReportTitle ${REPORTTITLE}/" \
          -e "s|^LogFile[ \t].*|LogFile ${LOGFILE}|" \
          $conffile

        # Enable DNSCache Option
        if [ "$DNSCACHE" = "true" ]; then
          sed -i \
            -e "s/^#DNSCache[ \t]/DNSCache /" \
            -e "s/^#DNSChildren[ \t].*/DNSChildren 10/" \
            $conffile
        else
          sed -i \
            -e "s/^DNSCache[ \t]/#DNSCache /" \
            -e "s/^DNSChildren[ \t]/#DNSChildren /" \
            $conffile
        fi
      else
        rm -f $conffile
      fi
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)

    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.



exit 0