. /lib/firewall/core.sh
fw_init
-fw_is_loaded || exit 0
+
+# Wait for firewall if startup is in progress
+lock -w /var/lock/firewall.start
case "$ACTION" in
ifup)
- fw_configure_interface "$INTERFACE" add "$DEVICE" ;;
+ fw_is_loaded && {
+ fw_configure_interface "$INTERFACE" add "$DEVICE" &
+ } || {
+ /etc/init.d/firewall enabled && fw_start &
+ }
+ ;;
ifdown)
- fw_configure_interface "$INTERFACE" del "$DEVICE" ;;
+ fw_is_loaded && fw_configure_interface "$INTERFACE" del "$DEVICE" &
+ ;;
esac
+
fw_start() {
fw_init
+ lock /var/lock/firewall.start
+
FW_DEFAULTS_APPLIED=
fw_is_loaded && {
fw_callback post core
uci_set_state firewall core loaded 1
+
+ lock -u /var/lock/firewall.start
}
fw_stop() {
}
fw_is_loaded() {
- local bool
- config_get_bool bool core loaded 0
- return $((! $bool))
+ local bool=$(uci -q -P /var/state get firewall.core.loaded)
+ return $((! ${bool:-0}))
}