Don't expect that this works, but I wanted to commit it.
### END INIT INFO
. /lib/lsb/init-functions
-. /etc/sysconfig/network
+. /etc/init.d/networking/functions
case "${1}" in
start)
# Start all network interfaces
- for file in $(find ${NETWORK_DEVICES} -maxdepth 1); do
- interface=${file##*/}
-
- if [ -d "${file}" ] || [ -n "${interface}" ]; then
- continue
- fi
-
- IN_BOOT=1 ${NETWORK_SCRIPTS}/brup ${interface}
+ for zone in $(find ${CONFIG_ZONES}/ -maxdepth 1); do
+ [ -d "${zone}" ] || continue
+ IN_BOOT=1 /etc/init.d/networking/zone ${zone##*/} up
done
touch /var/lock/subsys/network
;;
stop)
- # Reverse list
- FILES=""
- for file in $(find ${NETWORK_DEVICES} -maxdepth 1); do
- interface=${file##*/}
-
- if [ -d "${file}" ] || [ -n "${interface}" ]; then
- continue
- fi
- FILES="${file} ${FILES}"
- done
-
# Stop all network interfaces
- for file in ${FILES}
- do
- interface=${file##*/}
-
- IN_BOOT=1 ${NETWORK_SCRIPTS}/brdown ${interface}
+ for zone in $(find ${CONFIG_ZONES}/ -maxdepth 1); do
+ [ -d "${zone}" ] || continue
+ IN_BOOT=1 /etc/init.d/networking/zone ${zone##*/} down
done
rm -f /var/lock/subsys/network
;;
+++ /dev/null
-#!/bin/sh
-########################################################################
-# Begin $NETWORK_DEVICES/brdown
-#
-# Description : Bridge Down
-#
-# Authors : Michael Tremer - michael.tremer@ipfire.org
-#
-# Version : 00.00
-#
-# Notes : This script removes the created bridge, removes
-# all child interface from it and then
-# the IFCONFIG variable is passed to the scripts found
-# in the services directory, to indicate what file the
-# service should source to get environmental variables.
-#
-########################################################################
-
-. /lib/lsb/init-functions
-
-message="Bringing down the ${1} interface..."
-
-# Collect a list of configuration files for our interface
-if [ -n "${2}" ]; then
- for file in ${@#$1} # All parameters except $1
- do
- FILES="${FILES} ${NETWORK_DEVICES}/${1}/${file}"
- done
-elif [ -d "${NETWORK_DEVICES}/${1}" ]; then
- FILES=`echo ${NETWORK_DEVICES}/${1}/*`
-else
- FILES="${NETWORK_DEVICES}/${1}"
-fi
-
-# Reverse the order configuration files are processed in
-for file in ${FILES}; do
- # skip backup files
- if [ "${file}" != "${file%""~""}" ]; then
- continue
- fi
-
- # place interfaces at last position
- if [[ "${file}" =~ "^[0-9a-f][0-9a-f]\:[0-9a-f][0-9a-f]\:[0-9a-f][0-9a-f]\:[0-9a-f][0-9a-f]\:[0-9a-f][0-9a-f]\:[0-9a-f][0-9a-f]$" ]]; then
- FILES2="${FILES2} ${file}"
- continue
- fi
-
- # append the rest
- FILES2="${file} ${FILES2}"
-done
-FILES=${FILES2}
-
-# Process each configuration file
-export BRIDGE_DOWN=1
-for file in ${FILES}; do
- if [ ! -f "${file}" ]; then
- log_warning_msg
- message="${file} is not a network configuration file or directory."
- log_warning_msg
- fi
- /etc/init.d/networking/ifdown ${file}
-done
-
-if [ -z "${2}" ]; then
- # Check if bridge already exists
- bridge_status=`brctl show 2>/dev/null`
- if echo "${bridge_status}" | grep -q "^${1}"; then
- # Create and bring up the bridge
- ip link set ${1} down || failed=1
- brctl delbr ${1} || failed=1
- (exit ${failed})
- evaluate_retval standard
- fi
-fi
-
-# End $NETWORK_DEVICES/brdown
+++ /dev/null
-#!/bin/sh
-########################################################################
-# Begin $NETWORK_DEVICES/brup
-#
-# Description : Bridge Up
-#
-# Authors : Michael Tremer - michael.tremer@ipfire.org
-#
-# Version : 00.00
-#
-# Notes : This script creates a bridge with a given name.
-# Then all required interfaces are added to the brige and
-# the IFCONFIG variable is passed to the scripts found
-# in the services directory, to indicate what file the
-# service should source to get environmental variables.
-#
-########################################################################
-
-. /lib/lsb/init-functions
-
-message="Bringing up ${1} interface..."
-
-# Collect a list of configuration files for our interface
-if [ -n "${2}" ]; then
- for file in ${@#$1} # All parameters except $1
- do
- FILES="${FILES} ${NETWORK_DEVICES}/${1}/${file}"
- done
-elif [ -d "${NETWORK_DEVICES}/${1}" ]; then
- FILES=`echo ${NETWORK_DEVICES}/${1}/*`
-else
- FILES="${NETWORK_DEVICES}/${1}"
-fi
-
-# Sort files
-for file in ${FILES}; do
- # skip backup files
- if [ "${file}" != "${file%""~""}" ]; then
- continue
- fi
-
- # place interfaces at first position
- if [[ "${file}" =~ "^[0-9a-f][0-9a-f]\:[0-9a-f][0-9a-f]\:[0-9a-f][0-9a-f]\:[0-9a-f][0-9a-f]\:[0-9a-f][0-9a-f]\:[0-9a-f][0-9a-f]$" ]]; then
- FILES2="${file} ${FILES2}"
- continue
- fi
-
- # append the rest
- FILES2="${FILES2} ${file}"
-done
-FILES=${FILES2}
-
-# Check if bridge already exists
-bridge_status=`brctl show 2>/dev/null`
-if ! echo "${bridge_status}" | grep -q "^${1}"; then
- # Create and bring up the bridge
- brctl addbr ${1} || failed=1
- ip link set ${1} up || failed=1
- (exit ${failed})
- evaluate_retval standard
-else
- log_warning_msg
- message="Bridge does already exist."
- log_warning_msg
-fi
-
-# Process each configuration file
-export BRIDGE_UP=1
-for file in ${FILES}; do
- if [ ! -f "${file}" ]; then
- log_warning_msg
- message="${file} is not a network configuration file or directory."
- log_warning_msg
- fi
- /etc/init.d/networking/ifup ${file}
-done
# #
###############################################################################
-[ -f "/etc/sysconfig/network" ] && . /etc/sysconfig/network
+CONFIG_DIR=/etc/sysconfig/networking
+
+CONFIG_ZONES=${CONFIG_DIR}/zones
+CONFIG_PORTS=${CONFIG_DIR}/ports
function is_mac() {
- egrep "^[0-9a-f][0-9a-f]\:[0-9a-f][0-9a-f]\:[0-9a-f][0-9a-f]\:[0-9a-f][0-9a-f]\:[0-9a-f][0-9a-f]\:[0-9a-f][0-9a-f]$" <<<$1
+ egrep -q "^[0-9a-f][0-9a-f]\:[0-9a-f][0-9a-f]\:[0-9a-f][0-9a-f]\:[0-9a-f][0-9a-f]\:[0-9a-f][0-9a-f]\:[0-9a-f][0-9a-f]$" <<<$1
}
function get_device_by_mac() {
- local mac=$1
+ local mac
+ local i
+
+ mac=$1
+
for i in /sys/class/net/*; do
if [ "$(cat $i/address)" = "$mac" ]; then
- echo $(basename $i)
+ grep -q "^${i##*/}" /proc/net/vlan/config 2>/dev/null && continue
+ echo ${i##*/}
+ break
fi
done
}
+function get_device_by_mac_and_vid() {
+ local mac
+ local vid
+
+ mac=$1
+ vid=$2
+
+ local i
+ local VID
+ local DEVICE
+ for i in $(cat /proc/net/vlan/config 2>/dev/null); do
+ awk -F'|' '{ print $2 $3 }' | read DEVICE VID PARENT
+ if [ -n "${VID}" ] || [ -n "${DEVICE}" ]; then
+ continue
+ fi
+ if [ "${vid}" = "${VID}" ] && [ "$(macify ${PARENT})" = "${mac}" ]; then
+ echo "${DEVICE}"
+ return 0
+ fi
+ done
+ return 1
+}
+
function get_mac_by_device() {
- local device=$1
+ local device
+ device=$1
if [ -d "/sys/class/net/$device" ]; then
cat /sys/class/net/$device/address
return 0
return 1
}
+function devicify() {
+ local device
+ local mac
+
+ device=$1
+
+ if is_mac ${device}; then
+ mac=${device}
+ device=$(get_device_by_mac ${device})
+ fi
+ echo ${device}
+}
+
+function macify() {
+ local input
+ local mac
+
+ input=$1
+
+ if is_mac ${input}; then
+ mac=${input}
+ else
+ mac=$(get_mac_by_device ${input})
+ fi
+ echo ${mac}
+}
+
function device_exists() {
- ip link show ${1} &>/dev/null
+ ip link show $(devicify ${1}) &>/dev/null
+}
+
+function rename_device() {
+ local source
+ local destination
+
+ source=$1
+ destination=$2
+
+ # Check if devices exist
+ if ! device_exists ${source} || device_exists ${destination}; then
+ return 4
+ fi
+
+ ip link set ${source} name ${destination}
+ return $?
}
function zone_exists() {
}
function bridge_devices() {
- : #TODO
+ local bridge
+ bridge=$1
+ [ -z "${bridge}" ] && return 2
+ brctl show | grep "^${bridge}" | awk '{ print $NF }' | grep -v "^interfaces$"
+}
+
+function zone_add_port() {
+ brctl addif ${1} ${2}
+}
+
+function all_zones() {
+ local zone
+ for zone in ${CONFIG_ZONES}/*; do
+ [ -d "${zone}" ] && echo ${zone}
+ done
}
########################################################################
. /lib/lsb/init-functions
-. ${IFCONFIG}
+[ -n "${CONFIG}" ] && . ${CONFIG}
interface=${IFCONFIG##*/}
########################################################################
. /lib/lsb/init-functions
-. ${CONFIG}
+. /etc/init.d/networking/functions
+[ -n "${CONFIG}" ] && . ${CONFIG}
+
+port=$(macify ${1})
case "${2}" in
up)
: # Do nothing
;;
+ add)
+ cat <<EOF > ${CONFIG_PORTS}/${port}/ethernet
+HOOK=ethernet
+EOF
+ ln -sf ${CONFIG_PORTS}/${port}/ethernet \
+ ${CONFIG_ZONES}/${ZONE}/port-${port}-ethernet
+ ;;
+
+ remove)
+ rm -f \
+ ${CONFIG_ZONES}/${ZONE}/port-${port}-ethernet \
+ ${CONFIG_PORTS}/${port}/ethernet
+ ;;
+
*)
- echo "Usage: ${0} [interface] {up|down}"
+ echo "Usage: ${0} [interface] {up|down|add|remove}"
exit 1
;;
esac
########################################################################
. /lib/lsb/init-functions
-. ${IFCONFIG}
+[ -n "${CONFIG}" ] && . ${CONFIG}
if [ -z "${IP}" ]; then
log_failure_msg "IP variable missing from ${IFCONFIG}, cannot continue."
########################################################################
. /lib/lsb/init-functions
-. ${IFCONFIG}
+[ -n "${CONFIG}" ] && . ${CONFIG}
case "${TYPE}" in
("" | "network")
########################################################################
. /lib/lsb/init-functions
-. ${IFCONFIG}
+[ -n "${CONFIG}" ] && . ${CONFIG}
case "${2}" in
up)
########################################################################
. /lib/lsb/init-functions
-. ${CONFIG}
+. /etc/init.d/networking/functions
+[ -n "${CONFIG}" ] && . ${CONFIG}
+
+port=$(macify ${1})
+device=$(devicify ${port})
case "${2}" in
up)
modprobe 8021q
- MESSAGE="Adding VLAN ${ID} to interface ${1}..."
- vconfig add ${1} ${ID} &>/dev/null
+ MESSAGE="Adding VLAN ${ID} to port ${port}..."
+ vconfig add ${device} ${ID} &>/dev/null
evaluate_retval
;;
down)
- MESSAGE="Removing VLAN ${ID} from interface ${1}..."
- vconfig rem ${1} ${ID} &>/dev/null
+ MESSAGE="Removing VLAN ${ID} from port ${port}..."
+ vconfig rem ${device} ${ID} &>/dev/null
evaluate_retval
;;
+ add)
+ ID=$3
+ cat <<EOF > ${CONFIG_PORTS}/${port}/vlan-${ID}
+HOOK=vlan
+ID=${ID}
+EOF
+ ln -sf ${CONFIG_PORTS}/${port}/vlan-${ID} \
+ ${CONFIG_ZONES}/${ZONE}/port-${port}-vlan-${ID}
+ ;;
+
+ remove)
+ rm -f \
+ ${CONFIG_PORTS}/${port}/vlan-${ID} \
+ ${CONFIG_ZONES}/${ZONE}/port-${port}-vlan-${ID}
+ ;;
+
*)
- echo "Usage: ${0} [interface] {up|down}"
+ echo "Usage: ${0} [interface] {up|down|add|remove}"
exit 1
;;
esac
+++ /dev/null
-#!/bin/sh
-########################################################################
-# Begin $NETWORK_DEVICES/ifdown
-#
-# Description : Interface Down
-#
-# Authors : Michael Tremer - michael.tremer@ipfire.org
-#
-# Version : 00.00
-#
-# Notes : This script brings up the configuration of each interface.
-# It handles some dependencies.
-#
-########################################################################
-
-. /lib/lsb/init-functions
-
-file=${1}
-
-if [ ! -f "${file}" ]; then
- message="Unable to process ${file}. File does not exist."
- log_failure_msg
- exit 1
-fi
-
-. ${file}
-
-if [ -n "${SERVICE}" -a -x "${NETWORK_SCRIPTS}/services/${SERVICE}" ]; then
- IFCONFIG=${file} ${NETWORK_SCRIPTS}/services/${SERVICE} ${1} down
-else
- echo -e "${FAILURE}Unable to process ${file}. Either"
- echo -e "${FAILURE}the SERVICE variable was not set,"
- echo -e "${FAILURE}or the specified service cannot be executed."
- message=""
- log_failure_msg
-fi
-
-# XXX We must check if a bridge has no devices left.
-
-# End $NETWORK_DEVICES/ifdown
+++ /dev/null
-#!/bin/sh
-########################################################################
-# Begin $NETWORK_DEVICES/ifup
-#
-# Description : Interface Up
-#
-# Authors : Michael Tremer - michael.tremer@ipfire.org
-#
-# Version : 00.00
-#
-# Notes : This script brings up the configuration of each interface.
-# It handles some dependencies.
-#
-########################################################################
-
-. /lib/lsb/init-functions
-
-file=${1}
-
-if [ ! -f "${file}" ]; then
- message="Unable to process ${file}. File does not exist."
- log_failure_msg
- exit 1
-fi
-
-. ${file}
-
-# XXX We must check if a bridge is there and up.
-
-if [ -n "${SERVICE}" -a -x "${NETWORK_SCRIPTS}/services/${SERVICE}" ]; then
- IFCONFIG=${file} ${NETWORK_SCRIPTS}/services/${SERVICE} ${1} up
-else
- echo -e "${FAILURE}Unable to process ${file}. Either"
- echo -e "${FAILURE}the SERVICE variable was not set,"
- echo -e "${FAILURE}or the specified service cannot be executed."
- message=""
- log_failure_msg
-fi
-
-# End $NETWORK_DEVICES/ifup
--- /dev/null
+#!/bin/bash
+###############################################################################
+# #
+# IPFire.org - A linux based firewall #
+# Copyright (C) 2009 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/lsb/init-functions
+. /etc/init.d/networking/functions
+
+port=$(macify $1)
+action=$2
+
+shift 2
+
+if ! device_exists ${port}; then
+ echo "Port ${port} does not exist."
+ exit 1
+fi
+
+if [ -z "${port}" ] || [ -z "${action}" ]; then
+ echo "Usage: $0 <port> <up|down> [hooks]"
+ echo
+fi
+
+for arg in ${@-$(find ${CONFIG_PORTS}/${port}/)}; do
+ arg=${arg##*/}
+ [ -e "${CONFIG_PORTS}/${port}/${arg}" ] || continue
+ hooks="${hooks} ${CONFIG_PORTS}/${port}/${arg}"
+done
+
+echo "DEBUG: hooks: $hooks"
+
+# Getting zone variable
+#local zone
+#if [ -z "$ZONE" ]; then
+# for zone in $(all_zones); do
+# for i in ${zone}/port-*; do
+# i=$(readlink ${i})
+# for j in ${ports}; do
+# if [ "${i}" = "${j}" ]; then
+# ZONE=${i%/*}
+# ZONE=${ZONE##*/}
+# fi
+# done
+# done
+# done
+#fi
+
+case "$action" in
+ up)
+ message="Setting up port ${port}..."
+ ip link set $(devicify ${port}) up
+ evaluate_retval
+
+ for hook in ${hooks}; do
+ [ -d "${hook}" ] && continue
+ (
+ . ${hook}
+ if [ -n "${HOOK}" -a -x "/etc/init.d/networking/hooks/${HOOK}" ]; then
+ CONFIG=${hook} /etc/init.d/networking/hooks/${HOOK} ${port} up
+ else
+ echo -e "${FAILURE}Unable to process ${hook}. Either"
+ echo -e "${FAILURE}the HOOK variable was not set,"
+ echo -e "${FAILURE}or the specified hook cannot be executed."
+ message=""
+ log_failure_msg
+ fi
+ )
+ done
+ ;;
+ down)
+ for hook in ${hooks}; do
+ [ -d "${hook}" ] && continue
+ (
+ . ${hook}
+ if [ -n "${HOOK}" -a -x "/etc/init.d/networking/hooks/${HOOK}" ]; then
+ CONFIG=${hook} /etc/init.d/networking/hooks/${HOOK} ${port} down
+ else
+ echo -e "${FAILURE}Unable to process ${hook}. Either"
+ echo -e "${FAILURE}the HOOK variable was not set,"
+ echo -e "${FAILURE}or the specified hook cannot be executed."
+ message=""
+ log_failure_msg
+ fi
+ )
+ done
+
+ message="Pushing down port ${port}..."
+ ip link set $(devicify ${port}) down
+ evaluate_retval
+ ;;
+esac
--- /dev/null
+#!/bin/bash
+###############################################################################
+# #
+# IPFire.org - A linux based firewall #
+# Copyright (C) 2009 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/lsb/init-functions
+. /etc/init.d/networking/functions
+
+zone=$1
+action=$2
+
+case "$action" in
+ up)
+ message="Bringing up zone ${zone}..."
+
+ # Check if bridge already exists
+ zone_status=`brctl show 2>/dev/null`
+ if ! echo "${zone_status}" | grep -q "^${zone}"; then
+ #/etc/init.d/networking/hooks pre-up ${CONFIG_ZONES}/${zone}
+
+ # Create and bring up the zone
+ brctl addbr ${zone} || failed=1
+ ip link set ${zone} up || failed=1
+ (exit ${failed})
+ evaluate_retval standard
+
+ [ "${IN_BOOT}" = "1" ] && \
+ for port in ${CONFIG_ZONES}/${zone}/port-*; do
+ #port=$(readlink ${port})
+ ZONE=${zone} /etc/init.d/networking/port ${port} up
+ done
+
+ ###/etc/init.d/networking/hooks post-up ${CONFIG_ZONES}/${zone}
+ else
+ log_warning_msg
+ message="Zone ${zone} does already exist."
+ log_warning_msg
+ fi
+ ;;
+
+ down)
+ message="Bringing down zone ${zone}..."
+ # Check if bridge already exists
+ zone_status=`brctl show 2>/dev/null`
+ if echo "${zone_status}" | grep -q "^${zone}"; then
+ #/etc/init.d/networking/hooks pre-down ${CONFIG_ZONES}/${zone}
+ # remove devices
+
+ for port in ${CONFIG_ZONES}/${zone}/port-*; do
+ brctl delif ${zone} ${port##*/}
+ /etc/init.d/networking/port ${port} down
+ done
+
+ # Bring down the zone and delete it
+ ip link set ${zone} down || failed=1
+ brctl delbr ${zone} || failed=1
+ (exit ${failed})
+ evaluate_retval standard
+
+ #/etc/init.d/networking/hooks post-down ${CONFIG_ZONES}/${zone}
+ else
+ log_warning_msg
+ message="Zone ${zone} does not exist."
+ log_warning_msg
+ fi
+ ;;
+esac
HOSTNAME=ipfire.localdomain
-NETWORK_DEVICES=/etc/sysconfig/network-devices
NORMAL="\\033[0;39m"
ERROR="\\033[1;31m"
-. ../src/initscripts/networking/functions
-
-CONFIG_DIR=${CONFIG_DIR-/etc/sysconfig/networking}
-
-CONFIG_ZONES=${CONFIG_DIR}/zones
-CONFIG_PORTS=${CONFIG_DIR}/ports
+. /etc/init.d/networking/functions
function usage() {
echo "Usage $0 - TODO"
exit $1
}
-function devicify() {
- local device
- local mac
-
- device=$1
-
- if is_mac ${device}; then
- mac=${device}
- device=$(get_device_by_mac ${device})
- decho "Figured out that ${mac} is ${device}."
- fi
- decho "Function: devicify $@ -> ${device}"
- echo ${device}
-}
-
function port_show() {
local port
function port_add() {
local port
local zone
- local vid
+ local hook
zone=$1
- port=$(devicify $2)
- vid=${3-0}
+ port=$(macify $2)
+ hook=${3-ethernet}
- decho "Function: port_add $@"
- decho " Zone: ${zone} Port: ${port} VLAN-ID: ${vid}"
+ shift 3
- # XXX Check if vlan id is valid
+ decho "Function: port_add"
+ decho " Zone: ${zone} Port: ${port} Hook: ${hook} $@"
if ! zone_exists ${zone}; then
error "Zone ${BOLD}${zone}${NORMAL} does not exist."
fi
if [ -z "$port" ]; then
- error "Port ${BOLD}${2}${NORMAL} could not be found."
+ error "Port ${BOLD}${port}${NORMAL} could not be found."
return 1
fi
-
+
if ! device_exists ${port}; then
error "Port ${BOLD}${port}${NORMAL} does not exist."
return 1
fi
- local mac
- mac=$(get_mac_by_device ${port})
-
- mkdir -p ${CONFIG_PORTS}/${mac} 2>/dev/null
- touch ${CONFIG_PORTS}/${mac}/${vid}
- ln -sf ${CONFIG_PORTS}/${mac}/${vid} ${CONFIG_ZONES}/${zone}/port-${mac}-${vid}
-
- # XXX add code to bring up device immediately
-
- vecho "Successfully added port ${BOLD}${port}${NORMAL} (${mac} - ${vid}) to ${BOLD}${zone}${NORMAL}."
+ mkdir -p ${CONFIG_PORTS}/${port} 2>/dev/null
+ if [ -x "/etc/init.d/networking/hooks/${hook}" ]; then
+ ZONE=${zone} /etc/init.d/networking/hooks/${hook} ${port} add $@
+ RET=$?
+ if [ "$RET" -eq "0" ]; then
+ vecho "Successfully added port ${BOLD}${port}${NORMAL} (${hook} $@) to ${BOLD}${zone}${NORMAL}."
+ /etc/init.d/networking/port ${port} up
+ else
+ error "Hook ${BOLD}${hook}${NORMAL} exited with $RET."
+ return $RET
+ fi
+ else
+ error "Hook ${BOLD}${hook}${NORMAL} does not exist or is not executeable."
+ return 1
+ fi
}
function port_del() {
local port
local zone
- local vid
-
+ local hook
+
zone=$1
port=$(devicify $2)
- vid=${3-0}
+ hook=${3-ethernet}
- decho "Function: port_del $@"
- decho " Zone: ${zone} Port: ${port} VLAN-ID: ${vid}"
+ shift 3
- rm -f ${CONFIG_ZONES}/${zone}/port-${mac}-${vid} \
- ${CONFIG_PORTS}/${mac}/${vid} 2>/dev/null
- rm -r ${CONFIG_PORTS}/${mac}/ 2>/dev/null # XXX Does this only remove if dir is empty?
+ decho "Function: port_del"
+ decho " Zone: ${zone} Port: ${port} Hook: ${hook}"
- # XXX add code to bring down device immediately
-
- vecho "Successfully removed port ${BOLD}${port}${NORMAL} (${mac} - ${vid}) from ${BOLD}${zone}${NORMAL}."
+ if [ -x "/etc/init.d/networking/hooks/${hook}" ]; then
+ /etc/init.d/networking/port ${port} down ## XXX How do we identify only that one hook?
+ ZONE=${zone} /etc/init.d/networking/hooks/${hook} ${port} remove $@
+ RET=$?
+ if [ "$RET" -eq "0" ]; then
+ vecho "Successfully removed port ${BOLD}${port}${NORMAL} (${hook} $@) from ${BOLD}${zone}${NORMAL}."
+ else
+ error "Hook ${BOLD}${hook}${NORMAL} exited with $RET."
+ return $RET
+ fi
+ else
+ error "Hook ${BOLD}${hook}${NORMAL} does not exist or is not executeable."
+ return 1
+ fi
}
function zone_show() {
echo -e "# ${ERROR}Ports:${NORMAL}"
local port
for port in ${CONFIG_ZONES}/${zone}/port-*; do
- port=$(basename ${port})
+ port=${port##*/}
echo "# ${port#port-}"
debug && echo "# TODO: Is port up or down?"
done
etc/init.d/mountkernfs
etc/init.d/network
etc/init.d/networking
-etc/init.d/networking/brdown
-etc/init.d/networking/brup
etc/init.d/networking/functions
-etc/init.d/networking/ifdown
-etc/init.d/networking/ifup
+etc/init.d/networking/hooks
+etc/init.d/networking/hooks/bonding
+etc/init.d/networking/hooks/bridge-slave
+etc/init.d/networking/hooks/ethernet
+etc/init.d/networking/hooks/ipv4-static
+etc/init.d/networking/hooks/ipv4-static-route
+etc/init.d/networking/hooks/stp
+etc/init.d/networking/hooks/vlan
etc/init.d/networking/net-hotplug
-etc/init.d/networking/services
-etc/init.d/networking/services/bonding
-etc/init.d/networking/services/bridge-slave
-etc/init.d/networking/services/ipv4-static
-etc/init.d/networking/services/ipv4-static-route
-etc/init.d/networking/services/stp
+etc/init.d/networking/port
+etc/init.d/networking/zone
etc/init.d/ntpd
etc/init.d/openldap
etc/init.d/random
etc/ipfire/certs/index.txt
etc/ipfire/certs/serial
etc/ipfire/crls
-etc/ipfire/network
-etc/ipfire/network/devices
-etc/sysconfig/network-devices
+etc/ipfire/networking
+etc/sysconfig/networking