Skip to content

Instantly share code, notes, and snippets.

@dcreager
Created August 22, 2014 10:50
Show Gist options
  • Save dcreager/16223c48d9801656d132 to your computer and use it in GitHub Desktop.
Save dcreager/16223c48d9801656d132 to your computer and use it in GitHub Desktop.
Wait for an interface to have an IP address
#!/bin/sh
INTERFACE=$1
if [ -z $INTERFACE ]; then
echo "Usage: wait-for-interface [interface name]"
exit 1
fi
echo "Wait for $INTERFACE to have an IP address..."
while ! ip addr show $INTERFACE | grep inet >/dev/null; do
# Wait a small amount of time before checking again
sleep 0.1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment