aboutsummaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorJan Macku <jamacku@redhat.com>2019-03-14 15:53:53 +0100
committerLukáš Nykrýn <lnykryn@redhat.com>2019-04-04 14:25:30 +0200
commit95632676a94a32bfa0a334b8e7f1c0fc87ce1af4 (patch)
tree24d49d0a651650a78d418cdb3a6fed8c5aa18a76 /etc
parent76226a349cd65ec9b511bc68e8f3cf8c291b7057 (diff)
downloadinitscripts-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
Diffstat (limited to 'etc')
-rwxr-xr-xetc/rc.d/init.d/network17
1 files changed, 16 insertions, 1 deletions
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