]> git.ipfire.org Git - people/jschlag/ipfire-2.x.git/commitdiff
network startup: Only work with configured zones improve_network_startup
authorJonatan Schlag <jonatan.schlag@ipfire.org>
Sat, 19 Mar 2022 16:38:43 +0000 (16:38 +0000)
committerJonatan Schlag <jonatan.schlag@ipfire.org>
Sat, 2 Apr 2022 07:34:14 +0000 (07:34 +0000)
Otherwise the called script fails with an failure message.
This does not hurt but is ugly.
I also changed my mind about the wording here. Because we only have four
possible zones we could talk about valid zones. But I think it is easier
and more future proof to talk about what is configured on the system.

Should make further changes easier.

Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
src/initscripts/system/network

index ff305e4723360c4bdd6abe798a374223b6a343f6..ff58a12afa9bcec3becda42ba58aaa82ebb1f940 100644 (file)
@@ -31,34 +31,37 @@ if ! [[ "${DO}" == "start" ||  "${DO}" == "restart" || "${DO}" == "stop" ]]; the
                exit 1
 fi
 
-declare -a VALID_ZONES
+declare -a CONFIGURED_ZONES
 
-VALID_ZONES+=("blue")
-VALID_ZONES+=("green")
-VALID_ZONES+=("orange")
+for zone in blue green orange; do
+       if ! is_${zone}_used; then
+               CONFIGURED_ZONES+=("${zone}")
+       fi
+done
 
 # If we are called as /etc/init.d/network also red is a valid zone.
 # Otherwise we are called as /etc/init.d/network-local where red
 # is invalid.
 if [[ "$(basename $0)" == "network" ]]; then
-       VALID_ZONES+=("red")
+       CONFIGURED_ZONES+=("red")
 fi
 
 declare -A ZONE_ACTION
 
-for i in "${VALID_ZONES[@]}"; do
+for i in "${CONFIGURED_ZONES[@]}"; do
        ZONE_ACTION[${i}]=false
 done
 
 if [ $# -eq 0 ]; then
-       for i in "${VALID_ZONES[@]}"; do
-               ZONE_ACTION[${i}]=true
+       for zone in "${CONFIGURED_ZONES[@]}"; do
+               ZONE_ACTION[${zone}]=true
        done
 fi
 
+
 while [ $# -ne 0 ]; do
        ZONE_VALID=false
-       for i in "${VALID_ZONES[@]}"; do
+       for i in "${CONFIGURED_ZONES[@]}"; do
                if [ "${i}" == "${1}" ]; then
                        ZONE_ACTION[${i}]=true
                        ZONE_VALID=true
@@ -68,7 +71,7 @@ while [ $# -ne 0 ]; do
        done
 
        if ! ${ZONE_VALID}; then
-               echo "'${1}' is not a valid zone. Cannot go on."
+               echo "'${1}' is not configured on this system. Cannot go on."
                exit 1
        fi
 done
@@ -76,14 +79,14 @@ done
 case "${DO}" in
        start)
                # Starting interfaces...
-               for i in "${VALID_ZONES[@]}"; do
+               for i in "${CONFIGURED_ZONES[@]}"; do
                        ${ZONE_ACTION[${i}]} && /etc/rc.d/init.d/networking/${i} start
                done
                ;;
 
        stop)
                # Stopping interfaces...
-               for i in "${VALID_ZONES[@]}"; do
+               for i in "${CONFIGURED_ZONES[@]}"; do
                        ${ZONE_ACTION[${i}]} && /etc/rc.d/init.d/networking/${i} stop
                done
 
@@ -91,7 +94,7 @@ case "${DO}" in
                ;;
 
        restart)
-               for i in "${VALID_ZONES[@]}"; do
+               for i in "${CONFIGURED_ZONES[@]}"; do
                        if ${ZONE_ACTION[${i}]}; then
                                ARGS+=" ${i}"
                        fi