]> git.ipfire.org Git - ipfire-3.x.git/commitdiff
Moved networking files from initscript package to network package.
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 24 May 2009 14:53:50 +0000 (16:53 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 24 May 2009 14:53:50 +0000 (16:53 +0200)
15 files changed:
lfs/network
src/initscripts/networking/hooks/bridge-slave [deleted file]
src/initscripts/networking/net-hotplug [deleted file]
src/network/lib/functions [moved from src/initscripts/networking/functions with 100% similarity]
src/network/lib/hooks/bonding [moved from src/initscripts/networking/hooks/bonding with 100% similarity]
src/network/lib/hooks/ethernet [moved from src/initscripts/networking/hooks/ethernet with 97% similarity]
src/network/lib/hooks/ipv4-static [moved from src/initscripts/networking/hooks/ipv4-static with 87% similarity]
src/network/lib/hooks/ipv4-static-route [moved from src/initscripts/networking/hooks/ipv4-static-route with 98% similarity]
src/network/lib/hooks/mtu [moved from src/initscripts/networking/hooks/mtu with 97% similarity]
src/network/lib/hooks/stp [moved from src/initscripts/networking/hooks/stp with 97% similarity]
src/network/lib/hooks/vlan [moved from src/initscripts/networking/hooks/vlan with 98% similarity]
src/network/lib/port [moved from src/initscripts/networking/port with 98% similarity]
src/network/lib/zone [moved from src/initscripts/networking/zone with 98% similarity]
src/network/network
src/rootfiles/core/network

index c4bea37c21649bf75621d063c41736eb8ad31255..146799451915d26e97105da7011b98f86d5cf674 100644 (file)
@@ -39,7 +39,7 @@ CORE       = yes
 EXTRA      = no
 DEBUG      = no
 BUILD_DEPS =
-DEPS       = initscripts
+DEPS       =
 
 URL        = http://www.ipfire.org/
 LICENSE    = GPL3+
@@ -74,6 +74,8 @@ $(objects):
 
 $(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)
diff --git a/src/initscripts/networking/hooks/bridge-slave b/src/initscripts/networking/hooks/bridge-slave
deleted file mode 100644 (file)
index 62ef54d..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/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
diff --git a/src/initscripts/networking/net-hotplug b/src/initscripts/networking/net-hotplug
deleted file mode 100644 (file)
index 405eff2..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/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
similarity index 97%
rename from src/initscripts/networking/hooks/ethernet
rename to src/network/lib/hooks/ethernet
index 3926420922c0108d2285042997ef1e2f3a9f2b0a..085fad7745d4cc2c247478acb21fa92789cb176f 100644 (file)
@@ -13,7 +13,8 @@
 ########################################################################
 
 . /lib/lsb/init-functions
-. /etc/init.d/networking/functions
+. /lib/network/functions
+
 [ -n "${CONFIG}" ] && . ${CONFIG}
 
 port=$(macify ${1})
similarity index 87%
rename from src/initscripts/networking/hooks/ipv4-static
rename to src/network/lib/hooks/ipv4-static
index 689932ffeae21a976f13c3b10a61c81941ae1490..41e73eee62d1537d6cf6816f2cfefda038e9e142 100644 (file)
@@ -14,7 +14,8 @@
 ########################################################################
 
 . /lib/lsb/init-functions
-. /etc/init.d/networking/functions
+. /lib/network/functions
+
 [ -n "${CONFIG}" ] && . ${CONFIG}
 
 zone=$2
@@ -94,23 +95,23 @@ case "${1}" in
                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
@@ -133,7 +134,7 @@ EOF
                ;;
        
        *)
-               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
similarity index 98%
rename from src/initscripts/networking/hooks/ipv4-static-route
rename to src/network/lib/hooks/ipv4-static-route
index 9daff1971284bc50c0172736c8bc2bc46212074c..73386779d963aac1e90ead563821a436a40b594e 100644 (file)
@@ -13,6 +13,8 @@
 ########################################################################
 
 . /lib/lsb/init-functions
+. /lib/network/functions
+
 [ -n "${CONFIG}" ] && . ${CONFIG}
 
 zone=$2
similarity index 97%
rename from src/initscripts/networking/hooks/mtu
rename to src/network/lib/hooks/mtu
index 99b1c9d92665e89154cccb0c826448dc5f9101b9..2cbd039abd73612f68a197f83e74ebcd07c47f7b 100644 (file)
@@ -16,7 +16,8 @@
 ########################################################################
 
 . /lib/lsb/init-functions
-. /etc/init.d/networking/functions
+. /lib/network/functions
+
 [ -n "${CONFIG}" ] && . ${CONFIG}
 
 function check_config() {
similarity index 97%
rename from src/initscripts/networking/hooks/stp
rename to src/network/lib/hooks/stp
index ed128dd35f9a587960763cb294914afe24f883b3..7b795edb2d9823b551aacab12ab207ee355e9389 100644 (file)
@@ -13,6 +13,8 @@
 ########################################################################
 
 . /lib/lsb/init-functions
+. /lib/network/functions
+
 [ -n "${CONFIG}" ] && . ${CONFIG}
 
 zone=$2
similarity index 98%
rename from src/initscripts/networking/hooks/vlan
rename to src/network/lib/hooks/vlan
index 3feaef9760eb73a1fcab5382a846a3a3c518bdad..cc61e398baf80601462ea2c363ed44719eb45229 100644 (file)
@@ -13,7 +13,8 @@
 ########################################################################
 
 . /lib/lsb/init-functions
-. /etc/init.d/networking/functions
+. /lib/network/functions
+
 [ -n "${CONFIG}" ] && . ${CONFIG}
 
 port=$(macify ${1})
similarity index 98%
rename from src/initscripts/networking/port
rename to src/network/lib/port
index 3fbd2bd6e7b7adf95e4425e5b7811816d0e66243..7bd56724bdc0c9211ee414a0fc33e02ca84dcc42 100644 (file)
@@ -20,7 +20,7 @@
 ###############################################################################
 
 . /lib/lsb/init-functions
-. /etc/init.d/networking/functions
+. /lib/network/functions
 
 port=$(macify $1)
 action=$2
similarity index 98%
rename from src/initscripts/networking/zone
rename to src/network/lib/zone
index ec194f8db26c56e248976931df398d53579a2298..7a0fcce7d8c2db52416376d173082d4eac7c9f4c 100644 (file)
@@ -20,7 +20,7 @@
 ###############################################################################
 
 . /lib/lsb/init-functions
-. /etc/init.d/networking/functions
+. /lib/network/functions
 
 zone=$1
 action=$2
index 39091b192231741b6572c5ae6be11bb4be573e80..462dcb93dd82675dca8994c5627d6ef6a4aef662 100644 (file)
@@ -26,7 +26,7 @@ BOLD="\\033[1;39m"
 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"
@@ -98,7 +98,7 @@ function usage() {
                        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"
@@ -148,7 +148,7 @@ function decho() {
 }
 
 function vecho() {
-       verbose && echo -e "$@"  >&2
+       verbose && echo -e "$@" >&2
 }
 
 function error() {
@@ -157,14 +157,31 @@ 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() {
@@ -219,12 +236,12 @@ function port_add() {
        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
@@ -233,7 +250,7 @@ function port_add() {
                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() {
@@ -250,9 +267,9 @@ 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}."
@@ -300,7 +317,7 @@ function zone_show() {
        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"
@@ -321,7 +338,7 @@ function zone_add() {
 
        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() {
@@ -333,13 +350,11 @@ 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
@@ -365,7 +380,7 @@ while [ "$#" -gt 0 ]; do
                        case "$arg" in
                                show)
                                        port_show $@
-                                       DO_RELOAD=0 _exit $?
+                                       _exit $?
                                        ;;
                                help)
                                        usage port 0
@@ -378,33 +393,35 @@ while [ "$#" -gt 0 ]; do
                        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."
@@ -412,12 +429,12 @@ while [ "$#" -gt 0 ]; do
                                        _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
index ecc4cb9226c1154f6c980e6aa31ee0a39075f9b8..8c1dded09b302ce7740de6b496898796c45da2eb 100644 (file)
@@ -1,2 +1,13 @@
-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