diff options
author | Jan Macku <jamacku@redhat.com> | 2019-03-14 15:53:53 +0100 |
---|---|---|
committer | Lukáš Nykrýn <lnykryn@redhat.com> | 2019-04-04 14:25:30 +0200 |
commit | 95632676a94a32bfa0a334b8e7f1c0fc87ce1af4 (patch) | |
tree | 24d49d0a651650a78d418cdb3a6fed8c5aa18a76 | |
parent | 76226a349cd65ec9b511bc68e8f3cf8c291b7057 (diff) | |
download | initscripts-95632676a94a32bfa0a334b8e7f1c0fc87ce1af4.tar initscripts-95632676a94a32bfa0a334b8e7f1c0fc87ce1af4.tar.gz initscripts-95632676a94a32bfa0a334b8e7f1c0fc87ce1af4.tar.bz2 initscripts-95632676a94a32bfa0a334b8e7f1c0fc87ce1af4.tar.xz initscripts-95632676a94a32bfa0a334b8e7f1c0fc87ce1af4.zip |
Add option to wait until target is reachable
Add option for time saving waiting
Replace date with simple timeout
Rename configurable variable and add documentation
Print log only when didn't reach IP address in time
Add support for IPv6 address
Remove unneeded output
Change -ge to -gt, because equal value is ok
Clarify DNS name option in documentation
-rw-r--r-- | doc/sysconfig.txt | 7 | ||||
-rwxr-xr-x | etc/rc.d/init.d/network | 17 |
2 files changed, 23 insertions, 1 deletions
diff --git a/doc/sysconfig.txt b/doc/sysconfig.txt index 891a10eb..a848ba42 100644 --- a/doc/sysconfig.txt +++ b/doc/sysconfig.txt @@ -152,6 +152,13 @@ Generic options: network has spanning tree running and must wait for STP convergence. Default: 0 (no delay) + WAIT_UNTIL_REACHABLE=<IP address|DNS name> + Network initscript will wait until specified target is reachable. + It starts to reaching passed IP address or DNS name every second until it reach it sucessfully or until it reach preset delay NETWORKDELAY (default 30). + It works with both IPv4 and IPv6 adress and also with DNS name. + Example: WAIT_UNTIL_REACHABLE=8.8.8.8 + Default: (not set) + IFDOWN_ON_SHUTDOWN=yes|no If yes, do bring interfaces down during system shutdown. If no, leave them in their current state (this is only supported on hosts using systemd). diff --git a/etc/rc.d/init.d/network b/etc/rc.d/init.d/network index ade227ef..2b874d17 100755 --- a/etc/rc.d/init.d/network +++ b/etc/rc.d/init.d/network @@ -163,7 +163,22 @@ start) touch /var/lock/subsys/network - [ -n "${NETWORKDELAY}" ] && /bin/sleep ${NETWORKDELAY} + # Fixed delay + [ -n "${NETWORKDELAY}" ] && [ -z "${WAIT_UNTIL_REACHABLE}" ] && /bin/sleep "${NETWORKDELAY}" + + # Adaptive delay + # It tests if network connection is ready via ping + if [ -n "${WAIT_UNTIL_REACHABLE}" ] ; then + [ -z "${NETWORKDELAY}" ] && NETWORKDELAY=30 + TIMEOUT=0 + IPV="" + ipcalc -c -6 "${WAIT_UNTIL_REACHABLE}" &>/dev/null && IPV="-6" + while [ $TIMEOUT -le $NETWORKDELAY ] ; do + ping $IPV -q -c 1 -W 1 "${WAIT_UNTIL_REACHABLE}" >/dev/null && break + TIMEOUT=$(( TIMEOUT + 1 )) + done + [ $TIMEOUT -gt $NETWORKDELAY ] && net_log $"Target is not reachable, but timeout was already reached. Continuing anyway." + fi ;; stop) [ "$EUID" != "0" ] && exit 4 |