[package] firewall:
[openwrt/svn-archive/archive.git] / package / firewall / files / firewall.hotplug
1 #!/bin/sh
2 # This script is executed as part of the hotplug event with
3 # HOTPLUG_TYPE=iface, triggered by various scripts when an interface
4 # is configured (ACTION=ifup) or deconfigured (ACTION=ifdown). The
5 # interface is available as INTERFACE, the real device as DEVICE.
6 . /etc/functions.sh
7
8 [ "$DEVICE" == "lo" ] && exit 0
9
10 . /lib/firewall/core.sh
11 fw_init
12
13 # Wait for firewall if startup is in progress
14 lock -w /var/lock/firewall.start
15
16 case "$ACTION" in
17 ifup)
18 fw_is_loaded && {
19 fw_configure_interface "$INTERFACE" add "$DEVICE" &
20 } || {
21 /etc/init.d/firewall enabled && fw_start &
22 }
23 ;;
24 ifdown)
25 fw_is_loaded && fw_configure_interface "$INTERFACE" del "$DEVICE" &
26 ;;
27 esac
28