Hi,
this is the first try for a patch series which makes the startup of local and uplink networks independent. This resolves in the end #11502. It should further allow us to keep waiting for a DHCP lease, because at least our local networks are all up when we get to the red network. This might have some small quirks, even when my testing so far shows no problems. I still think it is now better to share result, then to wait any longer. As this touches quite important parts of our network stack, I might be a could idea to merge this in two stages. After the patch, titled "network startup: Clean up duplicated Code ", might be a good breaking point. But in the end, this is up to you. Please keep in mind, I only tested the full patch set:
Remove ipsec interface creation from network startup Remove Start/Stop links for client175 Use bash as shebang in network initscripts network initscripts: check if the zone in the current config exists network initscripts: Remove code for old zone scheme network scripts: remove check for AUTOCONNECT network startup: Reload routing informations for every interface network startup: Always cleanup before red gets started network startup: check for correct action at start network startup: Refactor how cmd args are processed network startup: Clean up duplicated Code network script: add extra scripts for action that depend on a network network startup: Add scripts for local and uplink network startup: Start local and uplink network independent network startup: Only work with configured zones
config/rootfiles/common/aarch64/initscripts | 31 +++-- config/rootfiles/common/riscv64/initscripts | 31 +++-- config/rootfiles/common/x86_64/initscripts | 31 +++-- lfs/initscripts | 36 +++--- src/initscripts/networking/any | 31 ++++- src/initscripts/networking/functions.network | 14 +- src/initscripts/networking/red | 5 +- .../networking/red.up/99-pakfire-update | 2 +- src/initscripts/system/depends-on-network | 40 ++++++ src/initscripts/system/network | 121 ++++++++---------- 10 files changed, 218 insertions(+), 124 deletions(-) create mode 100644 src/initscripts/system/depends-on-network
Looking forward to your feedback
Greetings Jonatan
This is called several times in the boot process. It also depends on connectivity to the internet. So there is no point in calling it here when we do not know if we even have an internet connection.
It is called in the ipsecctrl programm which is called in the start and shutdown process of red ( /etc/init.d/networking/red.down/10-ipsec and /etc/init.d/networking/red.up/50-ipsec).
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org --- src/initscripts/system/network | 3 --- 1 file changed, 3 deletions(-)
diff --git a/src/initscripts/system/network b/src/initscripts/system/network index 9ef3fb0d8..7e457edfa 100644 --- a/src/initscripts/system/network +++ b/src/initscripts/system/network @@ -70,9 +70,6 @@ case "${DO}" in fi fi
- # Create IPsec interfaces - /usr/local/bin/ipsec-interfaces - /etc/rc.d/init.d/static-routes start
boot_mesg "Mounting network file systems..."
Hello,
I disagree with this patch.
I generally would like the IPsec interfaces to be around all the time whenever that is possible.
Your patch changes that so that the interfaces only become available when RED connects. That might be late, or might never happen.
Other software expecting those interfaces being available might have a problem then.
What is the saving here? Calling one extra script?
-Michael
On 23 May 2023, at 18:23, Jonatan Schlag jonatan.schlag@ipfire.org wrote:
This is called several times in the boot process. It also depends on connectivity to the internet. So there is no point in calling it here when we do not know if we even have an internet connection.
It is called in the ipsecctrl programm which is called in the start and shutdown process of red ( /etc/init.d/networking/red.down/10-ipsec and /etc/init.d/networking/red.up/50-ipsec).
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org
src/initscripts/system/network | 3 --- 1 file changed, 3 deletions(-)
diff --git a/src/initscripts/system/network b/src/initscripts/system/network index 9ef3fb0d8..7e457edfa 100644 --- a/src/initscripts/system/network +++ b/src/initscripts/system/network @@ -70,9 +70,6 @@ case "${DO}" in fi fi
- # Create IPsec interfaces
- /usr/local/bin/ipsec-interfaces
/etc/rc.d/init.d/static-routes start
boot_mesg "Mounting network file systems..."
2.30.2
This was dropped a while ago
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org --- lfs/initscripts | 3 --- 1 file changed, 3 deletions(-)
diff --git a/lfs/initscripts b/lfs/initscripts index 19b79a474..e078632ab 100644 --- a/lfs/initscripts +++ b/lfs/initscripts @@ -98,7 +98,6 @@ $(TARGET) : ln -sf ../init.d/fcron /etc/rc.d/rc0.d/K08fcron ln -sf ../init.d/apache /etc/rc.d/rc0.d/K28apache ln -sf ../init.d/sshd /etc/rc.d/rc0.d/K30sshd - ln -sf ../init.d/client175 /etc/rc.d/rc0.d/K34client175 ln -sf ../init.d/setclock /etc/rc.d/rc0.d/K47setclock ln -sf ../init.d/cyrus-sasl /etc/rc.d/rc0.d/K49cyrus-sasl ln -sf ../init.d/vnstat /etc/rc.d/rc0.d/K51vnstat @@ -131,7 +130,6 @@ $(TARGET) : ln -sf ../init.d/sshd /etc/rc.d/rc3.d/S30sshd ln -sf ../init.d/apache /etc/rc.d/rc3.d/S32apache ln -sf ../init.d/fcron /etc/rc.d/rc3.d/S40fcron - ln -sf ../init.d/client175 /etc/rc.d/rc3.d/S66client175 ln -sf ../../sysconfig/rc.local /etc/rc.d/rc3.d/S98rc.local ln -sf ../init.d/sslh /etc/rc.d/rc3.d/S98sslh ln -sf ../init.d/imspetor /etc/rc.d/rc3.d/S99imspetor @@ -145,7 +143,6 @@ $(TARGET) : ln -sf ../init.d/fcron /etc/rc.d/rc6.d/K08fcron ln -sf ../init.d/apache /etc/rc.d/rc6.d/K28apache ln -sf ../init.d/sshd /etc/rc.d/rc6.d/K30sshd - ln -sf ../init.d/client175 /etc/rc.d/rc6.d/K34client175 ln -sf ../init.d/setclock /etc/rc.d/rc6.d/K47setclock ln -sf ../init.d/cyrus-sasl /etc/rc.d/rc6.d/K49cyrus-sasl ln -sf ../init.d/vnstat /etc/rc.d/rc6.d/K51vnstat
/bin/sh is a symlink to /bin/bash on ipfire systems. Using /bin/sh in the scripts as shebang hurts in two ways:
1. We use features which do not work with sh as shell. This is not really a problem but if we rely on features of a real bash we can state this clearly. 2. The syntay highlighting in vim does not work without a correct shebang. As I want and need correct syntax highlighting I propose to change the shebang.
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org --- src/initscripts/networking/any | 2 +- src/initscripts/networking/functions.network | 2 +- src/initscripts/networking/red | 2 +- src/initscripts/networking/red.up/99-pakfire-update | 2 +- src/initscripts/system/network | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/initscripts/networking/any b/src/initscripts/networking/any index 15197badb..dc4796e91 100644 --- a/src/initscripts/networking/any +++ b/src/initscripts/networking/any @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash ############################################################################### # # # IPFire.org - A linux based firewall # diff --git a/src/initscripts/networking/functions.network b/src/initscripts/networking/functions.network index 0e2e5009e..4c7ad51d4 100644 --- a/src/initscripts/networking/functions.network +++ b/src/initscripts/networking/functions.network @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash ############################################################################### # # # IPFire.org - A linux based firewall # diff --git a/src/initscripts/networking/red b/src/initscripts/networking/red index 16d48f3ac..8e41314b6 100644 --- a/src/initscripts/networking/red +++ b/src/initscripts/networking/red @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash ############################################################################### # # # IPFire.org - A linux based firewall # diff --git a/src/initscripts/networking/red.up/99-pakfire-update b/src/initscripts/networking/red.up/99-pakfire-update index 3cc79a107..56cee66aa 100644 --- a/src/initscripts/networking/red.up/99-pakfire-update +++ b/src/initscripts/networking/red.up/99-pakfire-update @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash
nice -n 10 /opt/pakfire/pakfire update >/dev/null 2>&1 &
diff --git a/src/initscripts/system/network b/src/initscripts/system/network index 7e457edfa..0d63b4e8b 100644 --- a/src/initscripts/system/network +++ b/src/initscripts/system/network @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash ############################################################################### # # # IPFire.org - A linux based firewall #
This should actually not change any behaviour of bash, but it does not break anything either.
On 23 May 2023, at 18:23, Jonatan Schlag jonatan.schlag@ipfire.org wrote:
/bin/sh is a symlink to /bin/bash on ipfire systems. Using /bin/sh in the scripts as shebang hurts in two ways:
- We use features which do not work with sh as shell. This is not
really a problem but if we rely on features of a real bash we can state this clearly. 2. The syntay highlighting in vim does not work without a correct shebang. As I want and need correct syntax highlighting I propose to change the shebang.
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org
src/initscripts/networking/any | 2 +- src/initscripts/networking/functions.network | 2 +- src/initscripts/networking/red | 2 +- src/initscripts/networking/red.up/99-pakfire-update | 2 +- src/initscripts/system/network | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/initscripts/networking/any b/src/initscripts/networking/any index 15197badb..dc4796e91 100644 --- a/src/initscripts/networking/any +++ b/src/initscripts/networking/any @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash ############################################################################### # # # IPFire.org - A linux based firewall # diff --git a/src/initscripts/networking/functions.network b/src/initscripts/networking/functions.network index 0e2e5009e..4c7ad51d4 100644 --- a/src/initscripts/networking/functions.network +++ b/src/initscripts/networking/functions.network @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash ############################################################################### # # # IPFire.org - A linux based firewall # diff --git a/src/initscripts/networking/red b/src/initscripts/networking/red index 16d48f3ac..8e41314b6 100644 --- a/src/initscripts/networking/red +++ b/src/initscripts/networking/red @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash ############################################################################### # # # IPFire.org - A linux based firewall # diff --git a/src/initscripts/networking/red.up/99-pakfire-update b/src/initscripts/networking/red.up/99-pakfire-update index 3cc79a107..56cee66aa 100644 --- a/src/initscripts/networking/red.up/99-pakfire-update +++ b/src/initscripts/networking/red.up/99-pakfire-update @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash
nice -n 10 /opt/pakfire/pakfire update >/dev/null 2>&1 &
diff --git a/src/initscripts/system/network b/src/initscripts/system/network index 7e457edfa..0d63b4e8b 100644 --- a/src/initscripts/system/network +++ b/src/initscripts/system/network @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash ############################################################################### # #
# IPFire.org - A linux based firewall #
2.30.2
We check in /etc/init.d/network if the current Configuration (RED+GREEN or RED+GREEN+BLUE) contains the zone we want to start or stop. We do this not in /etc/init.d/networking/green,blue,orange
As this checks make sense also there and as these scripts are called form /etc/init.d/network I moved the check to these scripts.
As CONFIG_TYPE == 2 is unreadable I wrote functions to make things at least a litte bit prettier.
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org --- src/initscripts/networking/any | 27 +++++++++++++++++--- src/initscripts/networking/functions.network | 12 +++++++++ src/initscripts/system/network | 16 ++++-------- 3 files changed, 41 insertions(+), 14 deletions(-)
diff --git a/src/initscripts/networking/any b/src/initscripts/networking/any index dc4796e91..6dba5bef9 100644 --- a/src/initscripts/networking/any +++ b/src/initscripts/networking/any @@ -21,23 +21,44 @@
. /etc/sysconfig/rc . ${rc_functions} +. /etc/init.d/networking/functions.network + eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
-if [ "$(basename $0)" == "green" ]; then +ZONE="$(basename $0)" + + +if [ "${ZONE}" == "green" ]; then + if ! is_green_used; then + boot_mesg "Green zone is not configured. No action can be taken on this zone." ${FAILURE} + echo_failure + exit 1 + fi + DEVICE="${GREEN_DEV}" ADDRESS="${GREEN_ADDRESS}" NETADDRESS="${GREEN_NETADDRESS}" NETMASK="${GREEN_NETMASK}" DEVICE="${GREEN_DEV}" MTU="${GREEN_MTU}" -elif [ "$(basename $0)" == "blue" ]; then +elif [ "${ZONE}" == "blue" ]; then + if ! is_blue_used; then + boot_mesg "Blue zone is not configured. No action can be taken on this zone." ${FAILURE} + echo_failure + exit 1 + fi DEVICE="${BLUE_DEV}" ADDRESS="${BLUE_ADDRESS}" NETADDRESS="${BLUE_NETADDRESS}" NETMASK="${BLUE_NETMASK}" DEVICE="${BLUE_DEV}" MTU="${BLUE_MTU}" -elif [ "$(basename $0)" == "orange" ]; then +elif [ "${ZONE}" == "orange" ]; then + if ! is_orange_used; then + boot_mesg "Orange zone is not configured. No action can be taken on this zone." ${FAILURE} + echo_failure + exit 1 + fi DEVICE="${ORANGE_DEV}" ADDRESS="${ORANGE_ADDRESS}" NETADDRESS="${ORANGE_NETADDRESS}" diff --git a/src/initscripts/networking/functions.network b/src/initscripts/networking/functions.network index 4c7ad51d4..9cc4da24b 100644 --- a/src/initscripts/networking/functions.network +++ b/src/initscripts/networking/functions.network @@ -285,3 +285,15 @@ qmi_assign_address() { # Change the MAC address ip link set "${intf}" address "${address}" } + +is_blue_used() { + [ "${CONFIG_TYPE}" = "3" ] || [ "${CONFIG_TYPE}" = "4" ] +} + +is_green_used() { + [ -n "${GREEN_DEV}" ] && [ -v "GREEN_DEV" ] +} + +is_orange_used() { + [ "${CONFIG_TYPE}" = "2" ] || [ "${CONFIG_TYPE}" = "4" ] +} diff --git a/src/initscripts/system/network b/src/initscripts/system/network index 0d63b4e8b..fda16919d 100644 --- a/src/initscripts/system/network +++ b/src/initscripts/system/network @@ -54,12 +54,10 @@ case "${DO}" in [ "$green" == "1" ] && /etc/rc.d/init.d/networking/green start
# BLUE - [ "$blue" == "1" ] && [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ] && \ - /etc/rc.d/init.d/networking/blue start + [ "$blue" == "1" ] && /etc/rc.d/init.d/networking/blue start
# ORANGE - [ "$orange" == "1" ] && [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "4" ] && \ - /etc/rc.d/init.d/networking/orange start + [ "$orange" == "1" ] && /etc/rc.d/init.d/networking/orange start
# RED if [ "$red" == "1" ]; then @@ -87,18 +85,14 @@ case "${DO}" in [ "$green" == "1" ] && /etc/rc.d/init.d/networking/green stop
# BLUE - [ "$blue" == "1" ] && [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ] && \ - /etc/rc.d/init.d/networking/blue stop + [ "$blue" == "1" ] && /etc/rc.d/init.d/networking/blue stop
# ORANGE - [ "$orange" == "1" ] && [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "4" ] && \ - /etc/rc.d/init.d/networking/orange stop + [ "$orange" == "1" ] && /etc/rc.d/init.d/networking/orange stop
# RED if [ "$red" == "1" ]; then - if [ "$CONFIG_TYPE" = "1" -o "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then - /etc/rc.d/init.d/networking/red stop - fi + /etc/rc.d/init.d/networking/red stop fi
exit 0
Hello,
If you want to make this script better, why not give the zone name as a parameter?
First of all it should be renamed to something like “local” (as in: not RED) and then you don’t have to use any symlinks and read back the script name like this:
ZONE="$(basename $0)”
Otherwise I agree with introducing unified functions that check whether we have GREEN/BLUE/ORANGE and have them in one function. We should then go through the entire code base and replace those calls first before we are introducing any new changes.
I would prefer to give those function a “network_” prefix so that it becomes clear where this function is from and ideally shorten “is used” to just “have”. Like so: network_have_BLUE() and network_have_ORANGE().
Can we do that instead?
-Michael
On 23 May 2023, at 18:23, Jonatan Schlag jonatan.schlag@ipfire.org wrote:
We check in /etc/init.d/network if the current Configuration (RED+GREEN or RED+GREEN+BLUE) contains the zone we want to start or stop. We do this not in /etc/init.d/networking/green,blue,orange
As this checks make sense also there and as these scripts are called form /etc/init.d/network I moved the check to these scripts.
As CONFIG_TYPE == 2 is unreadable I wrote functions to make things at least a litte bit prettier.
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org
src/initscripts/networking/any | 27 +++++++++++++++++--- src/initscripts/networking/functions.network | 12 +++++++++ src/initscripts/system/network | 16 ++++-------- 3 files changed, 41 insertions(+), 14 deletions(-)
diff --git a/src/initscripts/networking/any b/src/initscripts/networking/any index dc4796e91..6dba5bef9 100644 --- a/src/initscripts/networking/any +++ b/src/initscripts/networking/any @@ -21,23 +21,44 @@
. /etc/sysconfig/rc . ${rc_functions} +. /etc/init.d/networking/functions.network
eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
-if [ "$(basename $0)" == "green" ]; then +ZONE="$(basename $0)"
+if [ "${ZONE}" == "green" ]; then
- if ! is_green_used; then
- boot_mesg "Green zone is not configured. No action can be taken on this zone." ${FAILURE}
- echo_failure
- exit 1
- fi
DEVICE="${GREEN_DEV}" ADDRESS="${GREEN_ADDRESS}" NETADDRESS="${GREEN_NETADDRESS}" NETMASK="${GREEN_NETMASK}" DEVICE="${GREEN_DEV}" MTU="${GREEN_MTU}" -elif [ "$(basename $0)" == "blue" ]; then +elif [ "${ZONE}" == "blue" ]; then
- if ! is_blue_used; then
- boot_mesg "Blue zone is not configured. No action can be taken on this zone." ${FAILURE}
- echo_failure
- exit 1
- fi
DEVICE="${BLUE_DEV}" ADDRESS="${BLUE_ADDRESS}" NETADDRESS="${BLUE_NETADDRESS}" NETMASK="${BLUE_NETMASK}" DEVICE="${BLUE_DEV}" MTU="${BLUE_MTU}" -elif [ "$(basename $0)" == "orange" ]; then +elif [ "${ZONE}" == "orange" ]; then
- if ! is_orange_used; then
- boot_mesg "Orange zone is not configured. No action can be taken on this zone." ${FAILURE}
- echo_failure
- exit 1
- fi
DEVICE="${ORANGE_DEV}" ADDRESS="${ORANGE_ADDRESS}" NETADDRESS="${ORANGE_NETADDRESS}" diff --git a/src/initscripts/networking/functions.network b/src/initscripts/networking/functions.network index 4c7ad51d4..9cc4da24b 100644 --- a/src/initscripts/networking/functions.network +++ b/src/initscripts/networking/functions.network @@ -285,3 +285,15 @@ qmi_assign_address() { # Change the MAC address ip link set "${intf}" address "${address}" }
+is_blue_used() {
- [ "${CONFIG_TYPE}" = "3" ] || [ "${CONFIG_TYPE}" = "4" ]
+}
+is_green_used() {
- [ -n "${GREEN_DEV}" ] && [ -v "GREEN_DEV" ]
+}
+is_orange_used() {
- [ "${CONFIG_TYPE}" = "2" ] || [ "${CONFIG_TYPE}" = "4" ]
+} diff --git a/src/initscripts/system/network b/src/initscripts/system/network index 0d63b4e8b..fda16919d 100644 --- a/src/initscripts/system/network +++ b/src/initscripts/system/network @@ -54,12 +54,10 @@ case "${DO}" in [ "$green" == "1" ] && /etc/rc.d/init.d/networking/green start
# BLUE
- [ "$blue" == "1" ] && [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ] && \
- /etc/rc.d/init.d/networking/blue start
- [ "$blue" == "1" ] && /etc/rc.d/init.d/networking/blue start
# ORANGE
- [ "$orange" == "1" ] && [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "4" ] && \
- /etc/rc.d/init.d/networking/orange start
- [ "$orange" == "1" ] && /etc/rc.d/init.d/networking/orange start
# RED if [ "$red" == "1" ]; then @@ -87,18 +85,14 @@ case "${DO}" in [ "$green" == "1" ] && /etc/rc.d/init.d/networking/green stop
# BLUE
- [ "$blue" == "1" ] && [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ] && \
- /etc/rc.d/init.d/networking/blue stop
- [ "$blue" == "1" ] && /etc/rc.d/init.d/networking/blue stop
# ORANGE
- [ "$orange" == "1" ] && [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "4" ] && \
- /etc/rc.d/init.d/networking/orange stop
- [ "$orange" == "1" ] && /etc/rc.d/init.d/networking/orange stop
# RED if [ "$red" == "1" ]; then
- if [ "$CONFIG_TYPE" = "1" -o "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then
- /etc/rc.d/init.d/networking/red stop
- fi
- /etc/rc.d/init.d/networking/red stop
fi
exit 0
2.30.2
Hi list,
Am Mittwoch, dem 24.05.2023 um 10:00 +0100 schrieb Michael Tremer:
Hello,
If you want to make this script better, why not give the zone name as a parameter?
First of all it should be renamed to something like “local” (as in: not RED) and then you don’t have to use any symlinks and read back the script name like this:
ZONE="$(basename $0)”
I did not want to make such a big change, as people might rely on these files. But I am happy to create a script and delete the other scripts/links. I suggest as naming:
/etc/init.d/networking/local
Calling the script could look like:
For one Zone
/etc/init.d/networking/local start ${ZONE} /etc/init.d/networking/local stop ${ZONE}
For all Zones
/etc/init.d/networking/local start /etc/init.d/networking/local stop
Look this fine to you?
Otherwise I agree with introducing unified functions that check whether we have GREEN/BLUE/ORANGE and have them in one function. We should then go through the entire code base and replace those calls first before we are introducing any new changes.
Ok, fine by me.
I would prefer to give those function a “network_” prefix so that it becomes clear where this function is from and ideally shorten “is used” to just “have”. Like so: network_have_BLUE() and network_have_ORANGE().
Can we do that instead?
Yes, we can do that. I have only comments on the naming of the functions. I would like to reuse the naming style of the old ipfire-3.x networking code. So I would propose:
network_zone_exists(ZONE)
network_zones_get_all()
network_zones_get_local()
network_zones_get_nonlocal()
As we all agreed on this naming some time ago, I think it faster to use these names instead of inventing new ones.
Greetings Jonatan
-Michael
On 23 May 2023, at 18:23, Jonatan Schlag jonatan.schlag@ipfire.org wrote:
We check in /etc/init.d/network if the current Configuration (RED+GREEN or RED+GREEN+BLUE) contains the zone we want to start or stop. We do this not in /etc/init.d/networking/green,blue,orange
As this checks make sense also there and as these scripts are called form /etc/init.d/network I moved the check to these scripts.
As CONFIG_TYPE == 2 is unreadable I wrote functions to make things at least a litte bit prettier.
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org
src/initscripts/networking/any | 27 +++++++++++++++++--- src/initscripts/networking/functions.network | 12 +++++++++ src/initscripts/system/network | 16 ++++-------- 3 files changed, 41 insertions(+), 14 deletions(-)
diff --git a/src/initscripts/networking/any b/src/initscripts/networking/any index dc4796e91..6dba5bef9 100644 --- a/src/initscripts/networking/any +++ b/src/initscripts/networking/any @@ -21,23 +21,44 @@
. /etc/sysconfig/rc . ${rc_functions} +. /etc/init.d/networking/functions.network
eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
-if [ "$(basename $0)" == "green" ]; then +ZONE="$(basename $0)"
+if [ "${ZONE}" == "green" ]; then
- if ! is_green_used; then
- boot_mesg "Green zone is not configured. No action can be taken
on this zone." ${FAILURE}
- echo_failure
- exit 1
- fi
DEVICE="${GREEN_DEV}" ADDRESS="${GREEN_ADDRESS}" NETADDRESS="${GREEN_NETADDRESS}" NETMASK="${GREEN_NETMASK}" DEVICE="${GREEN_DEV}" MTU="${GREEN_MTU}" -elif [ "$(basename $0)" == "blue" ]; then +elif [ "${ZONE}" == "blue" ]; then
- if ! is_blue_used; then
- boot_mesg "Blue zone is not configured. No action can be taken on
this zone." ${FAILURE}
- echo_failure
- exit 1
- fi
DEVICE="${BLUE_DEV}" ADDRESS="${BLUE_ADDRESS}" NETADDRESS="${BLUE_NETADDRESS}" NETMASK="${BLUE_NETMASK}" DEVICE="${BLUE_DEV}" MTU="${BLUE_MTU}" -elif [ "$(basename $0)" == "orange" ]; then +elif [ "${ZONE}" == "orange" ]; then
- if ! is_orange_used; then
- boot_mesg "Orange zone is not configured. No action can be taken
on this zone." ${FAILURE}
- echo_failure
- exit 1
- fi
DEVICE="${ORANGE_DEV}" ADDRESS="${ORANGE_ADDRESS}" NETADDRESS="${ORANGE_NETADDRESS}" diff --git a/src/initscripts/networking/functions.network b/src/initscripts/networking/functions.network index 4c7ad51d4..9cc4da24b 100644 --- a/src/initscripts/networking/functions.network +++ b/src/initscripts/networking/functions.network @@ -285,3 +285,15 @@ qmi_assign_address() { # Change the MAC address ip link set "${intf}" address "${address}" }
+is_blue_used() {
- [ "${CONFIG_TYPE}" = "3" ] || [ "${CONFIG_TYPE}" = "4" ]
+}
+is_green_used() {
- [ -n "${GREEN_DEV}" ] && [ -v "GREEN_DEV" ]
+}
+is_orange_used() {
- [ "${CONFIG_TYPE}" = "2" ] || [ "${CONFIG_TYPE}" = "4" ]
+} diff --git a/src/initscripts/system/network b/src/initscripts/system/network index 0d63b4e8b..fda16919d 100644 --- a/src/initscripts/system/network +++ b/src/initscripts/system/network @@ -54,12 +54,10 @@ case "${DO}" in [ "$green" == "1" ] && /etc/rc.d/init.d/networking/green start
# BLUE
- [ "$blue" == "1" ] && [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" =
"4" ] && \
- /etc/rc.d/init.d/networking/blue start
- [ "$blue" == "1" ] && /etc/rc.d/init.d/networking/blue start
# ORANGE
- [ "$orange" == "1" ] && [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE"
= "4" ] && \
- /etc/rc.d/init.d/networking/orange start
- [ "$orange" == "1" ] && /etc/rc.d/init.d/networking/orange start
# RED if [ "$red" == "1" ]; then @@ -87,18 +85,14 @@ case "${DO}" in [ "$green" == "1" ] && /etc/rc.d/init.d/networking/green stop
# BLUE
- [ "$blue" == "1" ] && [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" =
"4" ] && \
- /etc/rc.d/init.d/networking/blue stop
- [ "$blue" == "1" ] && /etc/rc.d/init.d/networking/blue stop
# ORANGE
- [ "$orange" == "1" ] && [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE"
= "4" ] && \
- /etc/rc.d/init.d/networking/orange stop
- [ "$orange" == "1" ] && /etc/rc.d/init.d/networking/orange stop
# RED if [ "$red" == "1" ]; then
- if [ "$CONFIG_TYPE" = "1" -o "$CONFIG_TYPE" = "2" -o
"$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then
- /etc/rc.d/init.d/networking/red stop
- fi
- /etc/rc.d/init.d/networking/red stop
fi
exit 0
2.30.2
Hello,
On 18 Aug 2023, at 13:55, Jonatan Schlag jonatan.schlag@ipfire.org wrote:
Hi list,
Am Mittwoch, dem 24.05.2023 um 10:00 +0100 schrieb Michael Tremer:
Hello,
If you want to make this script better, why not give the zone name as a parameter?
First of all it should be renamed to something like “local” (as in: not RED) and then you don’t have to use any symlinks and read back the script name like this:
ZONE="$(basename $0)”
I did not want to make such a big change, as people might rely on these files. But I am happy to create a script and delete the other scripts/links. I suggest as naming:
/etc/init.d/networking/local
Calling the script could look like:
For one Zone
/etc/init.d/networking/local start ${ZONE} /etc/init.d/networking/local stop ${ZONE}
For all Zones
/etc/init.d/networking/local start /etc/init.d/networking/local stop
Look this fine to you?
This looks good to me.
Otherwise I agree with introducing unified functions that check whether we have GREEN/BLUE/ORANGE and have them in one function. We should then go through the entire code base and replace those calls first before we are introducing any new changes.
Ok, fine by me.
I would prefer to give those function a “network_” prefix so that it becomes clear where this function is from and ideally shorten “is used” to just “have”. Like so: network_have_BLUE() and network_have_ORANGE().
Can we do that instead?
Yes, we can do that. I have only comments on the naming of the functions. I would like to reuse the naming style of the old ipfire-3.x networking code. So I would propose:
network_zone_exists(ZONE)
network_zones_get_all()
network_zones_get_local()
network_zones_get_nonlocal()
As we all agreed on this naming some time ago, I think it faster to use these names instead of inventing new ones.
Also okay for me.
Best, -Michael
Greetings Jonatan
-Michael
On 23 May 2023, at 18:23, Jonatan Schlag jonatan.schlag@ipfire.org wrote:
We check in /etc/init.d/network if the current Configuration (RED+GREEN or RED+GREEN+BLUE) contains the zone we want to start or stop. We do this not in /etc/init.d/networking/green,blue,orange
As this checks make sense also there and as these scripts are called form /etc/init.d/network I moved the check to these scripts.
As CONFIG_TYPE == 2 is unreadable I wrote functions to make things at least a litte bit prettier.
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org
src/initscripts/networking/any | 27 +++++++++++++++++--- src/initscripts/networking/functions.network | 12 +++++++++ src/initscripts/system/network | 16 ++++-------- 3 files changed, 41 insertions(+), 14 deletions(-)
diff --git a/src/initscripts/networking/any b/src/initscripts/networking/any index dc4796e91..6dba5bef9 100644 --- a/src/initscripts/networking/any +++ b/src/initscripts/networking/any @@ -21,23 +21,44 @@
. /etc/sysconfig/rc . ${rc_functions} +. /etc/init.d/networking/functions.network
eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
-if [ "$(basename $0)" == "green" ]; then +ZONE="$(basename $0)"
+if [ "${ZONE}" == "green" ]; then
- if ! is_green_used; then
- boot_mesg "Green zone is not configured. No action can be taken
on this zone." ${FAILURE}
- echo_failure
- exit 1
- fi
DEVICE="${GREEN_DEV}" ADDRESS="${GREEN_ADDRESS}" NETADDRESS="${GREEN_NETADDRESS}" NETMASK="${GREEN_NETMASK}" DEVICE="${GREEN_DEV}" MTU="${GREEN_MTU}" -elif [ "$(basename $0)" == "blue" ]; then +elif [ "${ZONE}" == "blue" ]; then
- if ! is_blue_used; then
- boot_mesg "Blue zone is not configured. No action can be taken on
this zone." ${FAILURE}
- echo_failure
- exit 1
- fi
DEVICE="${BLUE_DEV}" ADDRESS="${BLUE_ADDRESS}" NETADDRESS="${BLUE_NETADDRESS}" NETMASK="${BLUE_NETMASK}" DEVICE="${BLUE_DEV}" MTU="${BLUE_MTU}" -elif [ "$(basename $0)" == "orange" ]; then +elif [ "${ZONE}" == "orange" ]; then
- if ! is_orange_used; then
- boot_mesg "Orange zone is not configured. No action can be taken
on this zone." ${FAILURE}
- echo_failure
- exit 1
- fi
DEVICE="${ORANGE_DEV}" ADDRESS="${ORANGE_ADDRESS}" NETADDRESS="${ORANGE_NETADDRESS}" diff --git a/src/initscripts/networking/functions.network b/src/initscripts/networking/functions.network index 4c7ad51d4..9cc4da24b 100644 --- a/src/initscripts/networking/functions.network +++ b/src/initscripts/networking/functions.network @@ -285,3 +285,15 @@ qmi_assign_address() { # Change the MAC address ip link set "${intf}" address "${address}" }
+is_blue_used() {
- [ "${CONFIG_TYPE}" = "3" ] || [ "${CONFIG_TYPE}" = "4" ]
+}
+is_green_used() {
- [ -n "${GREEN_DEV}" ] && [ -v "GREEN_DEV" ]
+}
+is_orange_used() {
- [ "${CONFIG_TYPE}" = "2" ] || [ "${CONFIG_TYPE}" = "4" ]
+} diff --git a/src/initscripts/system/network b/src/initscripts/system/network index 0d63b4e8b..fda16919d 100644 --- a/src/initscripts/system/network +++ b/src/initscripts/system/network @@ -54,12 +54,10 @@ case "${DO}" in [ "$green" == "1" ] && /etc/rc.d/init.d/networking/green start
# BLUE
- [ "$blue" == "1" ] && [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" =
"4" ] && \
- /etc/rc.d/init.d/networking/blue start
- [ "$blue" == "1" ] && /etc/rc.d/init.d/networking/blue start
# ORANGE
- [ "$orange" == "1" ] && [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE"
= "4" ] && \
- /etc/rc.d/init.d/networking/orange start
- [ "$orange" == "1" ] && /etc/rc.d/init.d/networking/orange start
# RED if [ "$red" == "1" ]; then @@ -87,18 +85,14 @@ case "${DO}" in [ "$green" == "1" ] && /etc/rc.d/init.d/networking/green stop
# BLUE
- [ "$blue" == "1" ] && [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" =
"4" ] && \
- /etc/rc.d/init.d/networking/blue stop
- [ "$blue" == "1" ] && /etc/rc.d/init.d/networking/blue stop
# ORANGE
- [ "$orange" == "1" ] && [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE"
= "4" ] && \
- /etc/rc.d/init.d/networking/orange stop
- [ "$orange" == "1" ] && /etc/rc.d/init.d/networking/orange stop
# RED if [ "$red" == "1" ]; then
- if [ "$CONFIG_TYPE" = "1" -o "$CONFIG_TYPE" = "2" -o
"$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then
- /etc/rc.d/init.d/networking/red stop
- fi
- /etc/rc.d/init.d/networking/red stop
fi
exit 0
2.30.2
A long time ago (2007) there were more config types possible then 1, 2, 3 and 4. As our installer currently only accepts config type out of the set 1, 2, 3 and 4 we do not need to check if our CONFIG_TYPE is in this set.
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org --- src/initscripts/system/network | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/src/initscripts/system/network b/src/initscripts/system/network index fda16919d..146b3fda8 100644 --- a/src/initscripts/system/network +++ b/src/initscripts/system/network @@ -61,11 +61,9 @@ case "${DO}" in
# RED if [ "$red" == "1" ]; then - if [ "$CONFIG_TYPE" = "1" -o "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then - # Remove possible leftover files - rm -f /var/ipfire/red/{active,device,dial-on-demand,dns1,dns2,local-ipaddress,remote-ipaddress,resolv.conf} - [ "$AUTOCONNECT" == "off" ] || /etc/rc.d/init.d/networking/red start - fi + # Remove possible leftover files + rm -f /var/ipfire/red/{active,device,dial-on-demand,dns1,dns2,local-ipaddress,remote-ipaddress,resolv.conf} + [ "$AUTOCONNECT" == "off" ] || /etc/rc.d/init.d/networking/red start fi
/etc/rc.d/init.d/static-routes start
I believe the intention here was to be more extensible for more zones. This obviously never happened.
So I am happy with dropping the check.
We might only be left with some confusing behaviour if CONFIG_TYPE isn’t set at all. But that should break the system anyways.
On 23 May 2023, at 18:23, Jonatan Schlag jonatan.schlag@ipfire.org wrote:
A long time ago (2007) there were more config types possible then 1, 2, 3 and 4. As our installer currently only accepts config type out of the set 1, 2, 3 and 4 we do not need to check if our CONFIG_TYPE is in this set.
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org
src/initscripts/system/network | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/src/initscripts/system/network b/src/initscripts/system/network index fda16919d..146b3fda8 100644 --- a/src/initscripts/system/network +++ b/src/initscripts/system/network @@ -61,11 +61,9 @@ case "${DO}" in
# RED if [ "$red" == "1" ]; then
- if [ "$CONFIG_TYPE" = "1" -o "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then
- # Remove possible leftover files
- rm -f /var/ipfire/red/{active,device,dial-on-demand,dns1,dns2,local-ipaddress,remote-ipaddress,resolv.conf}
- [ "$AUTOCONNECT" == "off" ] || /etc/rc.d/init.d/networking/red start
- fi
- # Remove possible leftover files
- rm -f /var/ipfire/red/{active,device,dial-on-demand,dns1,dns2,local-ipaddress,remote-ipaddress,resolv.conf}
- [ "$AUTOCONNECT" == "off" ] || /etc/rc.d/init.d/networking/red start
fi
/etc/rc.d/init.d/static-routes start
2.30.2
This setting is also old (2007) and cannot be set via the webinterface anymore. So why checking for something, which can only be true.
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org --- src/initscripts/system/network | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/initscripts/system/network b/src/initscripts/system/network index 146b3fda8..6a47456f3 100644 --- a/src/initscripts/system/network +++ b/src/initscripts/system/network @@ -63,7 +63,7 @@ case "${DO}" in if [ "$red" == "1" ]; then # Remove possible leftover files rm -f /var/ipfire/red/{active,device,dial-on-demand,dns1,dns2,local-ipaddress,remote-ipaddress,resolv.conf} - [ "$AUTOCONNECT" == "off" ] || /etc/rc.d/init.d/networking/red start + /etc/rc.d/init.d/networking/red start fi
/etc/rc.d/init.d/static-routes start
True, we no longer support dial-on-demand.
On 23 May 2023, at 18:23, Jonatan Schlag jonatan.schlag@ipfire.org wrote:
This setting is also old (2007) and cannot be set via the webinterface anymore. So why checking for something, which can only be true.
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org
src/initscripts/system/network | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/initscripts/system/network b/src/initscripts/system/network index 146b3fda8..6a47456f3 100644 --- a/src/initscripts/system/network +++ b/src/initscripts/system/network @@ -63,7 +63,7 @@ case "${DO}" in if [ "$red" == "1" ]; then # Remove possible leftover files rm -f /var/ipfire/red/{active,device,dial-on-demand,dns1,dns2,local-ipaddress,remote-ipaddress,resolv.conf}
- [ "$AUTOCONNECT" == "off" ] || /etc/rc.d/init.d/networking/red start
- /etc/rc.d/init.d/networking/red start
fi
/etc/rc.d/init.d/static-routes start
2.30.2
This reload can and needs to be done when an interface is started. Not only when all interfaces are started.
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org --- src/initscripts/networking/any | 2 ++ src/initscripts/system/network | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/initscripts/networking/any b/src/initscripts/networking/any index 6dba5bef9..ec1321ad9 100644 --- a/src/initscripts/networking/any +++ b/src/initscripts/networking/any @@ -109,6 +109,8 @@ case "${1}" in ip addr add ${args} dev ${DEVICE} evaluate_retval fi + + /etc/rc.d/init.d/static-routes reload ;;
stop) diff --git a/src/initscripts/system/network b/src/initscripts/system/network index 6a47456f3..b346d487c 100644 --- a/src/initscripts/system/network +++ b/src/initscripts/system/network @@ -66,8 +66,6 @@ case "${DO}" in /etc/rc.d/init.d/networking/red start fi
- /etc/rc.d/init.d/static-routes start - boot_mesg "Mounting network file systems..." mount -a -O _netdev evaluate_retval
This assumption is incorrect.
You could have a route that points somewhere else if a certain interface is not available (e.g. VPNs).
This is probably bad network design, but I suppose that we did support this before.
On 23 May 2023, at 18:23, Jonatan Schlag jonatan.schlag@ipfire.org wrote:
This reload can and needs to be done when an interface is started. Not only when all interfaces are started.
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org
src/initscripts/networking/any | 2 ++ src/initscripts/system/network | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/initscripts/networking/any b/src/initscripts/networking/any index 6dba5bef9..ec1321ad9 100644 --- a/src/initscripts/networking/any +++ b/src/initscripts/networking/any @@ -109,6 +109,8 @@ case "${1}" in ip addr add ${args} dev ${DEVICE} evaluate_retval fi
- /etc/rc.d/init.d/static-routes reload
;;
stop) diff --git a/src/initscripts/system/network b/src/initscripts/system/network index 6a47456f3..b346d487c 100644 --- a/src/initscripts/system/network +++ b/src/initscripts/system/network @@ -66,8 +66,6 @@ case "${DO}" in /etc/rc.d/init.d/networking/red start fi
- /etc/rc.d/init.d/static-routes start
boot_mesg "Mounting network file systems..." mount -a -O _netdev evaluate_retval -- 2.30.2
There is no sense in doing this only in /etc/init.d/network and not in /etc/init.d/networking/red
This files should be always deleted before a startup
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org --- src/initscripts/networking/red | 3 +++ src/initscripts/system/network | 6 +----- 2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/src/initscripts/networking/red b/src/initscripts/networking/red index 8e41314b6..3873974ea 100644 --- a/src/initscripts/networking/red +++ b/src/initscripts/networking/red @@ -80,6 +80,9 @@ fi
case "${1}" in start) + # Remove possible leftover files + rm -f /var/ipfire/red/{active,device,dial-on-demand,dns1,dns2,local-ipaddress,remote-ipaddress,resolv.conf} + if [ "${DEVICE}" != "${GREEN_DEV}" ] && [ "${DEVICE}" != "" ]; then boot_mesg "Bringing up the ${DEVICE} interface..." boot_mesg_flush diff --git a/src/initscripts/system/network b/src/initscripts/system/network index b346d487c..9694165f2 100644 --- a/src/initscripts/system/network +++ b/src/initscripts/system/network @@ -60,11 +60,7 @@ case "${DO}" in [ "$orange" == "1" ] && /etc/rc.d/init.d/networking/orange start
# RED - if [ "$red" == "1" ]; then - # Remove possible leftover files - rm -f /var/ipfire/red/{active,device,dial-on-demand,dns1,dns2,local-ipaddress,remote-ipaddress,resolv.conf} - /etc/rc.d/init.d/networking/red start - fi + [ "$red" == "1" ] && /etc/rc.d/init.d/networking/red start
boot_mesg "Mounting network file systems..." mount -a -O _netdev
Agreed. Stuff for RED should be in its own script.
On 23 May 2023, at 18:23, Jonatan Schlag jonatan.schlag@ipfire.org wrote:
There is no sense in doing this only in /etc/init.d/network and not in /etc/init.d/networking/red
This files should be always deleted before a startup
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org
src/initscripts/networking/red | 3 +++ src/initscripts/system/network | 6 +----- 2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/src/initscripts/networking/red b/src/initscripts/networking/red index 8e41314b6..3873974ea 100644 --- a/src/initscripts/networking/red +++ b/src/initscripts/networking/red @@ -80,6 +80,9 @@ fi
case "${1}" in start)
- # Remove possible leftover files
- rm -f /var/ipfire/red/{active,device,dial-on-demand,dns1,dns2,local-ipaddress,remote-ipaddress,resolv.conf}
if [ "${DEVICE}" != "${GREEN_DEV}" ] && [ "${DEVICE}" != "" ]; then boot_mesg "Bringing up the ${DEVICE} interface..." boot_mesg_flush diff --git a/src/initscripts/system/network b/src/initscripts/system/network index b346d487c..9694165f2 100644 --- a/src/initscripts/system/network +++ b/src/initscripts/system/network @@ -60,11 +60,7 @@ case "${DO}" in [ "$orange" == "1" ] && /etc/rc.d/init.d/networking/orange start
# RED
- if [ "$red" == "1" ]; then
- # Remove possible leftover files
- rm -f /var/ipfire/red/{active,device,dial-on-demand,dns1,dns2,local-ipaddress,remote-ipaddress,resolv.conf}
- /etc/rc.d/init.d/networking/red start
- fi
- [ "$red" == "1" ] && /etc/rc.d/init.d/networking/red start
boot_mesg "Mounting network file systems..." mount -a -O _netdev -- 2.30.2
If we check this at the end, we already do some calculation in the next line. For example checking if the devices are correct. This is not necessary as we can already stop when we get an "stoop" or something like:
/etc/init.d/network green stop
This currently ends in an infinite loop, which gets fixed by this change.
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org --- src/initscripts/system/network | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/initscripts/system/network b/src/initscripts/system/network index 9694165f2..06240f53c 100644 --- a/src/initscripts/system/network +++ b/src/initscripts/system/network @@ -26,6 +26,11 @@ eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings) DO="${1}" shift
+if ! [[ "${DO}" == "start" || "${DO}" == "restart" || "${DO}" == "stop" ]]; then + echo "Usage: ${0} {start|stop|restart} [device(s)]" + exit 1 +fi + if [ -n "${1}" ]; then ALL=0 for i in green red blue orange; do @@ -100,9 +105,4 @@ case "${DO}" in sleep 1 ${0} start ${ARGS} ;; - - *) - echo "Usage: ${0} {start|stop|restart} [device(s)]" - exit 1 - ;; esac
How can calling “exit 1” result in an infinite loop?
That rather suggests that we are never getting to that part of the code. Should we not rather fix this?
Having a catchall at the end of a script is a standard pattern and keeps the script easier to extend if new options are being added because you cannot forget to add them to the top?
-Michael
On 23 May 2023, at 18:23, Jonatan Schlag jonatan.schlag@ipfire.org wrote:
If we check this at the end, we already do some calculation in the next line. For example checking if the devices are correct. This is not necessary as we can already stop when we get an "stoop" or something like:
/etc/init.d/network green stop
This currently ends in an infinite loop, which gets fixed by this change.
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org
src/initscripts/system/network | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/initscripts/system/network b/src/initscripts/system/network index 9694165f2..06240f53c 100644 --- a/src/initscripts/system/network +++ b/src/initscripts/system/network @@ -26,6 +26,11 @@ eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings) DO="${1}" shift
+if ! [[ "${DO}" == "start" || "${DO}" == "restart" || "${DO}" == "stop" ]]; then
- echo "Usage: ${0} {start|stop|restart} [device(s)]"
- exit 1
+fi
if [ -n "${1}" ]; then ALL=0 for i in green red blue orange; do @@ -100,9 +105,4 @@ case "${DO}" in sleep 1 ${0} start ${ARGS} ;;
- *)
- echo "Usage: ${0} {start|stop|restart} [device(s)]"
- exit 1
- ;;
esac
2.30.2
Hi,
yes, we never get to this piece of code:
while [ ! $# = 0 ]; do for i in green red blue orange; do if [ "${i}" == "${1}" ]; then eval "${i}=1" shift fi done done
This loop never ends, as ["${i}" == "${1}" ]; never evaluates to true for $1="stop". So we would actually want to do check here if $1 is a valid zone. So this has to wait until we have something like "network_zone_exists()".
Greetings Jonatan
Am Mittwoch, dem 24.05.2023 um 10:00 +0100 schrieb Michael Tremer:
How can calling “exit 1” result in an infinite loop?
That rather suggests that we are never getting to that part of the code. Should we not rather fix this?
Having a catchall at the end of a script is a standard pattern and keeps the script easier to extend if new options are being added because you cannot forget to add them to the top?
-Michael
On 23 May 2023, at 18:23, Jonatan Schlag jonatan.schlag@ipfire.org wrote:
If we check this at the end, we already do some calculation in the next line. For example checking if the devices are correct. This is not necessary as we can already stop when we get an "stoop" or something like:
/etc/init.d/network green stop
This currently ends in an infinite loop, which gets fixed by this change.
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org
src/initscripts/system/network | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/initscripts/system/network b/src/initscripts/system/network index 9694165f2..06240f53c 100644 --- a/src/initscripts/system/network +++ b/src/initscripts/system/network @@ -26,6 +26,11 @@ eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings) DO="${1}" shift
+if ! [[ "${DO}" == "start" || "${DO}" == "restart" || "${DO}" == "stop" ]]; then
- echo "Usage: ${0} {start|stop|restart} [device(s)]"
- exit 1
+fi
if [ -n "${1}" ]; then ALL=0 for i in green red blue orange; do @@ -100,9 +105,4 @@ case "${DO}" in sleep 1 ${0} start ${ARGS} ;;
- *)
- echo "Usage: ${0} {start|stop|restart} [device(s)]"
- exit 1
- ;;
esac
2.30.2
This avoids eval and all other sorts of things. We also now exit when we get an invalid zone name.
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org --- src/initscripts/system/network | 52 ++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 21 deletions(-)
diff --git a/src/initscripts/system/network b/src/initscripts/system/network index 06240f53c..008fbbe2b 100644 --- a/src/initscripts/system/network +++ b/src/initscripts/system/network @@ -31,41 +31,51 @@ if ! [[ "${DO}" == "start" || "${DO}" == "restart" || "${DO}" == "stop" ]]; the exit 1 fi
-if [ -n "${1}" ]; then - ALL=0 - for i in green red blue orange; do - eval "${i}=0" - done -else - ALL=1 - for i in green red blue orange; do - eval "${i}=1" - done +declare -A ZONE_ACTION + +ZONE_ACTION[blue]=false +ZONE_ACTION[green]=false +ZONE_ACTION[orange]=false +ZONE_ACTION[red]=false + +if [ $# -eq 0 ]; then + ZONE_ACTION[blue]=true + ZONE_ACTION[green]=true + ZONE_ACTION[orange]=true + ZONE_ACTION[red]=true fi
-while [ ! $# = 0 ]; do +while [ $# -ne 0 ]; do + ZONE_VALID=false for i in green red blue orange; do if [ "${i}" == "${1}" ]; then - eval "${i}=1" + ZONE_ACTION[${i}]=true + ZONE_VALID=true shift + break fi done + + if ! ${ZONE_VALID}; then + echo "'${1}' is not a valid zone. Cannot go on." + exit 1 + fi done
case "${DO}" in start) # Starting interfaces... # GREEN - [ "$green" == "1" ] && /etc/rc.d/init.d/networking/green start + ${ZONE_ACTION[green]} && /etc/rc.d/init.d/networking/green start
# BLUE - [ "$blue" == "1" ] && /etc/rc.d/init.d/networking/blue start + ${ZONE_ACTION[blue]} && /etc/rc.d/init.d/networking/blue start
# ORANGE - [ "$orange" == "1" ] && /etc/rc.d/init.d/networking/orange start + ${ZONE_ACTION[orange]} && /etc/rc.d/init.d/networking/orange start
# RED - [ "$red" == "1" ] && /etc/rc.d/init.d/networking/red start + ${ZONE_ACTION[red]} && /etc/rc.d/init.d/networking/red start
boot_mesg "Mounting network file systems..." mount -a -O _netdev @@ -79,16 +89,16 @@ case "${DO}" in
# Stopping interfaces... # GREEN - [ "$green" == "1" ] && /etc/rc.d/init.d/networking/green stop + ${ZONE_ACTION[green]} && /etc/rc.d/init.d/networking/green stop
# BLUE - [ "$blue" == "1" ] && /etc/rc.d/init.d/networking/blue stop + ${ZONE_ACTION[blue]} && /etc/rc.d/init.d/networking/blue stop
# ORANGE - [ "$orange" == "1" ] && /etc/rc.d/init.d/networking/orange stop + ${ZONE_ACTION[orange]} && /etc/rc.d/init.d/networking/orange stop
# RED - if [ "$red" == "1" ]; then + if ${ZONE_ACTION[red]}; then /etc/rc.d/init.d/networking/red stop fi
@@ -97,7 +107,7 @@ case "${DO}" in
restart) for i in green red blue orange; do - if [ "${!i}" == "1" ]; then + if {ZONE_ACTION[${i}]}; then ARGS+=" ${i}" fi done
Phew, this has already been a rubbish script.
One option could have been using “printf -v” to get rid of the eval call.
Otherwise, I fail to see the improvement here? It is just a different way to write this?!
Since you have introduced new functions to check whether a certain zone is available, why no just call those functions like this:
if network_has_BLUE; then /etc/init.d/networking/local BLUE start fi
-Michael
On 23 May 2023, at 18:23, Jonatan Schlag jonatan.schlag@ipfire.org wrote:
This avoids eval and all other sorts of things. We also now exit when we get an invalid zone name.
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org
src/initscripts/system/network | 52 ++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 21 deletions(-)
diff --git a/src/initscripts/system/network b/src/initscripts/system/network index 06240f53c..008fbbe2b 100644 --- a/src/initscripts/system/network +++ b/src/initscripts/system/network @@ -31,41 +31,51 @@ if ! [[ "${DO}" == "start" || "${DO}" == "restart" || "${DO}" == "stop" ]]; the exit 1 fi
-if [ -n "${1}" ]; then
- ALL=0
- for i in green red blue orange; do
- eval "${i}=0"
- done
-else
- ALL=1
- for i in green red blue orange; do
- eval "${i}=1"
- done
+declare -A ZONE_ACTION
+ZONE_ACTION[blue]=false +ZONE_ACTION[green]=false +ZONE_ACTION[orange]=false +ZONE_ACTION[red]=false
+if [ $# -eq 0 ]; then
- ZONE_ACTION[blue]=true
- ZONE_ACTION[green]=true
- ZONE_ACTION[orange]=true
- ZONE_ACTION[red]=true
fi
-while [ ! $# = 0 ]; do +while [ $# -ne 0 ]; do
- ZONE_VALID=false
for i in green red blue orange; do if [ "${i}" == "${1}" ]; then
- eval "${i}=1"
- ZONE_ACTION[${i}]=true
- ZONE_VALID=true
shift
- break
fi done
- if ! ${ZONE_VALID}; then
- echo "'${1}' is not a valid zone. Cannot go on."
- exit 1
- fi
done
case "${DO}" in start) # Starting interfaces... # GREEN
- [ "$green" == "1" ] && /etc/rc.d/init.d/networking/green start
- ${ZONE_ACTION[green]} && /etc/rc.d/init.d/networking/green start
# BLUE
- [ "$blue" == "1" ] && /etc/rc.d/init.d/networking/blue start
- ${ZONE_ACTION[blue]} && /etc/rc.d/init.d/networking/blue start
# ORANGE
- [ "$orange" == "1" ] && /etc/rc.d/init.d/networking/orange start
- ${ZONE_ACTION[orange]} && /etc/rc.d/init.d/networking/orange start
# RED
- [ "$red" == "1" ] && /etc/rc.d/init.d/networking/red start
- ${ZONE_ACTION[red]} && /etc/rc.d/init.d/networking/red start
boot_mesg "Mounting network file systems..." mount -a -O _netdev @@ -79,16 +89,16 @@ case "${DO}" in
# Stopping interfaces... # GREEN
- [ "$green" == "1" ] && /etc/rc.d/init.d/networking/green stop
- ${ZONE_ACTION[green]} && /etc/rc.d/init.d/networking/green stop
# BLUE
- [ "$blue" == "1" ] && /etc/rc.d/init.d/networking/blue stop
- ${ZONE_ACTION[blue]} && /etc/rc.d/init.d/networking/blue stop
# ORANGE
- [ "$orange" == "1" ] && /etc/rc.d/init.d/networking/orange stop
- ${ZONE_ACTION[orange]} && /etc/rc.d/init.d/networking/orange stop
# RED
- if [ "$red" == "1" ]; then
- if ${ZONE_ACTION[red]}; then
/etc/rc.d/init.d/networking/red stop fi
@@ -97,7 +107,7 @@ case "${DO}" in
restart) for i in green red blue orange; do
- if [ "${!i}" == "1" ]; then
- if {ZONE_ACTION[${i}]}; then
ARGS+=" ${i}" fi done -- 2.30.2
This gives us more flexibilty for future changes.
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org --- src/initscripts/system/network | 43 +++++++++++++--------------------- 1 file changed, 16 insertions(+), 27 deletions(-)
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}" == "start" || "${DO}" == "restart" || "${DO}" == "stop" ]]; the exit 1 fi
+declare -a VALID_ZONES + +VALID_ZONES+=("blue") +VALID_ZONES+=("green") +VALID_ZONES+=("orange") +VALID_ZONES+=("red") + declare -A ZONE_ACTION
ZONE_ACTION[blue]=false @@ -47,7 +54,7 @@ fi
while [ $# -ne 0 ]; do ZONE_VALID=false - for i in green red blue orange; do + for i in "${VALID_ZONES[@]}"; do if [ "${i}" == "${1}" ]; then ZONE_ACTION[${i}]=true ZONE_VALID=true @@ -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
boot_mesg "Mounting network file systems..." mount -a -O _netdev @@ -88,26 +87,16 @@ case "${DO}" in evaluate_retval
# 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
exit 0 ;;
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+=" ${i}" fi done
???
On 23 May 2023, at 18:23, Jonatan Schlag jonatan.schlag@ipfire.org wrote:
This gives us more flexibilty for future changes.
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org
src/initscripts/system/network | 43 +++++++++++++--------------------- 1 file changed, 16 insertions(+), 27 deletions(-)
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}" == "start" || "${DO}" == "restart" || "${DO}" == "stop" ]]; the exit 1 fi
+declare -a VALID_ZONES
+VALID_ZONES+=("blue") +VALID_ZONES+=("green") +VALID_ZONES+=("orange") +VALID_ZONES+=("red")
declare -A ZONE_ACTION
ZONE_ACTION[blue]=false @@ -47,7 +54,7 @@ fi
while [ $# -ne 0 ]; do ZONE_VALID=false
- for i in green red blue orange; do
- for i in "${VALID_ZONES[@]}"; do
if [ "${i}" == "${1}" ]; then ZONE_ACTION[${i}]=true ZONE_VALID=true @@ -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
boot_mesg "Mounting network file systems..." mount -a -O _netdev @@ -88,26 +87,16 @@ case "${DO}" in evaluate_retval
# 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
exit 0 ;;
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+=" ${i}" fi done -- 2.30.2
This allows us to split the network startup further up into seperate scripts. The mount of the network filesystems is now done after the startup of the network, but can be delayed further when the network is started through seperate scripts.
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org --- config/rootfiles/common/aarch64/initscripts | 4 +++ config/rootfiles/common/riscv64/initscripts | 4 +++ config/rootfiles/common/x86_64/initscripts | 4 +++ lfs/initscripts | 3 ++ src/initscripts/system/depends-on-network | 40 +++++++++++++++++++++ src/initscripts/system/network | 8 ----- 6 files changed, 55 insertions(+), 8 deletions(-) create mode 100644 src/initscripts/system/depends-on-network
diff --git a/config/rootfiles/common/aarch64/initscripts b/config/rootfiles/common/aarch64/initscripts index d9f80e6b2..506f616e6 100644 --- a/config/rootfiles/common/aarch64/initscripts +++ b/config/rootfiles/common/aarch64/initscripts @@ -18,6 +18,7 @@ etc/rc.d/init.d/collectd etc/rc.d/init.d/connectd etc/rc.d/init.d/conntrackd etc/rc.d/init.d/console +etc/rc.d/init.d/depends-on-network etc/rc.d/init.d/dhcp etc/rc.d/init.d/dhcrelay etc/rc.d/init.d/fcron @@ -105,6 +106,7 @@ etc/rc.d/rc0.d/K49cyrus-sasl etc/rc.d/rc0.d/K51vnstat etc/rc.d/rc0.d/K77conntrackd etc/rc.d/rc0.d/K78suricata +etc/rc.d/rc0.d/K79depends-on-network etc/rc.d/rc0.d/K79leds etc/rc.d/rc0.d/K80network etc/rc.d/rc0.d/K82wlanclient @@ -128,6 +130,7 @@ etc/rc.d/rc3.d/S15fireinfo etc/rc.d/rc3.d/S19smartenabler etc/rc.d/rc3.d/S19wlanclient etc/rc.d/rc3.d/S20network +etc/rc.d/rc3.d/S21depends-on-network etc/rc.d/rc3.d/S21leds etc/rc.d/rc3.d/S22conntrackd etc/rc.d/rc3.d/S24cyrus-sasl @@ -154,6 +157,7 @@ etc/rc.d/rc6.d/K49cyrus-sasl etc/rc.d/rc6.d/K51vnstat etc/rc.d/rc6.d/K77conntrackd etc/rc.d/rc6.d/K78suricata +etc/rc.d/rc6.d/K79depends-on-network etc/rc.d/rc6.d/K79leds etc/rc.d/rc6.d/K80network etc/rc.d/rc6.d/K82wlanclient diff --git a/config/rootfiles/common/riscv64/initscripts b/config/rootfiles/common/riscv64/initscripts index a4865aa29..e834cbfc3 100644 --- a/config/rootfiles/common/riscv64/initscripts +++ b/config/rootfiles/common/riscv64/initscripts @@ -18,6 +18,7 @@ etc/rc.d/init.d/collectd etc/rc.d/init.d/connectd etc/rc.d/init.d/conntrackd etc/rc.d/init.d/console +etc/rc.d/init.d/depends-on-network etc/rc.d/init.d/dhcp etc/rc.d/init.d/dhcrelay etc/rc.d/init.d/fcron @@ -104,6 +105,7 @@ etc/rc.d/rc0.d/K49cyrus-sasl etc/rc.d/rc0.d/K51vnstat etc/rc.d/rc0.d/K77conntrackd etc/rc.d/rc0.d/K78suricata +etc/rc.d/rc0.d/K79depends-on-network etc/rc.d/rc0.d/K79leds etc/rc.d/rc0.d/K80network etc/rc.d/rc0.d/K82wlanclient @@ -127,6 +129,7 @@ etc/rc.d/rc3.d/S15fireinfo etc/rc.d/rc3.d/S19smartenabler etc/rc.d/rc3.d/S19wlanclient etc/rc.d/rc3.d/S20network +etc/rc.d/rc3.d/S21depends-on-network etc/rc.d/rc3.d/S21leds etc/rc.d/rc3.d/S22conntrackd etc/rc.d/rc3.d/S24cyrus-sasl @@ -153,6 +156,7 @@ etc/rc.d/rc6.d/K49cyrus-sasl etc/rc.d/rc6.d/K51vnstat etc/rc.d/rc6.d/K77conntrackd etc/rc.d/rc6.d/K78suricata +etc/rc.d/rc6.d/K79depends-on-network etc/rc.d/rc6.d/K79leds etc/rc.d/rc6.d/K80network etc/rc.d/rc6.d/K82wlanclient diff --git a/config/rootfiles/common/x86_64/initscripts b/config/rootfiles/common/x86_64/initscripts index a4865aa29..e834cbfc3 100644 --- a/config/rootfiles/common/x86_64/initscripts +++ b/config/rootfiles/common/x86_64/initscripts @@ -18,6 +18,7 @@ etc/rc.d/init.d/collectd etc/rc.d/init.d/connectd etc/rc.d/init.d/conntrackd etc/rc.d/init.d/console +etc/rc.d/init.d/depends-on-network etc/rc.d/init.d/dhcp etc/rc.d/init.d/dhcrelay etc/rc.d/init.d/fcron @@ -104,6 +105,7 @@ etc/rc.d/rc0.d/K49cyrus-sasl etc/rc.d/rc0.d/K51vnstat etc/rc.d/rc0.d/K77conntrackd etc/rc.d/rc0.d/K78suricata +etc/rc.d/rc0.d/K79depends-on-network etc/rc.d/rc0.d/K79leds etc/rc.d/rc0.d/K80network etc/rc.d/rc0.d/K82wlanclient @@ -127,6 +129,7 @@ etc/rc.d/rc3.d/S15fireinfo etc/rc.d/rc3.d/S19smartenabler etc/rc.d/rc3.d/S19wlanclient etc/rc.d/rc3.d/S20network +etc/rc.d/rc3.d/S21depends-on-network etc/rc.d/rc3.d/S21leds etc/rc.d/rc3.d/S22conntrackd etc/rc.d/rc3.d/S24cyrus-sasl @@ -153,6 +156,7 @@ etc/rc.d/rc6.d/K49cyrus-sasl etc/rc.d/rc6.d/K51vnstat etc/rc.d/rc6.d/K77conntrackd etc/rc.d/rc6.d/K78suricata +etc/rc.d/rc6.d/K79depends-on-network etc/rc.d/rc6.d/K79leds etc/rc.d/rc6.d/K80network etc/rc.d/rc6.d/K82wlanclient diff --git a/lfs/initscripts b/lfs/initscripts index e078632ab..263292da9 100644 --- a/lfs/initscripts +++ b/lfs/initscripts @@ -103,6 +103,7 @@ $(TARGET) : ln -sf ../init.d/vnstat /etc/rc.d/rc0.d/K51vnstat ln -sf ../init.d/conntrackd /etc/rc.d/rc0.d/K77conntrackd ln -sf ../init.d/suricata /etc/rc.d/rc0.d/K78suricata + ln -sf ../init.d/depends-on-network /etc/rc.d/rc0.d/K79depends-on-network ln -sf ../init.d/leds /etc/rc.d/rc0.d/K79leds ln -sf ../init.d/network /etc/rc.d/rc0.d/K80network ln -sf ../init.d/wlanclient /etc/rc.d/rc0.d/K82wlanclient @@ -124,6 +125,7 @@ $(TARGET) : ln -sf ../init.d/smartenabler /etc/rc.d/rc3.d/S19smartenabler ln -sf ../init.d/wlanclient /etc/rc.d/rc3.d/S19wlanclient ln -sf ../init.d/network /etc/rc.d/rc3.d/S20network + ln -sf ../init.d/depends-on-network /etc/rc.d/rc3.d/S21depends-on-network ln -sf ../init.d/leds /etc/rc.d/rc3.d/S21leds ln -sf ../init.d/conntrackd /etc/rc.d/rc3.d/S22conntrackd ln -sf ../init.d/cyrus-sasl /etc/rc.d/rc3.d/S24cyrus-sasl @@ -148,6 +150,7 @@ $(TARGET) : ln -sf ../init.d/vnstat /etc/rc.d/rc6.d/K51vnstat ln -sf ../init.d/conntrackd /etc/rc.d/rc6.d/K77conntrackd ln -sf ../init.d/suricata /etc/rc.d/rc6.d/K78suricata + ln -sf ../init.d/depends-on-network /etc/rc.d/rc6.d/K79depends-on-network ln -sf ../init.d/leds /etc/rc.d/rc6.d/K79leds ln -sf ../init.d/network /etc/rc.d/rc6.d/K80network ln -sf ../init.d/wlanclient /etc/rc.d/rc6.d/K82wlanclient diff --git a/src/initscripts/system/depends-on-network b/src/initscripts/system/depends-on-network new file mode 100644 index 000000000..777a2dbd1 --- /dev/null +++ b/src/initscripts/system/depends-on-network @@ -0,0 +1,40 @@ +#!/bin/bash +######################################################################## +# Begin $rc_base/init.d/depends-on-network +# +# Description : Script to execute actions after complete network startup +# +# Notes : Written for IPFire by its team +# +######################################################################## + +. /etc/sysconfig/rc +. ${rc_functions} + +DO="${1}" +shift + +case "${DO}" in + start) + boot_mesg "Mounting network file systems..." + mount -a -O _netdev + evaluate_retval + ;; + + stop) + boot_mesg "Umounting network file systems..." + umount -a -O _netdev + evaluate_retval + ;; + restart) + ${0} stop + sleep 1 + ${0} start + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 + ;; +esac + +# End /etc/rc.d/init.d/depends-on-network diff --git a/src/initscripts/system/network b/src/initscripts/system/network index 0db64eaad..e3fe47597 100644 --- a/src/initscripts/system/network +++ b/src/initscripts/system/network @@ -75,17 +75,9 @@ case "${DO}" in for i in "${VALID_ZONES[@]}"; do ${ZONE_ACTION[${i}]} && /etc/rc.d/init.d/networking/${i} start done - - boot_mesg "Mounting network file systems..." - mount -a -O _netdev - evaluate_retval ;;
stop) - boot_mesg "Umounting network file systems..." - umount -a -O _netdev - evaluate_retval - # Stopping interfaces... for i in "${VALID_ZONES[@]}"; do ${ZONE_ACTION[${i}]} && /etc/rc.d/init.d/networking/${i} stop
Why is this script breaking with the “one script, one task” philosophy of sysvinit?
It should just be called “mountnetfs” and be called just with the right priority.
On 23 May 2023, at 18:23, Jonatan Schlag jonatan.schlag@ipfire.org wrote:
This allows us to split the network startup further up into seperate scripts. The mount of the network filesystems is now done after the startup of the network, but can be delayed further when the network is started through seperate scripts.
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org
config/rootfiles/common/aarch64/initscripts | 4 +++ config/rootfiles/common/riscv64/initscripts | 4 +++ config/rootfiles/common/x86_64/initscripts | 4 +++ lfs/initscripts | 3 ++ src/initscripts/system/depends-on-network | 40 +++++++++++++++++++++ src/initscripts/system/network | 8 ----- 6 files changed, 55 insertions(+), 8 deletions(-) create mode 100644 src/initscripts/system/depends-on-network
diff --git a/config/rootfiles/common/aarch64/initscripts b/config/rootfiles/common/aarch64/initscripts index d9f80e6b2..506f616e6 100644 --- a/config/rootfiles/common/aarch64/initscripts +++ b/config/rootfiles/common/aarch64/initscripts @@ -18,6 +18,7 @@ etc/rc.d/init.d/collectd etc/rc.d/init.d/connectd etc/rc.d/init.d/conntrackd etc/rc.d/init.d/console +etc/rc.d/init.d/depends-on-network etc/rc.d/init.d/dhcp etc/rc.d/init.d/dhcrelay etc/rc.d/init.d/fcron @@ -105,6 +106,7 @@ etc/rc.d/rc0.d/K49cyrus-sasl etc/rc.d/rc0.d/K51vnstat etc/rc.d/rc0.d/K77conntrackd etc/rc.d/rc0.d/K78suricata +etc/rc.d/rc0.d/K79depends-on-network etc/rc.d/rc0.d/K79leds etc/rc.d/rc0.d/K80network etc/rc.d/rc0.d/K82wlanclient @@ -128,6 +130,7 @@ etc/rc.d/rc3.d/S15fireinfo etc/rc.d/rc3.d/S19smartenabler etc/rc.d/rc3.d/S19wlanclient etc/rc.d/rc3.d/S20network +etc/rc.d/rc3.d/S21depends-on-network etc/rc.d/rc3.d/S21leds etc/rc.d/rc3.d/S22conntrackd etc/rc.d/rc3.d/S24cyrus-sasl @@ -154,6 +157,7 @@ etc/rc.d/rc6.d/K49cyrus-sasl etc/rc.d/rc6.d/K51vnstat etc/rc.d/rc6.d/K77conntrackd etc/rc.d/rc6.d/K78suricata +etc/rc.d/rc6.d/K79depends-on-network etc/rc.d/rc6.d/K79leds etc/rc.d/rc6.d/K80network etc/rc.d/rc6.d/K82wlanclient diff --git a/config/rootfiles/common/riscv64/initscripts b/config/rootfiles/common/riscv64/initscripts index a4865aa29..e834cbfc3 100644 --- a/config/rootfiles/common/riscv64/initscripts +++ b/config/rootfiles/common/riscv64/initscripts @@ -18,6 +18,7 @@ etc/rc.d/init.d/collectd etc/rc.d/init.d/connectd etc/rc.d/init.d/conntrackd etc/rc.d/init.d/console +etc/rc.d/init.d/depends-on-network etc/rc.d/init.d/dhcp etc/rc.d/init.d/dhcrelay etc/rc.d/init.d/fcron @@ -104,6 +105,7 @@ etc/rc.d/rc0.d/K49cyrus-sasl etc/rc.d/rc0.d/K51vnstat etc/rc.d/rc0.d/K77conntrackd etc/rc.d/rc0.d/K78suricata +etc/rc.d/rc0.d/K79depends-on-network etc/rc.d/rc0.d/K79leds etc/rc.d/rc0.d/K80network etc/rc.d/rc0.d/K82wlanclient @@ -127,6 +129,7 @@ etc/rc.d/rc3.d/S15fireinfo etc/rc.d/rc3.d/S19smartenabler etc/rc.d/rc3.d/S19wlanclient etc/rc.d/rc3.d/S20network +etc/rc.d/rc3.d/S21depends-on-network etc/rc.d/rc3.d/S21leds etc/rc.d/rc3.d/S22conntrackd etc/rc.d/rc3.d/S24cyrus-sasl @@ -153,6 +156,7 @@ etc/rc.d/rc6.d/K49cyrus-sasl etc/rc.d/rc6.d/K51vnstat etc/rc.d/rc6.d/K77conntrackd etc/rc.d/rc6.d/K78suricata +etc/rc.d/rc6.d/K79depends-on-network etc/rc.d/rc6.d/K79leds etc/rc.d/rc6.d/K80network etc/rc.d/rc6.d/K82wlanclient diff --git a/config/rootfiles/common/x86_64/initscripts b/config/rootfiles/common/x86_64/initscripts index a4865aa29..e834cbfc3 100644 --- a/config/rootfiles/common/x86_64/initscripts +++ b/config/rootfiles/common/x86_64/initscripts @@ -18,6 +18,7 @@ etc/rc.d/init.d/collectd etc/rc.d/init.d/connectd etc/rc.d/init.d/conntrackd etc/rc.d/init.d/console +etc/rc.d/init.d/depends-on-network etc/rc.d/init.d/dhcp etc/rc.d/init.d/dhcrelay etc/rc.d/init.d/fcron @@ -104,6 +105,7 @@ etc/rc.d/rc0.d/K49cyrus-sasl etc/rc.d/rc0.d/K51vnstat etc/rc.d/rc0.d/K77conntrackd etc/rc.d/rc0.d/K78suricata +etc/rc.d/rc0.d/K79depends-on-network etc/rc.d/rc0.d/K79leds etc/rc.d/rc0.d/K80network etc/rc.d/rc0.d/K82wlanclient @@ -127,6 +129,7 @@ etc/rc.d/rc3.d/S15fireinfo etc/rc.d/rc3.d/S19smartenabler etc/rc.d/rc3.d/S19wlanclient etc/rc.d/rc3.d/S20network +etc/rc.d/rc3.d/S21depends-on-network etc/rc.d/rc3.d/S21leds etc/rc.d/rc3.d/S22conntrackd etc/rc.d/rc3.d/S24cyrus-sasl @@ -153,6 +156,7 @@ etc/rc.d/rc6.d/K49cyrus-sasl etc/rc.d/rc6.d/K51vnstat etc/rc.d/rc6.d/K77conntrackd etc/rc.d/rc6.d/K78suricata +etc/rc.d/rc6.d/K79depends-on-network etc/rc.d/rc6.d/K79leds etc/rc.d/rc6.d/K80network etc/rc.d/rc6.d/K82wlanclient diff --git a/lfs/initscripts b/lfs/initscripts index e078632ab..263292da9 100644 --- a/lfs/initscripts +++ b/lfs/initscripts @@ -103,6 +103,7 @@ $(TARGET) : ln -sf ../init.d/vnstat /etc/rc.d/rc0.d/K51vnstat ln -sf ../init.d/conntrackd /etc/rc.d/rc0.d/K77conntrackd ln -sf ../init.d/suricata /etc/rc.d/rc0.d/K78suricata
- ln -sf ../init.d/depends-on-network /etc/rc.d/rc0.d/K79depends-on-network
ln -sf ../init.d/leds /etc/rc.d/rc0.d/K79leds ln -sf ../init.d/network /etc/rc.d/rc0.d/K80network ln -sf ../init.d/wlanclient /etc/rc.d/rc0.d/K82wlanclient @@ -124,6 +125,7 @@ $(TARGET) : ln -sf ../init.d/smartenabler /etc/rc.d/rc3.d/S19smartenabler ln -sf ../init.d/wlanclient /etc/rc.d/rc3.d/S19wlanclient ln -sf ../init.d/network /etc/rc.d/rc3.d/S20network
- ln -sf ../init.d/depends-on-network /etc/rc.d/rc3.d/S21depends-on-network
ln -sf ../init.d/leds /etc/rc.d/rc3.d/S21leds ln -sf ../init.d/conntrackd /etc/rc.d/rc3.d/S22conntrackd ln -sf ../init.d/cyrus-sasl /etc/rc.d/rc3.d/S24cyrus-sasl @@ -148,6 +150,7 @@ $(TARGET) : ln -sf ../init.d/vnstat /etc/rc.d/rc6.d/K51vnstat ln -sf ../init.d/conntrackd /etc/rc.d/rc6.d/K77conntrackd ln -sf ../init.d/suricata /etc/rc.d/rc6.d/K78suricata
- ln -sf ../init.d/depends-on-network /etc/rc.d/rc6.d/K79depends-on-network
ln -sf ../init.d/leds /etc/rc.d/rc6.d/K79leds ln -sf ../init.d/network /etc/rc.d/rc6.d/K80network ln -sf ../init.d/wlanclient /etc/rc.d/rc6.d/K82wlanclient diff --git a/src/initscripts/system/depends-on-network b/src/initscripts/system/depends-on-network new file mode 100644 index 000000000..777a2dbd1 --- /dev/null +++ b/src/initscripts/system/depends-on-network @@ -0,0 +1,40 @@ +#!/bin/bash +######################################################################## +# Begin $rc_base/init.d/depends-on-network +# +# Description : Script to execute actions after complete network startup +# +# Notes : Written for IPFire by its team +# +########################################################################
+. /etc/sysconfig/rc +. ${rc_functions}
+DO="${1}" +shift
+case "${DO}" in
- start)
- boot_mesg "Mounting network file systems..."
- mount -a -O _netdev
- evaluate_retval
- ;;
- stop)
- boot_mesg "Umounting network file systems..."
- umount -a -O _netdev
- evaluate_retval
- ;;
- restart)
- ${0} stop
- sleep 1
- ${0} start
- ;;
- *)
- echo "Usage: $0 {start|stop|restart}"
- exit 1
- ;;
+esac
+# End /etc/rc.d/init.d/depends-on-network diff --git a/src/initscripts/system/network b/src/initscripts/system/network index 0db64eaad..e3fe47597 100644 --- a/src/initscripts/system/network +++ b/src/initscripts/system/network @@ -75,17 +75,9 @@ case "${DO}" in for i in "${VALID_ZONES[@]}"; do ${ZONE_ACTION[${i}]} && /etc/rc.d/init.d/networking/${i} start done
- boot_mesg "Mounting network file systems..."
- mount -a -O _netdev
- evaluate_retval
;;
stop)
- boot_mesg "Umounting network file systems..."
- umount -a -O _netdev
- evaluate_retval
# Stopping interfaces... for i in "${VALID_ZONES[@]}"; do ${ZONE_ACTION[${i}]} && /etc/rc.d/init.d/networking/${i} stop -- 2.30.2
This allows us to start the local and uplink network independent of each other. The function of /etc/init.d/network remains unchangend to maintain backwards compatibility.
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org --- config/rootfiles/common/aarch64/initscripts | 2 ++ config/rootfiles/common/riscv64/initscripts | 2 ++ config/rootfiles/common/x86_64/initscripts | 2 ++ lfs/initscripts | 3 +++ src/initscripts/system/network | 22 ++++++++++++--------- 5 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/config/rootfiles/common/aarch64/initscripts b/config/rootfiles/common/aarch64/initscripts index 506f616e6..739503ae6 100644 --- a/config/rootfiles/common/aarch64/initscripts +++ b/config/rootfiles/common/aarch64/initscripts @@ -36,6 +36,8 @@ etc/rc.d/init.d/mountfs etc/rc.d/init.d/mountkernfs etc/rc.d/init.d/mounttmpfs etc/rc.d/init.d/network +etc/rc.d/init.d/network-local +etc/rc.d/init.d/network-uplink #etc/rc.d/init.d/networking etc/rc.d/init.d/networking/any etc/rc.d/init.d/networking/blue diff --git a/config/rootfiles/common/riscv64/initscripts b/config/rootfiles/common/riscv64/initscripts index e834cbfc3..ed1eae904 100644 --- a/config/rootfiles/common/riscv64/initscripts +++ b/config/rootfiles/common/riscv64/initscripts @@ -36,6 +36,8 @@ etc/rc.d/init.d/mountfs etc/rc.d/init.d/mountkernfs etc/rc.d/init.d/mounttmpfs etc/rc.d/init.d/network +etc/rc.d/init.d/network-local +etc/rc.d/init.d/network-uplink #etc/rc.d/init.d/networking etc/rc.d/init.d/networking/any etc/rc.d/init.d/networking/blue diff --git a/config/rootfiles/common/x86_64/initscripts b/config/rootfiles/common/x86_64/initscripts index e834cbfc3..ed1eae904 100644 --- a/config/rootfiles/common/x86_64/initscripts +++ b/config/rootfiles/common/x86_64/initscripts @@ -36,6 +36,8 @@ etc/rc.d/init.d/mountfs etc/rc.d/init.d/mountkernfs etc/rc.d/init.d/mounttmpfs etc/rc.d/init.d/network +etc/rc.d/init.d/network-local +etc/rc.d/init.d/network-uplink #etc/rc.d/init.d/networking etc/rc.d/init.d/networking/any etc/rc.d/init.d/networking/blue diff --git a/lfs/initscripts b/lfs/initscripts index 263292da9..e8a2e4c6e 100644 --- a/lfs/initscripts +++ b/lfs/initscripts @@ -193,6 +193,9 @@ $(TARGET) : ln -sf any /etc/rc.d/init.d/networking/$$i; \ done
+ ln -sf /etc/rc.d/init.d/network /etc/rc.d/init.d/network-local + ln -sf /etc/rc.d/init.d/networking/red /etc/rc.d/init.d/network-uplink + # intel intel no swconfig ifeq "$(BUILD_PLATFORM)" "arm" ln -sf ../init.d/swconfig /etc/rc.d/rcsysinit.d/S73swconfig diff --git a/src/initscripts/system/network b/src/initscripts/system/network index e3fe47597..ff305e472 100644 --- a/src/initscripts/system/network +++ b/src/initscripts/system/network @@ -36,20 +36,24 @@ declare -a VALID_ZONES VALID_ZONES+=("blue") VALID_ZONES+=("green") VALID_ZONES+=("orange") -VALID_ZONES+=("red") + +# 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") +fi
declare -A ZONE_ACTION
-ZONE_ACTION[blue]=false -ZONE_ACTION[green]=false -ZONE_ACTION[orange]=false -ZONE_ACTION[red]=false +for i in "${VALID_ZONES[@]}"; do + ZONE_ACTION[${i}]=false +done
if [ $# -eq 0 ]; then - ZONE_ACTION[blue]=true - ZONE_ACTION[green]=true - ZONE_ACTION[orange]=true - ZONE_ACTION[red]=true + for i in "${VALID_ZONES[@]}"; do + ZONE_ACTION[${i}]=true + done fi
while [ $# -ne 0 ]; do
On 23 May 2023, at 18:23, Jonatan Schlag jonatan.schlag@ipfire.org wrote:
This allows us to start the local and uplink network independent of each other. The function of /etc/init.d/network remains unchangend to maintain backwards compatibility.
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org
config/rootfiles/common/aarch64/initscripts | 2 ++ config/rootfiles/common/riscv64/initscripts | 2 ++ config/rootfiles/common/x86_64/initscripts | 2 ++ lfs/initscripts | 3 +++ src/initscripts/system/network | 22 ++++++++++++--------- 5 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/config/rootfiles/common/aarch64/initscripts b/config/rootfiles/common/aarch64/initscripts index 506f616e6..739503ae6 100644 --- a/config/rootfiles/common/aarch64/initscripts +++ b/config/rootfiles/common/aarch64/initscripts @@ -36,6 +36,8 @@ etc/rc.d/init.d/mountfs etc/rc.d/init.d/mountkernfs etc/rc.d/init.d/mounttmpfs etc/rc.d/init.d/network +etc/rc.d/init.d/network-local +etc/rc.d/init.d/network-uplink #etc/rc.d/init.d/networking etc/rc.d/init.d/networking/any etc/rc.d/init.d/networking/blue diff --git a/config/rootfiles/common/riscv64/initscripts b/config/rootfiles/common/riscv64/initscripts index e834cbfc3..ed1eae904 100644 --- a/config/rootfiles/common/riscv64/initscripts +++ b/config/rootfiles/common/riscv64/initscripts @@ -36,6 +36,8 @@ etc/rc.d/init.d/mountfs etc/rc.d/init.d/mountkernfs etc/rc.d/init.d/mounttmpfs etc/rc.d/init.d/network +etc/rc.d/init.d/network-local +etc/rc.d/init.d/network-uplink #etc/rc.d/init.d/networking etc/rc.d/init.d/networking/any etc/rc.d/init.d/networking/blue diff --git a/config/rootfiles/common/x86_64/initscripts b/config/rootfiles/common/x86_64/initscripts index e834cbfc3..ed1eae904 100644 --- a/config/rootfiles/common/x86_64/initscripts +++ b/config/rootfiles/common/x86_64/initscripts @@ -36,6 +36,8 @@ etc/rc.d/init.d/mountfs etc/rc.d/init.d/mountkernfs etc/rc.d/init.d/mounttmpfs etc/rc.d/init.d/network +etc/rc.d/init.d/network-local +etc/rc.d/init.d/network-uplink #etc/rc.d/init.d/networking etc/rc.d/init.d/networking/any etc/rc.d/init.d/networking/blue diff --git a/lfs/initscripts b/lfs/initscripts index 263292da9..e8a2e4c6e 100644 --- a/lfs/initscripts +++ b/lfs/initscripts @@ -193,6 +193,9 @@ $(TARGET) : ln -sf any /etc/rc.d/init.d/networking/$$i; \ done
- ln -sf /etc/rc.d/init.d/network /etc/rc.d/init.d/network-local
- ln -sf /etc/rc.d/init.d/networking/red /etc/rc.d/init.d/network-uplink
This is really unexpected.
# intel intel no swconfig ifeq "$(BUILD_PLATFORM)" "arm" ln -sf ../init.d/swconfig /etc/rc.d/rcsysinit.d/S73swconfig diff --git a/src/initscripts/system/network b/src/initscripts/system/network index e3fe47597..ff305e472 100644 --- a/src/initscripts/system/network +++ b/src/initscripts/system/network @@ -36,20 +36,24 @@ declare -a VALID_ZONES VALID_ZONES+=("blue") VALID_ZONES+=("green") VALID_ZONES+=("orange") -VALID_ZONES+=("red")
+# 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")
+fi
declare -A ZONE_ACTION
-ZONE_ACTION[blue]=false -ZONE_ACTION[green]=false -ZONE_ACTION[orange]=false -ZONE_ACTION[red]=false +for i in "${VALID_ZONES[@]}"; do
- ZONE_ACTION[${i}]=false
+done
if [ $# -eq 0 ]; then
- ZONE_ACTION[blue]=true
- ZONE_ACTION[green]=true
- ZONE_ACTION[orange]=true
- ZONE_ACTION[red]=true
- for i in "${VALID_ZONES[@]}"; do
- ZONE_ACTION[${i}]=true
- done
fi
while [ $# -ne 0 ]; do
2.30.2
This allows us several things:
1. We can start apache and sshd earlier. This makes debugging and troubleshooting easier. When the startup hangs at red an admin can now at least login and search for what is wrong. 2. We can change the implementation of local and uplink network easier as both are a little bit more independent as before.
Fixes: #11502
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org --- config/rootfiles/common/aarch64/initscripts | 27 ++++++++++--------- config/rootfiles/common/riscv64/initscripts | 27 ++++++++++--------- config/rootfiles/common/x86_64/initscripts | 27 ++++++++++--------- lfs/initscripts | 29 ++++++++++++--------- 4 files changed, 61 insertions(+), 49 deletions(-)
diff --git a/config/rootfiles/common/aarch64/initscripts b/config/rootfiles/common/aarch64/initscripts index 739503ae6..b3187fb45 100644 --- a/config/rootfiles/common/aarch64/initscripts +++ b/config/rootfiles/common/aarch64/initscripts @@ -110,8 +110,9 @@ etc/rc.d/rc0.d/K77conntrackd etc/rc.d/rc0.d/K78suricata etc/rc.d/rc0.d/K79depends-on-network etc/rc.d/rc0.d/K79leds -etc/rc.d/rc0.d/K80network -etc/rc.d/rc0.d/K82wlanclient +etc/rc.d/rc0.d/K80network-uplink +etc/rc.d/rc0.d/K81wlanclient +etc/rc.d/rc0.d/K82network-local #etc/rc.d/rc0.d/K85messagebus etc/rc.d/rc0.d/K86unbound etc/rc.d/rc0.d/K87acpid @@ -130,14 +131,15 @@ etc/rc.d/rc3.d/S15fireinfo #etc/rc.d/rc3.d/S15messagebus #etc/rc.d/rc3.d/S18cpufreq etc/rc.d/rc3.d/S19smartenabler -etc/rc.d/rc3.d/S19wlanclient -etc/rc.d/rc3.d/S20network -etc/rc.d/rc3.d/S21depends-on-network -etc/rc.d/rc3.d/S21leds -etc/rc.d/rc3.d/S22conntrackd -etc/rc.d/rc3.d/S24cyrus-sasl -etc/rc.d/rc3.d/S30sshd -etc/rc.d/rc3.d/S32apache +etc/rc.d/rc3.d/S20network-local +etc/rc.d/rc3.d/S21sshd +etc/rc.d/rc3.d/S22apache +etc/rc.d/rc3.d/S23wlanclient +etc/rc.d/rc3.d/S24network-uplink +etc/rc.d/rc3.d/S25depends-on-network +etc/rc.d/rc3.d/S25leds +etc/rc.d/rc3.d/S30conntrackd +etc/rc.d/rc3.d/S35cyrus-sasl etc/rc.d/rc3.d/S40fcron #etc/rc.d/rc3.d/S66client175 etc/rc.d/rc3.d/S98rc.local @@ -161,8 +163,9 @@ etc/rc.d/rc6.d/K77conntrackd etc/rc.d/rc6.d/K78suricata etc/rc.d/rc6.d/K79depends-on-network etc/rc.d/rc6.d/K79leds -etc/rc.d/rc6.d/K80network -etc/rc.d/rc6.d/K82wlanclient +etc/rc.d/rc6.d/K80network-uplink +etc/rc.d/rc6.d/K81wlanclient +etc/rc.d/rc6.d/K82network-local #etc/rc.d/rc6.d/K85messagebus etc/rc.d/rc6.d/K86unbound etc/rc.d/rc6.d/K87acpid diff --git a/config/rootfiles/common/riscv64/initscripts b/config/rootfiles/common/riscv64/initscripts index ed1eae904..cbb3f9118 100644 --- a/config/rootfiles/common/riscv64/initscripts +++ b/config/rootfiles/common/riscv64/initscripts @@ -109,8 +109,9 @@ etc/rc.d/rc0.d/K77conntrackd etc/rc.d/rc0.d/K78suricata etc/rc.d/rc0.d/K79depends-on-network etc/rc.d/rc0.d/K79leds -etc/rc.d/rc0.d/K80network -etc/rc.d/rc0.d/K82wlanclient +etc/rc.d/rc0.d/K80network-uplink +etc/rc.d/rc0.d/K81wlanclient +etc/rc.d/rc0.d/K82network-local #etc/rc.d/rc0.d/K85messagebus etc/rc.d/rc0.d/K86unbound etc/rc.d/rc0.d/K87acpid @@ -129,14 +130,15 @@ etc/rc.d/rc3.d/S15fireinfo #etc/rc.d/rc3.d/S15messagebus #etc/rc.d/rc3.d/S18cpufreq etc/rc.d/rc3.d/S19smartenabler -etc/rc.d/rc3.d/S19wlanclient -etc/rc.d/rc3.d/S20network -etc/rc.d/rc3.d/S21depends-on-network -etc/rc.d/rc3.d/S21leds -etc/rc.d/rc3.d/S22conntrackd -etc/rc.d/rc3.d/S24cyrus-sasl -etc/rc.d/rc3.d/S30sshd -etc/rc.d/rc3.d/S32apache +etc/rc.d/rc3.d/S20network-local +etc/rc.d/rc3.d/S21sshd +etc/rc.d/rc3.d/S22apache +etc/rc.d/rc3.d/S23wlanclient +etc/rc.d/rc3.d/S24network-uplink +etc/rc.d/rc3.d/S25depends-on-network +etc/rc.d/rc3.d/S25leds +etc/rc.d/rc3.d/S30conntrackd +etc/rc.d/rc3.d/S35cyrus-sasl etc/rc.d/rc3.d/S40fcron #etc/rc.d/rc3.d/S66client175 etc/rc.d/rc3.d/S98rc.local @@ -160,8 +162,9 @@ etc/rc.d/rc6.d/K77conntrackd etc/rc.d/rc6.d/K78suricata etc/rc.d/rc6.d/K79depends-on-network etc/rc.d/rc6.d/K79leds -etc/rc.d/rc6.d/K80network -etc/rc.d/rc6.d/K82wlanclient +etc/rc.d/rc6.d/K80network-uplink +etc/rc.d/rc6.d/K81wlanclient +etc/rc.d/rc6.d/K82network-local #etc/rc.d/rc6.d/K85messagebus etc/rc.d/rc6.d/K86unbound etc/rc.d/rc6.d/K87acpid diff --git a/config/rootfiles/common/x86_64/initscripts b/config/rootfiles/common/x86_64/initscripts index ed1eae904..cbb3f9118 100644 --- a/config/rootfiles/common/x86_64/initscripts +++ b/config/rootfiles/common/x86_64/initscripts @@ -109,8 +109,9 @@ etc/rc.d/rc0.d/K77conntrackd etc/rc.d/rc0.d/K78suricata etc/rc.d/rc0.d/K79depends-on-network etc/rc.d/rc0.d/K79leds -etc/rc.d/rc0.d/K80network -etc/rc.d/rc0.d/K82wlanclient +etc/rc.d/rc0.d/K80network-uplink +etc/rc.d/rc0.d/K81wlanclient +etc/rc.d/rc0.d/K82network-local #etc/rc.d/rc0.d/K85messagebus etc/rc.d/rc0.d/K86unbound etc/rc.d/rc0.d/K87acpid @@ -129,14 +130,15 @@ etc/rc.d/rc3.d/S15fireinfo #etc/rc.d/rc3.d/S15messagebus #etc/rc.d/rc3.d/S18cpufreq etc/rc.d/rc3.d/S19smartenabler -etc/rc.d/rc3.d/S19wlanclient -etc/rc.d/rc3.d/S20network -etc/rc.d/rc3.d/S21depends-on-network -etc/rc.d/rc3.d/S21leds -etc/rc.d/rc3.d/S22conntrackd -etc/rc.d/rc3.d/S24cyrus-sasl -etc/rc.d/rc3.d/S30sshd -etc/rc.d/rc3.d/S32apache +etc/rc.d/rc3.d/S20network-local +etc/rc.d/rc3.d/S21sshd +etc/rc.d/rc3.d/S22apache +etc/rc.d/rc3.d/S23wlanclient +etc/rc.d/rc3.d/S24network-uplink +etc/rc.d/rc3.d/S25depends-on-network +etc/rc.d/rc3.d/S25leds +etc/rc.d/rc3.d/S30conntrackd +etc/rc.d/rc3.d/S35cyrus-sasl etc/rc.d/rc3.d/S40fcron #etc/rc.d/rc3.d/S66client175 etc/rc.d/rc3.d/S98rc.local @@ -160,8 +162,9 @@ etc/rc.d/rc6.d/K77conntrackd etc/rc.d/rc6.d/K78suricata etc/rc.d/rc6.d/K79depends-on-network etc/rc.d/rc6.d/K79leds -etc/rc.d/rc6.d/K80network -etc/rc.d/rc6.d/K82wlanclient +etc/rc.d/rc6.d/K80network-uplink +etc/rc.d/rc6.d/K81wlanclient +etc/rc.d/rc6.d/K82network-local #etc/rc.d/rc6.d/K85messagebus etc/rc.d/rc6.d/K86unbound etc/rc.d/rc6.d/K87acpid diff --git a/lfs/initscripts b/lfs/initscripts index e8a2e4c6e..711f29632 100644 --- a/lfs/initscripts +++ b/lfs/initscripts @@ -104,9 +104,10 @@ $(TARGET) : ln -sf ../init.d/conntrackd /etc/rc.d/rc0.d/K77conntrackd ln -sf ../init.d/suricata /etc/rc.d/rc0.d/K78suricata ln -sf ../init.d/depends-on-network /etc/rc.d/rc0.d/K79depends-on-network - ln -sf ../init.d/leds /etc/rc.d/rc0.d/K79leds - ln -sf ../init.d/network /etc/rc.d/rc0.d/K80network - ln -sf ../init.d/wlanclient /etc/rc.d/rc0.d/K82wlanclient + ln -sf ../init.d/leds /etc/rc.d/rc0.d/K79leds + ln -sf ../init.d/network-uplink /etc/rc.d/rc0.d/K80network-uplink + ln -sf ../init.d/wlanclient /etc/rc.d/rc0.d/K81wlanclient + ln -sf ../init.d/network-local /etc/rc.d/rc0.d/K82network-local ln -sf ../init.d/messagebus /etc/rc.d/rc0.d/K85messagebus ln -sf ../init.d/unbound /etc/rc.d/rc0.d/K86unbound ln -sf ../init.d/sysklogd /etc/rc.d/rc0.d/K90sysklogd @@ -123,14 +124,15 @@ $(TARGET) : ln -sf ../init.d/messagebus /etc/rc.d/rc3.d/S15messagebus ln -sf ../init.d/cpufreq /etc/rc.d/rc3.d/S18cpufreq ln -sf ../init.d/smartenabler /etc/rc.d/rc3.d/S19smartenabler - ln -sf ../init.d/wlanclient /etc/rc.d/rc3.d/S19wlanclient - ln -sf ../init.d/network /etc/rc.d/rc3.d/S20network - ln -sf ../init.d/depends-on-network /etc/rc.d/rc3.d/S21depends-on-network - ln -sf ../init.d/leds /etc/rc.d/rc3.d/S21leds - ln -sf ../init.d/conntrackd /etc/rc.d/rc3.d/S22conntrackd - ln -sf ../init.d/cyrus-sasl /etc/rc.d/rc3.d/S24cyrus-sasl - ln -sf ../init.d/sshd /etc/rc.d/rc3.d/S30sshd - ln -sf ../init.d/apache /etc/rc.d/rc3.d/S32apache + ln -sf ../init.d/network-local /etc/rc.d/rc3.d/S20network-local + ln -sf ../init.d/sshd /etc/rc.d/rc3.d/S21sshd + ln -sf ../init.d/apache /etc/rc.d/rc3.d/S22apache + ln -sf ../init.d/wlanclient /etc/rc.d/rc3.d/S23wlanclient + ln -sf ../init.d/network-uplink /etc/rc.d/rc3.d/S24network-uplink + ln -sf ../init.d/depends-on-network /etc/rc.d/rc3.d/S25depends-on-network + ln -sf ../init.d/leds /etc/rc.d/rc3.d/S25leds + ln -sf ../init.d/conntrackd /etc/rc.d/rc3.d/S30conntrackd + ln -sf ../init.d/cyrus-sasl /etc/rc.d/rc3.d/S35cyrus-sasl ln -sf ../init.d/fcron /etc/rc.d/rc3.d/S40fcron ln -sf ../../sysconfig/rc.local /etc/rc.d/rc3.d/S98rc.local ln -sf ../init.d/sslh /etc/rc.d/rc3.d/S98sslh @@ -152,8 +154,9 @@ $(TARGET) : ln -sf ../init.d/suricata /etc/rc.d/rc6.d/K78suricata ln -sf ../init.d/depends-on-network /etc/rc.d/rc6.d/K79depends-on-network ln -sf ../init.d/leds /etc/rc.d/rc6.d/K79leds - ln -sf ../init.d/network /etc/rc.d/rc6.d/K80network - ln -sf ../init.d/wlanclient /etc/rc.d/rc6.d/K82wlanclient + ln -sf ../init.d/network-uplink /etc/rc.d/rc6.d/K80network-uplink + ln -sf ../init.d/wlanclient /etc/rc.d/rc6.d/K81wlanclient + ln -sf ../init.d/network-local /etc/rc.d/rc6.d/K82network-local ln -sf ../init.d/messagebus /etc/rc.d/rc6.d/K85messagebus ln -sf ../init.d/unbound /etc/rc.d/rc6.d/K86unbound ln -sf ../init.d/sysklogd /etc/rc.d/rc6.d/K90sysklogd
I agree with the essence of this change.
But it should not rely on confusing symlinks and instead have a simple script that calls another one.
On 23 May 2023, at 18:23, Jonatan Schlag jonatan.schlag@ipfire.org wrote:
This allows us several things:
- We can start apache and sshd earlier. This makes debugging and
troubleshooting easier. When the startup hangs at red an admin can now at least login and search for what is wrong. 2. We can change the implementation of local and uplink network easier as both are a little bit more independent as before.
Fixes: #11502
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org
config/rootfiles/common/aarch64/initscripts | 27 ++++++++++--------- config/rootfiles/common/riscv64/initscripts | 27 ++++++++++--------- config/rootfiles/common/x86_64/initscripts | 27 ++++++++++--------- lfs/initscripts | 29 ++++++++++++--------- 4 files changed, 61 insertions(+), 49 deletions(-)
diff --git a/config/rootfiles/common/aarch64/initscripts b/config/rootfiles/common/aarch64/initscripts index 739503ae6..b3187fb45 100644 --- a/config/rootfiles/common/aarch64/initscripts +++ b/config/rootfiles/common/aarch64/initscripts @@ -110,8 +110,9 @@ etc/rc.d/rc0.d/K77conntrackd etc/rc.d/rc0.d/K78suricata etc/rc.d/rc0.d/K79depends-on-network etc/rc.d/rc0.d/K79leds -etc/rc.d/rc0.d/K80network -etc/rc.d/rc0.d/K82wlanclient +etc/rc.d/rc0.d/K80network-uplink +etc/rc.d/rc0.d/K81wlanclient +etc/rc.d/rc0.d/K82network-local #etc/rc.d/rc0.d/K85messagebus etc/rc.d/rc0.d/K86unbound etc/rc.d/rc0.d/K87acpid @@ -130,14 +131,15 @@ etc/rc.d/rc3.d/S15fireinfo #etc/rc.d/rc3.d/S15messagebus #etc/rc.d/rc3.d/S18cpufreq etc/rc.d/rc3.d/S19smartenabler -etc/rc.d/rc3.d/S19wlanclient -etc/rc.d/rc3.d/S20network -etc/rc.d/rc3.d/S21depends-on-network -etc/rc.d/rc3.d/S21leds -etc/rc.d/rc3.d/S22conntrackd -etc/rc.d/rc3.d/S24cyrus-sasl -etc/rc.d/rc3.d/S30sshd -etc/rc.d/rc3.d/S32apache +etc/rc.d/rc3.d/S20network-local +etc/rc.d/rc3.d/S21sshd +etc/rc.d/rc3.d/S22apache +etc/rc.d/rc3.d/S23wlanclient +etc/rc.d/rc3.d/S24network-uplink +etc/rc.d/rc3.d/S25depends-on-network +etc/rc.d/rc3.d/S25leds +etc/rc.d/rc3.d/S30conntrackd +etc/rc.d/rc3.d/S35cyrus-sasl etc/rc.d/rc3.d/S40fcron #etc/rc.d/rc3.d/S66client175 etc/rc.d/rc3.d/S98rc.local @@ -161,8 +163,9 @@ etc/rc.d/rc6.d/K77conntrackd etc/rc.d/rc6.d/K78suricata etc/rc.d/rc6.d/K79depends-on-network etc/rc.d/rc6.d/K79leds -etc/rc.d/rc6.d/K80network -etc/rc.d/rc6.d/K82wlanclient +etc/rc.d/rc6.d/K80network-uplink +etc/rc.d/rc6.d/K81wlanclient +etc/rc.d/rc6.d/K82network-local #etc/rc.d/rc6.d/K85messagebus etc/rc.d/rc6.d/K86unbound etc/rc.d/rc6.d/K87acpid diff --git a/config/rootfiles/common/riscv64/initscripts b/config/rootfiles/common/riscv64/initscripts index ed1eae904..cbb3f9118 100644 --- a/config/rootfiles/common/riscv64/initscripts +++ b/config/rootfiles/common/riscv64/initscripts @@ -109,8 +109,9 @@ etc/rc.d/rc0.d/K77conntrackd etc/rc.d/rc0.d/K78suricata etc/rc.d/rc0.d/K79depends-on-network etc/rc.d/rc0.d/K79leds -etc/rc.d/rc0.d/K80network -etc/rc.d/rc0.d/K82wlanclient +etc/rc.d/rc0.d/K80network-uplink +etc/rc.d/rc0.d/K81wlanclient +etc/rc.d/rc0.d/K82network-local #etc/rc.d/rc0.d/K85messagebus etc/rc.d/rc0.d/K86unbound etc/rc.d/rc0.d/K87acpid @@ -129,14 +130,15 @@ etc/rc.d/rc3.d/S15fireinfo #etc/rc.d/rc3.d/S15messagebus #etc/rc.d/rc3.d/S18cpufreq etc/rc.d/rc3.d/S19smartenabler -etc/rc.d/rc3.d/S19wlanclient -etc/rc.d/rc3.d/S20network -etc/rc.d/rc3.d/S21depends-on-network -etc/rc.d/rc3.d/S21leds -etc/rc.d/rc3.d/S22conntrackd -etc/rc.d/rc3.d/S24cyrus-sasl -etc/rc.d/rc3.d/S30sshd -etc/rc.d/rc3.d/S32apache +etc/rc.d/rc3.d/S20network-local +etc/rc.d/rc3.d/S21sshd +etc/rc.d/rc3.d/S22apache +etc/rc.d/rc3.d/S23wlanclient +etc/rc.d/rc3.d/S24network-uplink +etc/rc.d/rc3.d/S25depends-on-network +etc/rc.d/rc3.d/S25leds +etc/rc.d/rc3.d/S30conntrackd +etc/rc.d/rc3.d/S35cyrus-sasl etc/rc.d/rc3.d/S40fcron #etc/rc.d/rc3.d/S66client175 etc/rc.d/rc3.d/S98rc.local @@ -160,8 +162,9 @@ etc/rc.d/rc6.d/K77conntrackd etc/rc.d/rc6.d/K78suricata etc/rc.d/rc6.d/K79depends-on-network etc/rc.d/rc6.d/K79leds -etc/rc.d/rc6.d/K80network -etc/rc.d/rc6.d/K82wlanclient +etc/rc.d/rc6.d/K80network-uplink +etc/rc.d/rc6.d/K81wlanclient +etc/rc.d/rc6.d/K82network-local #etc/rc.d/rc6.d/K85messagebus etc/rc.d/rc6.d/K86unbound etc/rc.d/rc6.d/K87acpid diff --git a/config/rootfiles/common/x86_64/initscripts b/config/rootfiles/common/x86_64/initscripts index ed1eae904..cbb3f9118 100644 --- a/config/rootfiles/common/x86_64/initscripts +++ b/config/rootfiles/common/x86_64/initscripts @@ -109,8 +109,9 @@ etc/rc.d/rc0.d/K77conntrackd etc/rc.d/rc0.d/K78suricata etc/rc.d/rc0.d/K79depends-on-network etc/rc.d/rc0.d/K79leds -etc/rc.d/rc0.d/K80network -etc/rc.d/rc0.d/K82wlanclient +etc/rc.d/rc0.d/K80network-uplink +etc/rc.d/rc0.d/K81wlanclient +etc/rc.d/rc0.d/K82network-local #etc/rc.d/rc0.d/K85messagebus etc/rc.d/rc0.d/K86unbound etc/rc.d/rc0.d/K87acpid @@ -129,14 +130,15 @@ etc/rc.d/rc3.d/S15fireinfo #etc/rc.d/rc3.d/S15messagebus #etc/rc.d/rc3.d/S18cpufreq etc/rc.d/rc3.d/S19smartenabler -etc/rc.d/rc3.d/S19wlanclient -etc/rc.d/rc3.d/S20network -etc/rc.d/rc3.d/S21depends-on-network -etc/rc.d/rc3.d/S21leds -etc/rc.d/rc3.d/S22conntrackd -etc/rc.d/rc3.d/S24cyrus-sasl -etc/rc.d/rc3.d/S30sshd -etc/rc.d/rc3.d/S32apache +etc/rc.d/rc3.d/S20network-local +etc/rc.d/rc3.d/S21sshd +etc/rc.d/rc3.d/S22apache +etc/rc.d/rc3.d/S23wlanclient +etc/rc.d/rc3.d/S24network-uplink +etc/rc.d/rc3.d/S25depends-on-network +etc/rc.d/rc3.d/S25leds +etc/rc.d/rc3.d/S30conntrackd +etc/rc.d/rc3.d/S35cyrus-sasl etc/rc.d/rc3.d/S40fcron #etc/rc.d/rc3.d/S66client175 etc/rc.d/rc3.d/S98rc.local @@ -160,8 +162,9 @@ etc/rc.d/rc6.d/K77conntrackd etc/rc.d/rc6.d/K78suricata etc/rc.d/rc6.d/K79depends-on-network etc/rc.d/rc6.d/K79leds -etc/rc.d/rc6.d/K80network -etc/rc.d/rc6.d/K82wlanclient +etc/rc.d/rc6.d/K80network-uplink +etc/rc.d/rc6.d/K81wlanclient +etc/rc.d/rc6.d/K82network-local #etc/rc.d/rc6.d/K85messagebus etc/rc.d/rc6.d/K86unbound etc/rc.d/rc6.d/K87acpid diff --git a/lfs/initscripts b/lfs/initscripts index e8a2e4c6e..711f29632 100644 --- a/lfs/initscripts +++ b/lfs/initscripts @@ -104,9 +104,10 @@ $(TARGET) : ln -sf ../init.d/conntrackd /etc/rc.d/rc0.d/K77conntrackd ln -sf ../init.d/suricata /etc/rc.d/rc0.d/K78suricata ln -sf ../init.d/depends-on-network /etc/rc.d/rc0.d/K79depends-on-network
- ln -sf ../init.d/leds /etc/rc.d/rc0.d/K79leds
- ln -sf ../init.d/network /etc/rc.d/rc0.d/K80network
- ln -sf ../init.d/wlanclient /etc/rc.d/rc0.d/K82wlanclient
- ln -sf ../init.d/leds /etc/rc.d/rc0.d/K79leds
- ln -sf ../init.d/network-uplink /etc/rc.d/rc0.d/K80network-uplink
- ln -sf ../init.d/wlanclient /etc/rc.d/rc0.d/K81wlanclient
- ln -sf ../init.d/network-local /etc/rc.d/rc0.d/K82network-local
ln -sf ../init.d/messagebus /etc/rc.d/rc0.d/K85messagebus ln -sf ../init.d/unbound /etc/rc.d/rc0.d/K86unbound ln -sf ../init.d/sysklogd /etc/rc.d/rc0.d/K90sysklogd @@ -123,14 +124,15 @@ $(TARGET) : ln -sf ../init.d/messagebus /etc/rc.d/rc3.d/S15messagebus ln -sf ../init.d/cpufreq /etc/rc.d/rc3.d/S18cpufreq ln -sf ../init.d/smartenabler /etc/rc.d/rc3.d/S19smartenabler
- ln -sf ../init.d/wlanclient /etc/rc.d/rc3.d/S19wlanclient
- ln -sf ../init.d/network /etc/rc.d/rc3.d/S20network
- ln -sf ../init.d/depends-on-network /etc/rc.d/rc3.d/S21depends-on-network
- ln -sf ../init.d/leds /etc/rc.d/rc3.d/S21leds
- ln -sf ../init.d/conntrackd /etc/rc.d/rc3.d/S22conntrackd
- ln -sf ../init.d/cyrus-sasl /etc/rc.d/rc3.d/S24cyrus-sasl
- ln -sf ../init.d/sshd /etc/rc.d/rc3.d/S30sshd
- ln -sf ../init.d/apache /etc/rc.d/rc3.d/S32apache
- ln -sf ../init.d/network-local /etc/rc.d/rc3.d/S20network-local
- ln -sf ../init.d/sshd /etc/rc.d/rc3.d/S21sshd
- ln -sf ../init.d/apache /etc/rc.d/rc3.d/S22apache
- ln -sf ../init.d/wlanclient /etc/rc.d/rc3.d/S23wlanclient
- ln -sf ../init.d/network-uplink /etc/rc.d/rc3.d/S24network-uplink
- ln -sf ../init.d/depends-on-network /etc/rc.d/rc3.d/S25depends-on-network
- ln -sf ../init.d/leds /etc/rc.d/rc3.d/S25leds
- ln -sf ../init.d/conntrackd /etc/rc.d/rc3.d/S30conntrackd
- ln -sf ../init.d/cyrus-sasl /etc/rc.d/rc3.d/S35cyrus-sasl
ln -sf ../init.d/fcron /etc/rc.d/rc3.d/S40fcron ln -sf ../../sysconfig/rc.local /etc/rc.d/rc3.d/S98rc.local ln -sf ../init.d/sslh /etc/rc.d/rc3.d/S98sslh @@ -152,8 +154,9 @@ $(TARGET) : ln -sf ../init.d/suricata /etc/rc.d/rc6.d/K78suricata ln -sf ../init.d/depends-on-network /etc/rc.d/rc6.d/K79depends-on-network ln -sf ../init.d/leds /etc/rc.d/rc6.d/K79leds
- ln -sf ../init.d/network /etc/rc.d/rc6.d/K80network
- ln -sf ../init.d/wlanclient /etc/rc.d/rc6.d/K82wlanclient
- ln -sf ../init.d/network-uplink /etc/rc.d/rc6.d/K80network-uplink
- ln -sf ../init.d/wlanclient /etc/rc.d/rc6.d/K81wlanclient
- ln -sf ../init.d/network-local /etc/rc.d/rc6.d/K82network-local
ln -sf ../init.d/messagebus /etc/rc.d/rc6.d/K85messagebus ln -sf ../init.d/unbound /etc/rc.d/rc6.d/K86unbound ln -sf ../init.d/sysklogd /etc/rc.d/rc6.d/K90sysklogd -- 2.30.2
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 | 37 +++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 16 deletions(-)
diff --git a/src/initscripts/system/network b/src/initscripts/system/network index ff305e472..abbd5bd88 100644 --- a/src/initscripts/system/network +++ b/src/initscripts/system/network @@ -21,6 +21,8 @@
. /etc/sysconfig/rc . ${rc_functions} +. /etc/init.d/networking/functions.network + eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
DO="${1}" @@ -31,34 +33,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 we are called as /etc/init.d/network also red is a configured zone. +# Otherwise we are called as /etc/init.d/network-local where we do +# not need to take care of red 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 +73,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 +81,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 +96,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
See my former email about how to fix this.
I believe this is the third patch in this series that touches the same code by adding/removing arrays and keeping status.
Just use the functions that you have created as it will make this all a lot easier to read and extend whenever necessary.
-Michael
On 23 May 2023, at 18:23, Jonatan Schlag jonatan.schlag@ipfire.org wrote:
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 | 37 +++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 16 deletions(-)
diff --git a/src/initscripts/system/network b/src/initscripts/system/network index ff305e472..abbd5bd88 100644 --- a/src/initscripts/system/network +++ b/src/initscripts/system/network @@ -21,6 +21,8 @@
. /etc/sysconfig/rc . ${rc_functions} +. /etc/init.d/networking/functions.network
eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
DO="${1}" @@ -31,34 +33,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 we are called as /etc/init.d/network also red is a configured zone. +# Otherwise we are called as /etc/init.d/network-local where we do +# not need to take care of red 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 +73,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 +81,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 +96,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 -- 2.30.2
Hello Jonatan,
Thanks for this *huge* patchset.
What I do not quite understand from your email is the motivation for this. Starting the SSH daemon a little bit sooner is not justifying such massive change.
I consider this a highly risky patchset as we are touching code that is already incredibly fragile and the smallest changes might introduce more problems.
But I have to say that I like how you split this into small patches that can be reviewed easier.
On 23 May 2023, at 18:23, Jonatan Schlag jonatan.schlag@ipfire.org wrote:
Hi,
this is the first try for a patch series which makes the startup of local and uplink networks independent. This resolves in the end #11502. It should further allow us to keep waiting for a DHCP lease, because at least our local networks are all up when we get to the red network. This might have some small quirks, even when my testing so far shows no problems. I still think it is now better to share result, then to wait any longer. As this touches quite important parts of our network stack, I might be a could idea to merge this in two stages. After the patch, titled "network startup: Clean up duplicated Code ", might be a good breaking point. But in the end, this is up to you. Please keep in mind, I only tested the full patch set:
Remove ipsec interface creation from network startup Remove Start/Stop links for client175 Use bash as shebang in network initscripts network initscripts: check if the zone in the current config exists network initscripts: Remove code for old zone scheme network scripts: remove check for AUTOCONNECT network startup: Reload routing informations for every interface network startup: Always cleanup before red gets started network startup: check for correct action at start network startup: Refactor how cmd args are processed network startup: Clean up duplicated Code network script: add extra scripts for action that depend on a network network startup: Add scripts for local and uplink network startup: Start local and uplink network independent network startup: Only work with configured zones
config/rootfiles/common/aarch64/initscripts | 31 +++-- config/rootfiles/common/riscv64/initscripts | 31 +++-- config/rootfiles/common/x86_64/initscripts | 31 +++-- lfs/initscripts | 36 +++--- src/initscripts/networking/any | 31 ++++- src/initscripts/networking/functions.network | 14 +- src/initscripts/networking/red | 5 +- .../networking/red.up/99-pakfire-update | 2 +- src/initscripts/system/depends-on-network | 40 ++++++ src/initscripts/system/network | 121 ++++++++---------- 10 files changed, 218 insertions(+), 124 deletions(-) create mode 100644 src/initscripts/system/depends-on-network
Looking forward to your feedback
Greetings Jonatan
Hi list,
Am Mittwoch, dem 24.05.2023 um 09:59 +0100 schrieb Michael Tremer:
Hello Jonatan,
Thanks for this *huge* patchset.
What I do not quite understand from your email is the motivation for this. Starting the SSH daemon a little bit sooner is not justifying such massive change.
Starting the SSH-Daemon earlier was not the only reason. The main reason was
a) to debug problems with the red interface via ssh and via console b) Wait infinitely for a dhcp lease. We currently only wait 30 seconds. If we do not get a lease, red stays down forever.
I consider this a highly risky patchset as we are touching code that is already incredibly fragile and the smallest changes might introduce more problems.
I know that this is a risky patch set. But not touching these code does not improve it. It gets worse each day. Never touch a running system turns against us here. So both change and no change have a risk here.
My further plan for this patch set is to split it up even further. My builder is currently running with all the patches you already agreed to. I will send this patch set in the next days. When this is merged, I will go on to review the other patches.
Greetings Jonatan
But I have to say that I like how you split this into small patches that can be reviewed easier.
On 23 May 2023, at 18:23, Jonatan Schlag jonatan.schlag@ipfire.org wrote:
Hi,
this is the first try for a patch series which makes the startup of local and uplink networks independent. This resolves in the end #11502. It should further allow us to keep waiting for a DHCP lease, because at least our local networks are all up when we get to the red network. This might have some small quirks, even when my testing so far shows no problems. I still think it is now better to share result, then to wait any longer. As this touches quite important parts of our network stack, I might be a could idea to merge this in two stages. After the patch, titled "network startup: Clean up duplicated Code ", might be a good breaking point. But in the end, this is up to you. Please keep in mind, I only tested the full patch set:
Remove ipsec interface creation from network startup Remove Start/Stop links for client175 Use bash as shebang in network initscripts network initscripts: check if the zone in the current config exists network initscripts: Remove code for old zone scheme network scripts: remove check for AUTOCONNECT network startup: Reload routing informations for every interface network startup: Always cleanup before red gets started network startup: check for correct action at start network startup: Refactor how cmd args are processed network startup: Clean up duplicated Code network script: add extra scripts for action that depend on a network network startup: Add scripts for local and uplink network startup: Start local and uplink network independent network startup: Only work with configured zones
config/rootfiles/common/aarch64/initscripts | 31 +++-- config/rootfiles/common/riscv64/initscripts | 31 +++-- config/rootfiles/common/x86_64/initscripts | 31 +++-- lfs/initscripts | 36 +++--- src/initscripts/networking/any | 31 ++++- src/initscripts/networking/functions.network | 14 +- src/initscripts/networking/red | 5 +- .../networking/red.up/99-pakfire-update | 2 +- src/initscripts/system/depends-on-network | 40 ++++++ src/initscripts/system/network | 121 ++++++++-------
10 files changed, 218 insertions(+), 124 deletions(-) create mode 100644 src/initscripts/system/depends-on-network
Looking forward to your feedback
Greetings Jonatan