Skip to content

Instantly share code, notes, and snippets.

@abelbeck
Last active September 22, 2017 00:42
Show Gist options
  • Save abelbeck/5f2b6e0c23ffc0394826cd4681a35879 to your computer and use it in GitHub Desktop.
Save abelbeck/5f2b6e0c23ffc0394826cd4681a35879 to your computer and use it in GitHub Desktop.
Startup delay using /mnt/kd/rc.elocal
#!/bin/sh
. /etc/rc.conf
## External target IPv4 host address, *not* a DNS name
TARGET_HOST="${IPCSOLUTIONS_TARGET_HOST:-8.8.4.4}"
## Approximate max seconds to delay
MAX_DELAY=120
echo -n "Probing external host '$TARGET_HOST' "
finish_msg=" failed."
cnt=$MAX_DELAY
while [ $cnt -gt 0 ]; do
fping -c 2 -t 1000 -p 1000 $TARGET_HOST >/dev/null 2>&1
rtn=$?
## Reachable
if [ $rtn -eq 0 ]; then
finish_msg=" reachable."
break
fi
## IP not found error
if [ $rtn -eq 2 ]; then
sleep 2
fi
echo -n "."
cnt=$((cnt - 2))
done
echo "$finish_msg"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment