]> git.ipfire.org Git - people/arne_f/network.git/commitdiff
network: Automatically create all ethernet ports.
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 23 Jul 2010 13:10:58 +0000 (15:10 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 23 Jul 2010 13:10:58 +0000 (15:10 +0200)
functions.cli
functions.device
functions.ports

index 9339a7bc2f0690b689dd9bf00cbb80bcde233201..7986413ea08618c14ed2515e3c70641f3344630a 100644 (file)
@@ -348,7 +348,8 @@ function cli_reset() {
                port_remove ${port}
        done
 
-       # XXX recreate ethernet ports
+       # Re-run the initialization functions
+       init_run
 
        exit ${EXIT_OK}
 }
index 70346c4b460e6ebdce961d7184200968fc5585bc..8ee7ca53d3c5f112a8ff90175ae0b32c58feddf3 100644 (file)
@@ -247,32 +247,17 @@ function device_set_address() {
 }
 
 function device_get() {
-       local from_config
-
-       while [ $# -gt 0 ]; do
-               case "${1}" in
-                       --from-config)
-                               from_config=1
-                               ;;
-                       --no-config)
-                               from_config=0
-                               ;;
-               esac
-               shift
-       done
-
+       local device
        local devices
 
-       if [ "${from_config}" != "0" ]; then
-               devices="${devices} $(device_config_list)"
-       fi
+       for device in ${SYS_CLASS_NET}/*; do
+               device=$(basename ${device})
 
-       if [ "${from_config}" != "1" ]; then
-               local device
-               for device in ${SYS_CLASS_NET}/*; do
-                       devices="${devices} $(basename ${device})"
-               done
-       fi
+               # bonding_masters is no device
+               [ "${device}" = "bonding_masters" ] && continue
+
+               devices="${devices} ${device}"
+       done
 
        echo ${devices}
        return ${EXIT_OK}
index d0d7dee62398c0ad7d6717351adb3c22966b24fc..6c59578dedc017232aafc6047914d63c34c6e5f5 100644 (file)
@@ -142,3 +142,19 @@ function ports_get() {
                fi
        done
 }
+
+# This function automatically creates the real ethernet devices
+# that do not exists in the configuration.
+# Saves some work for the administrator.
+function ports_init() {
+       local device
+       for device in $(devices_get_all); do
+               if device_is_real ${device}; then
+                       if ! port_exists ${device}; then
+                               port_create ethernet ${device}
+                       fi
+               fi
+       done
+}
+
+init_register ports_init