From 2ae0fb8da7283a13e331436f94f99fa7994f3781 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Fri, 23 Jul 2010 15:10:58 +0200 Subject: [PATCH] network: Automatically create all ethernet ports. --- functions.cli | 3 ++- functions.device | 31 ++++++++----------------------- functions.ports | 16 ++++++++++++++++ 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/functions.cli b/functions.cli index 9339a7bc..7986413e 100644 --- a/functions.cli +++ b/functions.cli @@ -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} } diff --git a/functions.device b/functions.device index 70346c4b..8ee7ca53 100644 --- a/functions.device +++ b/functions.device @@ -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} diff --git a/functions.ports b/functions.ports index d0d7dee6..6c59578d 100644 --- a/functions.ports +++ b/functions.ports @@ -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 -- 2.39.2