From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Tremer To: development@lists.ipfire.org Subject: Re: [Patch RFC 11/15] network startup: Clean up duplicated Code Date: Wed, 24 May 2023 10:00:38 +0100 Message-ID: <669F43BF-2AF0-4842-BD7E-75C777F4F347@ipfire.org> In-Reply-To: <20230523172314.7826-12-jonatan.schlag@ipfire.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============7005705155757338323==" List-Id: --===============7005705155757338323== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable ??? > On 23 May 2023, at 18:23, Jonatan Schlag wrot= e: >=20 > This gives us more flexibilty for future changes. >=20 > Signed-off-by: Jonatan Schlag > --- > src/initscripts/system/network | 43 +++++++++++++--------------------- > 1 file changed, 16 insertions(+), 27 deletions(-) >=20 > diff --git a/src/initscripts/system/network b/src/initscripts/system/network > index 008fbbe2b..0db64eaad 100644 > --- a/src/initscripts/system/network > +++ b/src/initscripts/system/network > @@ -31,6 +31,13 @@ if ! [[ "${DO}" =3D=3D "start" || "${DO}" =3D=3D "resta= rt" || "${DO}" =3D=3D "stop" ]]; the > exit 1 > fi >=20 > +declare -a VALID_ZONES > + > +VALID_ZONES+=3D("blue") > +VALID_ZONES+=3D("green") > +VALID_ZONES+=3D("orange") > +VALID_ZONES+=3D("red") > + > declare -A ZONE_ACTION >=20 > ZONE_ACTION[blue]=3Dfalse > @@ -47,7 +54,7 @@ fi >=20 > while [ $# -ne 0 ]; do > ZONE_VALID=3Dfalse > - for i in green red blue orange; do > + for i in "${VALID_ZONES[@]}"; do > if [ "${i}" =3D=3D "${1}" ]; then > ZONE_ACTION[${i}]=3Dtrue > ZONE_VALID=3Dtrue > @@ -65,17 +72,9 @@ done > case "${DO}" in > start) > # Starting interfaces... > - # GREEN > - ${ZONE_ACTION[green]} && /etc/rc.d/init.d/networking/green start > - > - # BLUE > - ${ZONE_ACTION[blue]} && /etc/rc.d/init.d/networking/blue start > - > - # ORANGE > - ${ZONE_ACTION[orange]} && /etc/rc.d/init.d/networking/orange start > - > - # RED > - ${ZONE_ACTION[red]} && /etc/rc.d/init.d/networking/red start > + for i in "${VALID_ZONES[@]}"; do > + ${ZONE_ACTION[${i}]} && /etc/rc.d/init.d/networking/${i} start > + done >=20 > boot_mesg "Mounting network file systems..." > mount -a -O _netdev > @@ -88,26 +87,16 @@ case "${DO}" in > evaluate_retval >=20 > # Stopping interfaces... > - # GREEN > - ${ZONE_ACTION[green]} && /etc/rc.d/init.d/networking/green stop > - > - # BLUE > - ${ZONE_ACTION[blue]} && /etc/rc.d/init.d/networking/blue stop > - > - # ORANGE > - ${ZONE_ACTION[orange]} && /etc/rc.d/init.d/networking/orange stop > - > - # RED > - if ${ZONE_ACTION[red]}; then > - /etc/rc.d/init.d/networking/red stop > - fi > + for i in "${VALID_ZONES[@]}"; do > + ${ZONE_ACTION[${i}]} && /etc/rc.d/init.d/networking/${i} stop > + done >=20 > exit 0 > ;; >=20 > restart) > - for i in green red blue orange; do > - if {ZONE_ACTION[${i}]}; then > + for i in "${VALID_ZONES[@]}"; do > + if ${ZONE_ACTION[${i}]}; then > ARGS+=3D" ${i}" > fi > done > --=20 > 2.30.2 >=20 --===============7005705155757338323==--