Debian Codegraph @

debian/postinst

raw
1 #! /bin/bash
2 # postinst script for isoqlog
3 # Murat Demirten <[email protected]>
4
5 set -e
6 # Use debconf.
7 . /usr/share/debconf/confmodule
8
9 case "$1" in
10 configure)
11
12 db_get isoqlog/main_logtype && logtype="$RET"
13 db_get isoqlog/main_outputdir && outputdir="$RET"
14 db_get isoqlog/main_hostname && hostname="$RET"
15 db_get isoqlog/main_langfile && langfile=$(echo "$RET" | LC_ALL=C tr 'A-Z' 'a-z')
16 db_get isoqlog/main_domains && domains="$RET"
17
18 if [ "$logtype" = "sendmail" ]; then
19 logstore="/var/log/mail/mail.log"
20 elif [ "$logtype" = "exim" ]; then
21 logstore="/var/log/exim4/mainlog"
22 else
23 logstore="/var/log/mail.log"
24 fi
25 # Now build isoqlog.conf
26
27 TMPFILE=`mktemp /tmp/isoqlog.conf-XXXXXX` || exit 1
28 echo "#isoqlog 2.0 Configuration file" >> $TMPFILE 2>&1
29 echo "" >> $TMPFILE 2>&1
30 echo "logtype = \"$logtype\"" >> $TMPFILE 2>&1
31 echo "logstore = \"$logstore\"" >> $TMPFILE 2>&1
32 echo "domainsfile = \"/etc/isoqlog/isoqlog.domains\"" >> $TMPFILE 2>&1
33 echo "outputdir = \"$outputdir\"" >> $TMPFILE 2>&1
34 echo "htmldir = \"/usr/share/isoqlog/htmltemp\"" >> $TMPFILE 2>&1
35 echo "langfile = \"/usr/share/isoqlog/lang/$langfile\"" >> $TMPFILE 2>&1
36 echo "hostname = \"$hostname\"" >> $TMPFILE 2>&1
37 echo "" >> $TMPFILE 2>&1
38 echo "maxsender = 100" >> $TMPFILE 2>&1
39 echo "maxreceiver = 100" >> $TMPFILE 2>&1
40 echo "maxtotal = 100" >> $TMPFILE 2>&1
41 echo "" >> $TMPFILE 2>&1
42 echo "maxbyte = 100" >> $TMPFILE 2>&1
43
44 mv -f $TMPFILE /etc/isoqlog/isoqlog.conf > /dev/null 2>&1
45
46 TMPFILE=`mktemp /tmp/isoqlog.domains-XXXXXX` || exit 1
47 for i in $domains; do
48 echo "$i" >> $TMPFILE 2>&1
49 done
50
51 mv -f $TMPFILE /etc/isoqlog/isoqlog.domains > /dev/null 2>&1
52
53 ## Set cron job
54 FILE="/etc/cron.daily/isoqlog"
55 echo "#!/bin/sh" > $FILE 2>&1
56 echo "# /etc/cron.daily/isoqlog: isoqlog report script" >> $FILE 2>&1
57 echo "" >> $FILE 2>&1
58 echo "/usr/bin/isoqlog > /dev/null 2>&1" >> $FILE 2>&1
59 ## Fix the permissions
60 chmod 755 $FILE
61
62 ## Copy images and library dirs into output dir
63 if ! [ -d $outputdir ]; then
64 mkdir -p $outputdir
65 fi
66 if ! [ -d $outputdir/images ]; then
67 cp -rf /usr/share/isoqlog/htmltemp/images $outputdir/
68 fi
69 if ! [ -d $outputdir/library ]; then
70 cp -rf /usr/share/isoqlog/htmltemp/library $outputdir/
71 fi
72 chmod 755 $outputdir
73 chmod 755 $outputdir/images
74 chmod 755 $outputdir/library
75
76 exit 0
77 ;;
78
79 abort-upgrade|abort-remove|abort-deconfigure)
80
81 ;;
82
83 *)
84 echo "postinst called with unknown argument \`$1'" >&2
85 exit 1
86 ;;
87 esac
88
89 # dh_installdeb will replace this with shell code automatically
90 # generated by other debhelper scripts.
91
92 #DEBHELPER#
93
94 exit 0
95
96