shorewall_code/Shorewall/wait4ifup
teastep a0b42400a3 Add wait4ifup
git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@5180 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb
2007-01-01 00:40:42 +00:00

29 lines
372 B
Bash
Executable File

#!/bin/sh
#
# Determine if Interface is up
#
interface_is_up() {
[ -n "$(ip link ls dev $1 | grep -e '[<,]UP[,>]')" ]
}
case $# in
1)
timeout=60
;;
2)
timeout=$2
;;
*)
echo "usage: $(basename $0) <interface> [ <timeout> ]"
exit 2
;;
esac
while [ $timeout -gt 0 ] && ! interface_is_up $1; do
sleep 1
timeout=$(( $timeout - 1 ))
done