Question, is my interpretation of the chain of events correct?
At the end of the boot process, rc.local will be executed as the last script to run. Then, the inner parentheses will create a sub-shell, where there will be an instruction to wait for 10 min and then a restart of the network interfaces. The ampersand & puts this subshell in the background and forks again, further distancing from the initial process. This “double-forking” ensures that the process will continue to run even when the terminal or shell that launched it is closed because the process, if orphaned, will be adopted by PID 1 (init process).
I’m far, far away of being an expert of IPFire. I installed IPFire about 3 hours ago for the first time (in some virtual machine) to take a closer look at it. Nor I’m an expert of the Linux OS - I have just gained some experience with it while using it for… a longer period of time
…as far as I know:
yes - normal boot (to a command line interface) enters runlevel 3. All scripts in /etc/rc.d/rc3.d will be processed in alphabetical order and the last entry in this directory “S98rc.local” is a link to this rc.local script
…and yes - this was the idea behind but it does not work the way it was supposed to It still works but if the parent process gets a kill signal, the child process completes the sleep command but gets killed right after the sleep finishes and the rest is skipped But since there is no watchdog mechanism to kill the parent process it still works. The rc.d scripts are called with the sh interpreter and not with bash - maybe that’s the problem…
this means that the kill signal is also sent to the child process. Since sleep is a blocking command the child process should continue sleeping for the specified duration. Once the sleep command completes, the child process will check for pending signals. If a kill signal is pending, the child process will be terminated before it has a chance to execute the next command. Maybe a TRAP can prevent the kill signal to propagate to the child process?
Hello,
I was notified of this thread because someone linked to the thread I raised years ago. I still have the problem that I reported there, so I worked around it with the following script.
This is saved as /usr/local/bin/pingcheck.sh and linked in to the /etc/fcron.minutely/ directory.
#!/bin/bash
#
########################################################################
# Begin
#
# Description : Gateway ping check
#
# Authors : DNL
#
# Version : 01.20
#
# Notes : Designed to run regularly from cron. Restarts red0
# network if unable to ping ISP's router.
#
########################################################################
PING_TIMEOUT=5
MAX_RETRIES=4
ATTEMPT=0
# Don't run in the first 120 seconds after IPFire has booted
if [[ $( cut -d'.' -f1 /proc/uptime ) -gt 120 ]]; then
RED_TYPE=$(grep RED_TYPE /var/ipfire/ethernet/settings | cut -d'=' -f2)
REMOTE_IP=$(cat /var/ipfire/red/remote-ipaddress)
if [[ "$RED_TYPE" == "DHCP" ]]; then
while [[ $ATTEMPT -le $MAX_RETRIES ]]; do
if ping -q -c 1 -w $PING_TIMEOUT "${REMOTE_IP}" &>/dev/null
then
# Connection is up - exit quietly
exit 0
else
ATTEMPT=$(( ATTEMPT+1 ))
sleep $PING_TIMEOUT
fi
done
logger -p local0.info -t pingcheck.sh[$$] "Unable to ping upstream router. Restarting RED connection"
# try `connscheduler reconnect` first instead of restarting the network. - sadly it does not work for me.
#/usr/local/bin/connscheduler reconnect > /dev/null
/etc/init.d/network stop
# DEBUG logger -p local0.info -t pingcheck.sh[$$] "Stopping red connection returned $?"
# DEBUG logger -p local0.info -t pingcheck.sh[$$] "Starting red connection"
/etc/init.d/network start
fi
fi
This cron job has run on my system since that thread years ago and has proven to be reliable. EDIT: @arne_f 's tip of running connsheduler reconnect sadly does not work at all for me, so I have resorted back to a full network stop/start. Perhaps the problem I have is related to what the connscheduler script does?
Thanks for the tip about modifying the timeout in /var/ipfire/dhcpc/dhcpcd.conf@bonnietwin . EDIT: I tried it just now at 120 and it still failed to work. Two minutes seems like a very long time, but given that connscheduler reconnect fails for me perhaps I have another issue.
It is true, that ISPs tend to go their own way on supplying DOCSIS based internet.
The basic idea of IP assignment of a DOCSIS modem ( CPE ) is
while the connection to the CMTS isn’t up, the modem works as a DHCP server in the 192.168.100.0/24 network ( lease time short, 30s for example )
when the connection is established, the DHCP server stops. DHCP requests are forwarded to the ISP DHCP server.
renewing the private IP with short lease time, results in the detection of the internet connection by a RENEW/NAK/DISCOVER/OFFER sequence resulting in a public IP.
dhcpcd handles this procedure right.
Problem is that some DHCP servers of ISPs do not implement the simple algorithm explained above.
ISPs further tend to not providing a simple modem ( or a router with bridge mode ), but router with its behaviour of its own ( defined by ISP ). A router should handle the process much easier ( supply a private address, which doesn’t change independent of the online status of the WAN side ).
Obviously there are problems on the ISP side, which should be solved on the side. There is no save procedure in IPFire to circumvent these problems. My opinion.
I went through backups and I had previously tried /etc/init.d/network stop red and /etc/init.d/network start red, however it wasn’t as reliable as restarting all networking.
When I’m able I’ll try that and see if there’s any difference in the shell scripts.
So in my opinion people are using the wrong tool for the job by making ipfire do the work…
I would suggest buying something like this:
It has programable outlets (if I picked the right one!) where it does the above list. There are others but this is the one I could find quickly. FYI don’t search for just “watchdog”. You will get LOTS of entries for “basement water watchdog”.
Can you explain how to do this to a non-ipfire expert, please? I can work with putty, but I’m not familiar with Linux and have to google every command.
I’m not speaking on behalf of the development team, but based on my understanding, it’s unlikely that this script will be integrated into the standard release. The script serves specific needs and isn’t universally applicable. Adding it as a checkbox in the Web User Interface would entail discussions, coding, and rigorous testing—resources that could be spent on more pressing issues. For now, your best option is to adapt the script for your own setup and include it in your backups. If you need further guidance, feel free to ask.
It seems, that it’s a widely present problem with cable modems. Maybe lots of users even do not know, why ipfire does not connect after a reboot of the cable modem (and ipfire [at the same time]).
I’m not an expert, too, but maybe the DevTeam can have a look at this issue at all. (BTW, how about other systems like pfsense in this situations? Do they all have this problem? If not, why? Shouldn’t ipfire provide as much support to the user as needed to have a stable connection?)