summaryrefslogtreecommitdiff
path: root/udev/cloud-init-wait
diff options
context:
space:
mode:
Diffstat (limited to 'udev/cloud-init-wait')
-rwxr-xr-xudev/cloud-init-wait13
1 files changed, 5 insertions, 8 deletions
diff --git a/udev/cloud-init-wait b/udev/cloud-init-wait
index 7d53dee4..9df502e3 100755
--- a/udev/cloud-init-wait
+++ b/udev/cloud-init-wait
@@ -3,16 +3,13 @@
CI_NET_READY="/run/cloud-init/network-config-ready"
LOG="/run/cloud-init/${0##*/}.log"
LOG_INIT=0
+MAX_WAIT=60
DEBUG=0
block_until_ready() {
- local fname="$1"
- local naplen="$2" max="$3" n=0
- while ! [ -f "$fname" ]; do
- n=$(($n+1))
- [ "$n" -ge "$max" ] && return 1
- sleep $naplen
- done
+ local fname="$1" max="$2"
+ [ -f "$fname" ] && return 0
+ udevadm settle "--timeout=$max" "--exit-if-exists=$fname"
}
log() {
@@ -56,7 +53,7 @@ main() {
return 0
fi
- block_until_ready "$readyfile" .1 600 ||
+ block_until_ready "$readyfile" "$MAX_WAIT" ||
{ log "failed waiting for ready on $INTERFACE"; return 1; }
log "net config ready"