File: wflogs_email

package info (click to toggle)
wflogs 0.9.8-4
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 4,220 kB
  • ctags: 3,750
  • sloc: ansic: 12,166; sh: 8,047; cpp: 6,412; lex: 1,525; yacc: 1,430; makefile: 731; sed: 16
file content (66 lines) | stat: -rw-r--r-- 1,613 bytes parent folder | download | duplicates (3)
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
#!/bin/sh -e

# This script sends an email containing a firewall activity report during
# the last day.
# I choose to have an output type which is text, maybe I can add human, but I
# don't think that it would be a good idea to add something else.

#This script was written by Jean-Michel Kelbert <kelbert@debian.org>, for
#the Debian project (but  may  be used by others).

export LC_ALL="C"

WFLOGS=/usr/bin/wflogs
CONFIG=/etc/default/wflogs

test -x $WFLOGS || exit 0
test -r $CONFIG || exit 0

. $CONFIG

test -r $INPUT_FILE || exit 0

test "$EMAIL_SEND" = "true" || exit 0

if [ -z "$INPUT_TYPE" ]; then
  INPUT_TYPE="netfilter"
fi

INPUT_TYPE=`echo $INPUT_TYPE | tr -d " "`

# wflogs options.
case "$EMAIL_SORT" in
 "Yes default order")
  OPTIONS="--sort"
  ;;
 "Yes custom order")
  OPTIONS="--sort=$EMAIL_SORT_OPTIONS"
  ;;
esac

case "$EMAIL_OUTPUT_WHOIS" in
 "no whois lookups")
  EMAIL_OUTPUT_WHOIS=0
  ;;
 "always do whois lookups")
  EMAIL_OUTPUT_WHOIS=1
  ;;
 "do whois lookups only if no DNS name could be found")
  EMAIL_OUTPUT_WHOIS=2
  ;;
esac

OPTIONS="$OPTIONS --strict-parsing=loose \
-i $INPUT_TYPE -o text --duration=$EMAIL_OUTPUT_DURATION \
--summary=$EMAIL_OUTPUT_SUMMARY --whois_lookup=$EMAIL_OUTPUT_WHOIS \
--src_mac=$EMAIL_OUTPUT_MAC --dst_mac=$EMAIL_OUTPUT_MAC \
--mac_vendor=$EMAIL_OUTPUT_MAC_VENDOR"

if [ "$EMAIL_OBFUSCATE" != "nothing" ]; then
  OPTIONS="--obfuscate=$EMAIL_OBFUSCATE $OPTIONS"
fi

FILTER="\$start_time >= [yesterday]"

# Send the mail.
eval "$WFLOGS -f '$FILTER' $OPTIONS -- $INPUT_FILE | mail $EMAIL_ADDRESS -s 'Wflogs report since `date +"%D" -d "yesterday"`'"