1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
#!/bin/sh -e
action=$1
version=$2
set -e
# Source debconf library.
. /usr/share/debconf/confmodule
if [ -n "$version" ] && dpkg --compare-versions "$version" lt 0.4.13-2
then
db_get trafstats/user || true
db_set trafstats/writer "$RET" || true
db_unregister trafstats/user || true
fi
db_capb backup || true
db_version 2.0 || true
if [ -a /etc/trafstats/mail.conf ] ; then
. /etc/trafstats/mail.conf
db_set trafstats/recipients "${RECIPIENTS}" || true
fi
STATE=1
while [ "$STATE" != 0 -a "$STATE" != 9 ]
do
case $STATE in
1)
db_beginblock || true
db_input high trafstats/overwrite || true
db_input high trafstats/erasecffile || true
db_input high trafstats/startonboot || true
db_endblock || true
;;
2)
DEVICES=`tail +3 /proc/net/dev | cut -d : -f 1`
DEVICES=`echo $DEVICES | sed -e "s/ /, /g"`
db_subst trafstats/interface devices $DEVICES, any || true
db_input critical trafstats/interface || true
;;
3)
db_beginblock || true
db_input medium trafstats/storage-delay || true
db_input medium trafstats/timestamp-delay || true
db_endblock || true
;;
4)
db_get trafstats/storage-delay || true
SDELAY=$RET
db_get trafstats/timestamp-delay || true
TDELAY=$RET
if [ $SDELAY -lt $TDELAY ]
then
db_subst trafstats/timestore-warn sdelay "$SDELAY" || true
db_subst trafstats/timestore-warn tdelay "$TDELAY" || true
db_text trafstats/timestore-warn || true
fi
;;
5)
db_beginblock || true
db_input medium trafstats/dbname || true
db_input medium trafstats/reader || true
db_input medium trafstats/writer || true
db_endblock || true
;;
6)
db_beginblock || true
db_input medium trafstats/castrate || true
db_input medium trafstats/nodaemon || true
db_input medium trafstats/verbosity || true
db_endblock || true
;;
7)
db_get trafstats/verbosity || true
if [ "$RET" = "insane" ]
then
db_input critical trafstats/areyoucrazy || true
fi
;;
8)
db_input critical trafstats/recipients || true
;;
esac
db_go || true
# if db_go; then
STATE=$(($STATE + 1))
# else
# STATE=$(($STATE - 1))
# fi
done
db_stop || true
exit 0
|