#! /bin/bash # postinst script for isoqlog # Murat Demirten set -e # Use debconf. . /usr/share/debconf/confmodule case "$1" in configure) db_get isoqlog/main_logtype && logtype="$RET" db_get isoqlog/main_outputdir && outputdir="$RET" db_get isoqlog/main_hostname && hostname="$RET" db_get isoqlog/main_langfile && langfile=$(echo "$RET" | LC_ALL=C tr 'A-Z' 'a-z') db_get isoqlog/main_domains && domains="$RET" if [ "$logtype" = "sendmail" ]; then logstore="/var/log/mail/mail.log" elif [ "$logtype" = "exim" ]; then logstore="/var/log/exim4/mainlog" else logstore="/var/log/mail.log" fi # Now build isoqlog.conf TMPFILE=`mktemp /tmp/isoqlog.conf-XXXXXX` || exit 1 echo "#isoqlog 2.0 Configuration file" >> $TMPFILE 2>&1 echo "" >> $TMPFILE 2>&1 echo "logtype = \"$logtype\"" >> $TMPFILE 2>&1 echo "logstore = \"$logstore\"" >> $TMPFILE 2>&1 echo "domainsfile = \"/etc/isoqlog/isoqlog.domains\"" >> $TMPFILE 2>&1 echo "outputdir = \"$outputdir\"" >> $TMPFILE 2>&1 echo "htmldir = \"/usr/share/isoqlog/htmltemp\"" >> $TMPFILE 2>&1 echo "langfile = \"/usr/share/isoqlog/lang/$langfile\"" >> $TMPFILE 2>&1 echo "hostname = \"$hostname\"" >> $TMPFILE 2>&1 echo "" >> $TMPFILE 2>&1 echo "maxsender = 100" >> $TMPFILE 2>&1 echo "maxreceiver = 100" >> $TMPFILE 2>&1 echo "maxtotal = 100" >> $TMPFILE 2>&1 echo "" >> $TMPFILE 2>&1 echo "maxbyte = 100" >> $TMPFILE 2>&1 mv -f $TMPFILE /etc/isoqlog/isoqlog.conf > /dev/null 2>&1 TMPFILE=`mktemp /tmp/isoqlog.domains-XXXXXX` || exit 1 for i in $domains; do echo "$i" >> $TMPFILE 2>&1 done mv -f $TMPFILE /etc/isoqlog/isoqlog.domains > /dev/null 2>&1 ## Set cron job FILE="/etc/cron.daily/isoqlog" echo "#!/bin/sh" > $FILE 2>&1 echo "# /etc/cron.daily/isoqlog: isoqlog report script" >> $FILE 2>&1 echo "" >> $FILE 2>&1 echo "/usr/bin/isoqlog > /dev/null 2>&1" >> $FILE 2>&1 ## Fix the permissions chmod 755 $FILE ## Copy images and library dirs into output dir if ! [ -d $outputdir ]; then mkdir -p $outputdir fi if ! [ -d $outputdir/images ]; then cp -rf /usr/share/isoqlog/htmltemp/images $outputdir/ fi if ! [ -d $outputdir/library ]; then cp -rf /usr/share/isoqlog/htmltemp/library $outputdir/ fi chmod 755 $outputdir chmod 755 $outputdir/images chmod 755 $outputdir/library exit 0 ;; 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