From: Michael Tremer Date: Wed, 4 Feb 2009 20:13:28 +0000 (+0100) Subject: Adding hotplug scripts. X-Git-Tag: v3.0-alpha1~33^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f0a79c3340aaec0643d856c9de2c845b1d22379d;p=ipfire-3.x.git Adding hotplug scripts. --- diff --git a/src/initscripts/networking/ifdown b/src/initscripts/networking/ifdown new file mode 100644 index 000000000..fe9258e24 --- /dev/null +++ b/src/initscripts/networking/ifdown @@ -0,0 +1,40 @@ +#!/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 diff --git a/src/initscripts/networking/ifup b/src/initscripts/networking/ifup new file mode 100644 index 000000000..092d13a60 --- /dev/null +++ b/src/initscripts/networking/ifup @@ -0,0 +1,40 @@ +#!/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 diff --git a/src/initscripts/networking/net-hotplug b/src/initscripts/networking/net-hotplug index 8b89510fb..978e8008d 100644 --- a/src/initscripts/networking/net-hotplug +++ b/src/initscripts/networking/net-hotplug @@ -19,10 +19,14 @@ # # ############################################################################### +. /etc/init.d/networking/functions + if [ "$INTERFACE" = "" ]; then exit 1 fi +MAC=$(get_mac_by_device ${INTERFACE}) + case $ACTION in add|register) case $INTERFACE in @@ -33,7 +37,13 @@ case $ACTION in # interfaces that are registered then brought up *) export IN_HOTPLUG=1 - ## Put ifup code here + for file in ${NETWORK_DEVICES}/*/*; do + if [ "$(basename ${file})" = "${MAC}" ]; then + /etc/init.d/networking/ifup ${file} + exit $? + fi + done + exit 1 ;; esac ;; @@ -46,7 +56,13 @@ case $ACTION in ;; *) export IN_HOTPLUG=1 - ## Put ifdown code here + for file in ${NETWORK_DEVICES}/*/*; do + if [ "$(basename ${file})" = "${MAC}" ]; then + /etc/init.d/networking/ifdown ${file} + exit $? + fi + done + exit 1 ;; esac ;;