| 1 |
#! /bin/sh |
| 2 |
# Copyright 2001 Alberto Gonzalez Iniesta <[email protected]> |
| 3 |
# Licensed under the GNU General Public License, version 2. See the file |
| 4 |
# /usr/share/common-licenses/GPL or <http://www.gnu.org/copyleft/gpl.txt>. |
| 5 |
# |
| 6 |
set -e |
| 7 |
test $DEBIAN_SCRIPT_DEBUG && set -v -x |
| 8 |
CONF_FILE='/etc/default/fwlogwatch' |
| 9 |
|
| 10 |
# use debconf |
| 11 |
. /usr/share/debconf/confmodule |
| 12 |
|
| 13 |
case "$1" in |
| 14 |
configure) |
| 15 |
|
| 16 |
db_get fwlogwatch/buildconfig || RET="true" |
| 17 |
if [ "$RET" = "false" ]; then |
| 18 |
echo "Not rebuilding '$CONF_FILE', since it contains unknown values." |
| 19 |
echo "If you want to rebuild it with debconf, delete it and run: dpkg-reconfigure fwlogwatch" |
| 20 |
else |
| 21 |
cat > "$CONF_FILE" <<EOF |
| 22 |
# |
| 23 |
# Debian's configuration for fwlogwatch |
| 24 |
# The best way to edit this file is running 'dpkg-reconfigure fwlogwatch' |
| 25 |
# |
| 26 |
EOF |
| 27 |
db_get fwlogwatch/realtime || RET="false" |
| 28 |
## If realtime is selected |
| 29 |
if [ "$RET" = "true" ]; then |
| 30 |
echo "START_DAEMON='true'" >> "$CONF_FILE" |
| 31 |
db_get fwlogwatch/respond || RET="false" |
| 32 |
# Respond active, using iptables |
| 33 |
if [ "$RET" = "yes (iptables)" ]; then |
| 34 |
PARAM1="-B" |
| 35 |
MODE="iptables" |
| 36 |
# Respond active, using ipchains |
| 37 |
elif [ "$RET" = "yes (ipchains)" ]; then |
| 38 |
PARAM1="-B" |
| 39 |
MODE="ipchains" |
| 40 |
# Respond active, using custom script |
| 41 |
elif [ "$RET" = "yes (other)" ]; then |
| 42 |
PARAM1="-B" |
| 43 |
MODE="other" |
| 44 |
# Respond NOT active |
| 45 |
else |
| 46 |
PARAM1="" |
| 47 |
MODE="" |
| 48 |
fi |
| 49 |
db_get fwlogwatch/notify || RET="false" |
| 50 |
# Notify active, send email (if there's no email address, do not notify) |
| 51 |
if [ "$RET" = "yes (mail)" ]; then |
| 52 |
db_get fwlogwatch/email || RET="" |
| 53 |
if [ "$RET" != "" ]; then |
| 54 |
PARAM2="-A" |
| 55 |
EMAIL="$RET" |
| 56 |
else |
| 57 |
PARAM2="" |
| 58 |
EMAIL="" |
| 59 |
fi |
| 60 |
# Notify active, other action (debconf warned to edit 'fwlw_notify') |
| 61 |
elif [ "$RET" = "yes (other)" ]; then |
| 62 |
PARAM2="-A" |
| 63 |
EMAIL="" |
| 64 |
# Notify NOT active |
| 65 |
else |
| 66 |
PARAM2="" |
| 67 |
EMAIL="" |
| 68 |
fi |
| 69 |
echo "PARAMS='$PARAM2 $PARAM1'" >> "$CONF_FILE" |
| 70 |
echo "MODE='$MODE'" >> "$CONF_FILE" |
| 71 |
echo "EMAIL='$EMAIL'" >> "$CONF_FILE" |
| 72 |
## If realtime is NOT selected |
| 73 |
else |
| 74 |
echo "START_DAEMON='false'" >> "$CONF_FILE" |
| 75 |
echo "PARAMS=''" >> "$CONF_FILE" |
| 76 |
echo "MODE=''" >> "$CONF_FILE" |
| 77 |
echo "EMAIL=''" >> "$CONF_FILE" |
| 78 |
fi |
| 79 |
db_get fwlogwatch/cron_email || RET="none" |
| 80 |
# 'none' will avoid sending daily stats |
| 81 |
echo "CRON_EMAIL='$RET'" >> "$CONF_FILE" |
| 82 |
if [ "$RET" != "none" ]; then |
| 83 |
db_get fwlogwatch/cron_parameters || RET="-p -d -O ta -t -e -l 1d" |
| 84 |
echo "CRON_PARAMS='$RET'" >> "$CONF_FILE" |
| 85 |
fi |
| 86 |
fi |
| 87 |
# Needs to be here because it seems something doesn't close all of its filedescriptors nicely |
| 88 |
db_stop |
| 89 |
;; |
| 90 |
esac |
| 91 |
|
| 92 |
#DEBHELPER# |
| 93 |
|
| 94 |
exit 0 |
| 95 |
# vim:set ai et sts=2 sw=2 tw=0: |