[package] lsm: update to 0.131
[openwrt/svn-archive/archive.git] / net / lsm / files / lsm_script
1 #!/bin/sh
2 #
3 # (C) 2009 Mika Ilmaranta <ilmis@nullnet.fi>
4 # (C) 2009 Tom Eastep <teastep@shorewall.net>
5 #
6 # License: GPLv2
7 #
8
9 DATE=$(/bin/date)
10
11 STATE=${1}
12 NAME=${2}
13 CHECKIP=${3}
14 DEVICE=${4}
15 WARN_EMAIL=${5}
16 REPLIED=${6}
17 WAITING=${7}
18 TIMEOUT=${8}
19 REPLY_LATE=${9}
20 CONS_RCVD=${10}
21 CONS_WAIT=${11}
22 CONS_MISS=${12}
23 AVG_RTT=${13}
24
25 if [ -f /usr/share/shorewall-lite/lib.base ]; then
26 VARDIR=/etc/shorewall-lite/state
27 STATEDIR=/etc/shorewall-lite
28 else
29 VARDIR=/var/lib/shorewall
30 STATEDIR=/etc/shorewall
31 fi
32
33 [ -f ${STATEDIR}/vardir ] && . ${STATEDIR}/vardir
34
35 cat <<EOM | ssmtp ${WARN_EMAIL}
36 Subject: "LSM: ${NAME} ${STATE}, DEV ${DEVICE}"
37
38 Hi,
39
40 Your connection ${NAME} has changed it's state to ${STATE} at ${DATE}.
41
42 Following parameters were passed:
43
44 newstate = ${STATE}
45 name = ${NAME}
46 checkip = ${CHECKIP}
47 device = ${DEVICE}
48 warn_email = ${WARN_EMAIL}
49
50 Packet counters:
51
52 replied = ${REPLIED} packets replied
53 waiting = ${WAITING} packets waiting for reply
54 timeout = ${TIMEOUT} packets that have timed out (= packet loss)
55 reply_late = ${REPLY_LATE} packets that received a reply after timeout
56 cons_rcvd = ${CONS_RCVD} consecutively received replies in sequence
57 cons_wait = ${CONS_WAIT} consecutive packets waiting for reply
58 cons_miss = ${CONS_MISS} consecutive packets that have timed out
59 avg_rtt = ${AVG_RTT} average rtt, notice that waiting and timed out packets have rtt = 0 when calculating this
60
61 Your LSM Daemon
62
63 EOM
64
65 if [ ${STATE} = up ]; then
66 echo 0 > ${VARDIR}/${DEVICE}.status # Uncomment this line if you are running Shorewall 4.4.x or earlier
67 ${VARDIR}/firewall enable ${DEVICE}
68 else
69 echo 1 > ${VARDIR}/${DEVICE}.status # Uncomment this line if you are running Shorewall 4.4.x or earlier
70 ${VARDIR}/firewall disable ${DEVICE}
71 fi
72
73 /sbin/shorewall-lite show routing > /var/log/lsm
74
75 exit 0
76
77 #EOF