File: fwlogwatch.postinst

package info (click to toggle)
fwlogwatch 1.4-3
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 996 kB
  • sloc: ansic: 5,288; lex: 1,747; php: 706; sh: 437; makefile: 160
file content (95 lines) | stat: -rw-r--r-- 2,896 bytes parent folder | download | duplicates (10)
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
#! /bin/sh
# Copyright 2001 Alberto Gonzalez Iniesta <agi@agi.as>
# Licensed under the GNU General Public License, version 2.  See the file
# /usr/share/common-licenses/GPL or <http://www.gnu.org/copyleft/gpl.txt>.
# 
set -e
test $DEBIAN_SCRIPT_DEBUG && set -v -x
CONF_FILE='/etc/default/fwlogwatch'

# use debconf
. /usr/share/debconf/confmodule

case "$1" in
  configure)

    db_get fwlogwatch/buildconfig || RET="true"
    if [ "$RET" = "false" ]; then
      echo "Not rebuilding '$CONF_FILE', since it contains unknown values."
      echo "If you want to rebuild it with debconf, delete it and run: dpkg-reconfigure fwlogwatch"
    else
    cat > "$CONF_FILE" <<EOF
#
# Debian's configuration for fwlogwatch
# The best way to edit this file is running 'dpkg-reconfigure fwlogwatch'
#
EOF
    db_get fwlogwatch/realtime || RET="false"
    ## If realtime is selected
    if [ "$RET" = "true" ]; then
      echo "START_DAEMON='true'" >> "$CONF_FILE"
      db_get fwlogwatch/respond || RET="false"
      # Respond active, using iptables
      if [ "$RET" = "yes (iptables)" ]; then
        PARAM1="-B"
        MODE="iptables"
      # Respond active, using ipchains
      elif [ "$RET" = "yes (ipchains)" ]; then
        PARAM1="-B"
        MODE="ipchains"
      # Respond active, using custom script
      elif [ "$RET" = "yes (other)" ]; then
        PARAM1="-B"
        MODE="other"
      # Respond NOT active
      else
        PARAM1=""
        MODE=""
      fi
      db_get fwlogwatch/notify || RET="false"
      # Notify active, send email (if there's no email address, do not notify)
      if [ "$RET" = "yes (mail)" ]; then
        db_get fwlogwatch/email || RET=""
        if [ "$RET" != "" ]; then
          PARAM2="-A"
          EMAIL="$RET"
        else
          PARAM2=""
          EMAIL=""
        fi
      # Notify active, other action (debconf warned to edit 'fwlw_notify')
      elif [ "$RET" = "yes (other)" ]; then
          PARAM2="-A"
          EMAIL=""
      # Notify NOT active
      else
          PARAM2=""
          EMAIL=""
      fi
      echo "PARAMS='$PARAM2 $PARAM1'" >> "$CONF_FILE"
      echo "MODE='$MODE'" >> "$CONF_FILE"
      echo "EMAIL='$EMAIL'" >> "$CONF_FILE"
    ## If realtime is NOT selected
    else
      echo "START_DAEMON='false'" >> "$CONF_FILE"
      echo "PARAMS=''" >> "$CONF_FILE"
      echo "MODE=''" >> "$CONF_FILE"
      echo "EMAIL=''" >> "$CONF_FILE"
    fi
    db_get fwlogwatch/cron_email || RET="none"
    # 'none' will avoid sending daily stats
    echo "CRON_EMAIL='$RET'" >> "$CONF_FILE"
    if [ "$RET" != "none" ]; then
      db_get fwlogwatch/cron_parameters || RET="-p -d -O ta -t -e -l 1d"
      echo "CRON_PARAMS='$RET'" >> "$CONF_FILE"
    fi
    fi
    # Needs to be here because it seems something doesn't close all of its filedescriptors nicely
    db_stop
  ;;
esac

#DEBHELPER#

exit 0
# vim:set ai et sts=2 sw=2 tw=0: