mirror of
https://github.com/kernelkit/infix.git
synced 2026-08-01 13:23:01 +02:00
confd: Add script to wait for an interface
usage: wait-interface wlan0 30
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
pkglibexec_SCRIPTS = bootstrap error load gen-service gen-hostname \
|
||||
gen-interfaces gen-motd gen-hardware gen-version \
|
||||
mstpd-wait-online
|
||||
mstpd-wait-online wait-interface
|
||||
sbin_SCRIPTS = dagger migrate
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
if [ $# -lt 2 ]; then
|
||||
echo "usage: $0 <ifname> <timeout>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ifname=$1
|
||||
timeout=$2
|
||||
while true; do
|
||||
if ip link show $ifname &>/dev/null; then
|
||||
break
|
||||
fi
|
||||
|
||||
retries=$(($retries + 1))
|
||||
if [ $retries -ge $timeout ]; then
|
||||
logger -t wait-interface "Timeout: Interface $ifname not found after $timeout seconds"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sleep 1
|
||||
done
|
||||
Reference in New Issue
Block a user