COLOUR_STP_LEARNING=${COLOUR_YELLOW}
COLOUR_STP_BLOCKING=${COLOUR_YELLOW}
+COLOUR_VARIABLES="COLOUR_GREEN COLOUR_RED COLOUR_NORMAL COLOUR_YELLOW"
+COLOUR_VARIABLES="${COLOUR_VARIABLES} COLOUR_BOLD COLOUR_DOWN COLOUR_ERROR"
+COLOUR_VARIABLES="${COLOUR_VARIABLES} COLOUR_ERROR COLOUR_OK COLOUR_UP"
+COLOUR_VARIABLES="${COLOUR_VARIABLES} COLOUR_WARM COLOUR_ENABLED COLOUR_DISABLED"
+COLOUR_VARIABLES="${COLOUR_VARIABLES} COLOUR_LOG COLOUR_STP_FORWARDING"
+COLOUR_VARIABLES="${COLOUR_VARIABLES} COLOUR_STP_DISCARDING COLOUR_STP_LEARNING"
+COLOUR_VARIABLES="${COLOUR_VARIABLES} COLOUR_STP_BLOCKING"
+
function colours_disable() {
local line
- for line in $(set | grep "^COLOUR_"); do
- unset ${line%%=*}
+ for line in ${COLOUR_VARIABLES}; do
+ unset ${line}
done
}
done
}
+function zone_has_port() {
+ # Check, if the given port is configured
+ # in this zone.
+
+ local zone=${1}
+ local port=${2}
+ shift 2
+
+ assert isset zone
+ assert isset port
+
+ [ -e "$(zone_dir ${zone})/ports/${port}" ]
+}
+
# XXX overwritten some lines below
function zone_config() {
local zone=${1}
esac
}
+function zone_config_option() {
+ local zone=${1}
+ local option=${2}
+ local default=${3}
+ shift 2
+
+ assert isset zone
+ assert isset option
+
+ (
+ VALUE="${default}"
+ zone_config_read ${zone}
+
+ VALUE="${!option}"
+ echo "${VALUE}"
+ )
+}
+
function zone_config_create() {
local zone=${1}
shift
--- /dev/null
+#!/bin/bash
+###############################################################################
+# #
+# IPFire.org - A linux based firewall #
+# Copyright (C) 2011 Michael Tremer & Christian Schmidt #
+# #
+# This program is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+# #
+###############################################################################
+
+. /lib/network/functions
+
+# Do nothing, if the network isn't running.
+# That happens for example on boot time.
+if ! network_is_running; then
+ exit 0
+fi
+
+# Check if the udev environment variables are properly set.
+assert isset ACTION
+assert isset INTERFACE
+
+# Check, if the device is a physical network interface and
+# if we can handle it.
+if ! device_is_real ${INTERFACE}; then
+ exit ${EXIT_OK}
+fi
+
+# Check, if there is a configuration for that device.
+if port_exists ${INTERFACE}; then
+ port=${INTERFACE}
+
+else
+ # If the given device was not configured,
+ # we create an initial configuration.
+ port_create ethernet ${INTERFACE}
+ exit ${EXIT_OK}
+fi
+
+case "${ACTION}" in
+ add|register)
+ zone=$(port_zone ${port})
+
+ # Check, if the device is configured in a zone.
+ # If not, there is nothing to do.
+ isset zone || exit ${EXIT_OK}
+
+ boot=$(zone_config_option ${zone} BOOT)
+ if enabled boot; then
+ zone_up ${zone}
+ fi
+ ;;
+
+ remove|unregister)
+ port_down ${port}
+ ;;
+esac
+
+exit ${EXIT_OK}