aboutsummaryrefslogtreecommitdiff
path: root/share/provision/files/ipredator/usr/local/bin/fermreload.sh
blob: cebf7cc806ae119c4becadcc6bc584136df78644 (plain)
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
#!/bin/bash
#
# fermreload.sh
# V: 0.1
#
# Reloads the ferm firewall ruleset and is invoked by
# the udev via /etc/udev/rules.d/81-vpn-firewall.rules.
#
# IPredator 2014
# Released under the Kopimi license.
#
# Blog post:   https://blog.ipredator.se/linux-firewall-howto.html
#

LOGGER=/usr/bin/logger
LOGGER_TAG=$0

UDEV_ACTION=$1

FERM=/usr/sbin/ferm
FERM_CONF=/etc/ferm/ferm.conf

MSG_FW_RULE_ADD="Adding VPN firewall rules."
MSG_FW_RULE_REMOVE="Removing VPN firewall rules."
MSG_UDEV_ACTION_UNKNOWN="Unknown udev action."

case "$UDEV_ACTION" in
    add)
        $LOGGER -t $LOGGER_TAG $MSG_FW_RULE_ADD
        $FERM $FERM_CONF
        ;;
    remove)
        $LOGGER -t $LOGGER_TAG $MSG_FW_RULE_REMOVE
        $FERM $FERM_CONF
        ;;
    *)
        $LOGGER -t $LOGGER_TAG $MSG_UDEV_ACTION_UNKNOWN
        exit 1
esac