aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/sysconfig.txt7
-rwxr-xr-xetc/rc.d/init.d/network17
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