confd: Add script to wait for an interface

usage: wait-interface wlan0 30
This commit is contained in:
Mattias Walström
2025-06-19 15:23:27 +02:00
parent 0ad8fab5c7
commit 57d5bf1577
2 changed files with 22 additions and 1 deletions
+1 -1
View File
@@ -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
+21
View File
@@ -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