]> git.ipfire.org Git - ipfire-3.x.git/commitdiff
Adding hotplug scripts.
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 4 Feb 2009 20:13:28 +0000 (21:13 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 4 Feb 2009 20:13:28 +0000 (21:13 +0100)
src/initscripts/networking/ifdown [new file with mode: 0644]
src/initscripts/networking/ifup [new file with mode: 0644]
src/initscripts/networking/net-hotplug

diff --git a/src/initscripts/networking/ifdown b/src/initscripts/networking/ifdown
new file mode 100644 (file)
index 0000000..fe9258e
--- /dev/null
@@ -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 (file)
index 0000000..092d13a
--- /dev/null
@@ -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
index 8b89510fb39be425221e8937635fb9e804d059a5..978e8008d901fda5caa2d8aa83c0b7acee2a6474 100644 (file)
 #                                                                             #
 ###############################################################################
 
+. /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
                ;;