EXTRA = no
DEBUG = no
BUILD_DEPS =
-DEPS = initscripts
+DEPS =
URL = http://www.ipfire.org/
LICENSE = GPL3+
$(OBJECT): $(objects)
@$(PREBUILD)
- install -m 755 -v $(DIR_APP)/network /usr/bin
+ install -m 755 -v $(DIR_APP)/network /sbin
+ -mkdir -pv /lib/network
+ cp -av $(DIR_APP)/lib/* /lib/network/
$(INSTALL_INITSCRIPT)
@$(POSTBUILD)
+++ /dev/null
-#!/bin/sh
-########################################################################
-# Begin $NETWORK_DEVICES/services/bridge-slave
-#
-# Description : Bridge Slave Script
-#
-# Authors : Michael Tremer - michael.tremer@ipfire.org
-#
-# Version : 00.00
-#
-# Notes : This script adds a nic to a bridge.
-#
-########################################################################
-
-. /lib/lsb/init-functions
-[ -n "${CONFIG}" ] && . ${CONFIG}
-
-interface=${IFCONFIG##*/}
-
-. /etc/init.d/networking/functions
-
-case "${2}" in
- up)
- if ! device_exists ${BRIDGE}; then
- MESSAGE="Bringing up bridge ${BRIDGE}..."
- brctl addbr ${BRIDGE} || failed=1
- ip link set ${BRIDGE} up || failed=1
- (exit ${failed})
- evaluate_retval
- fi
-
- MESSAGE="Adding slave interface ${interface} to the ${1} interface..."
- brctl addif ${1} ${interface}
- evaluate_retval
- ;;
-
- down)
- MESSAGE="Removing slave interface ${interface} from the ${1} interface..."
- brctl delif ${1} ${interface}
- evaluate_retval
- ;;
-
- *)
- echo "Usage: ${0} [interface] {up|down}"
- exit 1
- ;;
-esac
-
-# End $NETWORK_DEVICES/services/bridge-slave
+++ /dev/null
-#!/bin/bash
-###############################################################################
-# #
-# IPFire.org - A linux based firewall #
-# Copyright (C) 2007, 2008, 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/>. #
-# #
-###############################################################################
-
-. /etc/init.d/networking/functions
-
-if [ "$INTERFACE" = "" ]; then
- exit 1
-fi
-
-MAC=$(get_mac ${INTERFACE})
-
-case $ACTION in
- add|register)
- # Don't do anything if the network is stopped
- if [ -f /dev/.in_sysinit ] ; then
- exit 0
- fi
- if [ ! -f /var/lock/subsys/network ]; then
- exit 0
- fi
- case $INTERFACE in
- # interfaces that are brought up as a part of configuration
- ppp*|ippp*|isdn*|plip*|lo*|irda*|dummy*|ipsec*|tun*|tap*)
- exit 0
- ;;
- # interfaces that are registered then brought up
- *)
- export IN_HOTPLUG=1
- /etc/init.d/networking/port ${MAC} up
- # XXX Walk through zones here?
- ;;
- esac
- ;;
-
- remove|unregister)
- case $INTERFACE in
- # interfaces that are brought down as part of deconfiguration
- ppp*|ippp*|isdn*|plip*|lo*|irda*|dummy*|ipsec*|tun*|tap*)
- exit 0
- ;;
- *)
- export IN_HOTPLUG=1
- : # Nothing to do here at the moment
- ;;
- esac
- ;;
-
- *)
- exit 1
- ;;
-
-esac
########################################################################
. /lib/lsb/init-functions
-. /etc/init.d/networking/functions
+. /lib/network/functions
+
[ -n "${CONFIG}" ] && . ${CONFIG}
port=$(macify ${1})
########################################################################
. /lib/lsb/init-functions
-. /etc/init.d/networking/functions
+. /lib/network/functions
+
[ -n "${CONFIG}" ] && . ${CONFIG}
zone=$2
shift 2
while [ $# -gt 0 ]; do
case "$1" in
- --ip=)
- IP=${2#--ip=}
+ --ip=*)
+ IP=${1#--ip=}
;;
- --prefix=)
- PREFIX=${2#--prefix=}
+ --prefix=*)
+ PREFIX=${1#--prefix=}
;;
- --peer=)
- PEER=${2#--peer=}
+ --peer=*)
+ PEER=${1#--peer=}
;;
- --broadcast=)
- BROADCAST=${2#--broadcast=}
+ --broadcast=*)
+ BROADCAST=${1#--broadcast=}
;;
- --source=)
- SOURCE=${2#--source=}
+ --source=*)
+ SOURCE=${1#--source=}
;;
- --gateway=)
- GATEWAY=${2#--gateway=}
+ --gateway=*)
+ GATEWAY=${1#--gateway=}
;;
*)
echo "Unknown option: $1" >&2
;;
*)
- echo "Usage: ${0} {pre-up|post-up|pre-down|post-down|config} [interface]"
+ echo "Usage: ${0} {config|pre-up|post-up|pre-down|post-down|status} [interface]"
exit 1
;;
esac
########################################################################
. /lib/lsb/init-functions
+. /lib/network/functions
+
[ -n "${CONFIG}" ] && . ${CONFIG}
zone=$2
########################################################################
. /lib/lsb/init-functions
-. /etc/init.d/networking/functions
+. /lib/network/functions
+
[ -n "${CONFIG}" ] && . ${CONFIG}
function check_config() {
########################################################################
. /lib/lsb/init-functions
+. /lib/network/functions
+
[ -n "${CONFIG}" ] && . ${CONFIG}
zone=$2
########################################################################
. /lib/lsb/init-functions
-. /etc/init.d/networking/functions
+. /lib/network/functions
+
[ -n "${CONFIG}" ] && . ${CONFIG}
port=$(macify ${1})
###############################################################################
. /lib/lsb/init-functions
-. /etc/init.d/networking/functions
+. /lib/network/functions
port=$(macify $1)
action=$2
###############################################################################
. /lib/lsb/init-functions
-. /etc/init.d/networking/functions
+. /lib/network/functions
zone=$1
action=$2
NORMAL="\\033[0;39m"
ERROR="\\033[1;31m"
-. /etc/init.d/networking/functions
+. /lib/network/functions
function usage() {
echo -e "${BOLD}Usage $0${NORMAL}\n"
echo " Adds a port to a zone."
echo
echo " Requires a \"zone\" and \"port\"."
- echo " Example: $0 zone addport green0"
+ echo " Example: $0 zone addport green0 black0"
echo
echo " You may also pass a hook and its parameters:"
echo " $0 zone addport green0 black0 vlan 10"
}
function vecho() {
- verbose && echo -e "$@" >&2
+ verbose && echo -e "$@" >&2
}
function error() {
}
function _exit() {
- if [ $1 -eq 0 ] && [ "$DO_RELOAD" = "1" ]; then
+ local code
+ local reload
+
+ while [ $# -gt 0 ]; do
+ case "$1" in
+ --reload)
+ reload=1
+ ;;
+ [0-9]*)
+ code=$1
+ ;;
+ *)
+ error "Unrecognized argument: $1"
+ ;;
+ esac
+ shift
+ done
+ if [ ${reload} -eq 1 ]; then
# Reloading network to apply changes immediately
vecho "Reloading network settings..."
cmd $0 $(verbose && echo "-v") $(debug && echo "-d") reload
fi
- decho "Exiting with code $1."
- exit $1
+ decho "Exiting with code ${code}."
+ exit ${code}
}
function cmd() {
fi
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 $@
+ if [ -x "/lib/network/hooks/${hook}" ]; then
+ ZONE=${zone} /lib/network/hooks/${hook} ${port} add $@
RET=$?
if [ "$RET" -eq "0" ]; then
vecho "Successfully added port ${BOLD}${port}${NORMAL} (${hook} $@) to ${BOLD}${zone}${NORMAL}."
- cmd /etc/init.d/networking/port ${port} up
+ cmd /lib/network/port ${port} up
else
error "Hook ${BOLD}${hook}${NORMAL} exited with $RET."
return $RET
error "Hook ${BOLD}${hook}${NORMAL} does not exist or is not executeable."
return 1
fi
- cmd /etc/init.d/networking/zone ${zone} up
+ cmd /lib/network/zone ${zone} up
}
function port_del() {
decho "Function: port_del"
decho " Zone: ${zone} Port: ${port} Hook: ${hook}"
- if [ -x "/etc/init.d/networking/hooks/${hook}" ]; then
- cmd /etc/init.d/networking/port ${port} down ## XXX How do we identify only that one hook?
- ZONE=${zone} cmd /etc/init.d/networking/hooks/${hook} ${port} remove $@
+ if [ -x "/lib/network/hooks/${hook}" ]; then
+ cmd /lib/network/port ${port} down ## XXX How do we identify only that one hook?
+ ZONE=${zone} cmd /lib/network/hooks/${hook} ${port} remove $@
RET=$?
if [ "$RET" -eq "0" ]; then
vecho "Successfully removed port ${BOLD}${port}${NORMAL} (${hook} $@) from ${BOLD}${zone}${NORMAL}."
local port
for config in ${CONFIG_ZONES}/${zone}/port-*; do
port=${config##*/}; port=${port#port-}; port=${port%%-*}
- if ZONE=${zone} cmd /etc/init.d/networking/port ${port} attach ${config} &>/dev/null; then
+ if ZONE=${zone} cmd /lib/network/port ${port} attach ${config} &>/dev/null; then
echo "# ${config#port-} is up"
else
echo "# ${config#port-} is down"
mkdir -p ${CONFIG_ZONES}/${zone}
vecho "Successfully added zone ${zone}."
- cmd /etc/init.d/networking/zone ${zone} up
+ cmd /lib/network/zone ${zone} up
}
function zone_del() {
return 1
fi
- cmd /etc/init.d/networking/zone ${zone} down
+ cmd /lib/network/zone ${zone} down
rm -rf ${CONFIG_ZONES}/${zone}
vecho "Successfully removed zone ${zone}."
}
-DO_RELOAD=1
-
# See what to do
while [ "$#" -gt 0 ]; do
arg=$1
case "$arg" in
show)
port_show $@
- DO_RELOAD=0 _exit $?
+ _exit $?
;;
help)
usage port 0
case "$arg" in
add)
zone_add $@
- _exit $?
+ _exit --reload $?
;;
del)
zone_del $@
- _exit $?
+ _exit --reload $?
;;
show)
zone_show $@
- DO_RELOAD=0 _exit $?
+ _exit $?
;;
addport)
port_add $@
- _exit $?
+ _exit --reload $?
;;
delport)
port_del $@
- _exit $?
+ _exit --reload $?
;;
list)
all_zones
_exit $?
;;
config)
- zone=$1; shift
- hook=$1; shift
- if [ -x /etc/init.d/networking/hooks/${hook} ]; then
- /etc/init.d/networking/hooks/${hook} config ${zone} $@
+ zone=$1; hook=$2; shift 2
+ if [ -z "${zone}" ] || [ -z "${hook}" ]; then
+ usage config
+ fi
+ if [ -x /lib/network/hooks/${hook} ]; then
+ /lib/network/hooks/${hook} config ${zone} $@
RET=$?
else
error "\"${hook}\" is not a known hook."
_exit $RET
;;
help)
- DO_RELOAD=0 usage zone 0
+ usage zone 0
;;
esac
;;
-*)
- DO_RELOAD=0 error "Option \"$arg\" is not known."
+ error "Option \"$arg\" is not known."
;;
esac
done
-etc/init.d/network
-usr/bin/network
+lib/network
+lib/network/functions
+lib/network/hooks
+lib/network/hooks/bonding
+lib/network/hooks/ethernet
+lib/network/hooks/ipv4-static
+lib/network/hooks/ipv4-static-route
+lib/network/hooks/mtu
+lib/network/hooks/stp
+lib/network/hooks/vlan
+lib/network/port
+lib/network/zone
+sbin/network