summaryrefslogtreecommitdiffstats
path: root/package/firewall/files/firewall.hotplug
blob: bc75e42d1d3fd1b36c10d0b6f63330c82e213545 (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
#!/bin/sh
# This script is executed as part of the hotplug event with
# HOTPLUG_TYPE=iface, triggered by various scripts when an interface
# is configured (ACTION=ifup) or deconfigured (ACTION=ifdown).  The
# interface is available as INTERFACE, the real device as DEVICE.
. /etc/functions.sh

[ "$DEVICE" == "lo" ] && exit 0

. /lib/firewall/core.sh
fw_init

# Wait for firewall if startup is in progress
lock -w /var/lock/firewall.start

case "$ACTION" in
	ifup)
		fw_is_loaded && {
			fw_configure_interface "$INTERFACE" add "$DEVICE" &
		} || {
			/etc/init.d/firewall enabled && fw_start &
		}
	;;
	ifdown)
		fw_is_loaded && fw_configure_interface "$INTERFACE" del "$DEVICE" &
	;;
esac