How-to ensure your Mac waits for internet connection before booting

One common issue among Macs is that the Wowza service tries to fire up prior to network availability.  To avoid this, you might write your own startup script that includes this very check.  This is one (of a million) ways you could check for internet connectivity before startup:

#!/bin/bash

until wget -q -O – http://www.google.com | grep Lucky > /dev/null; do
sleep 10
done

# continue with rest of startup script

This will attempt to load google.com and look for the word “Lucky” in the markup.

Alternatively you could parse the headers in the wget response:

wget -SO- -T 1 -t 1 http://google.com 2>&1 >/dev/null | grep -c “HTTP/1.1 200 OK”

Would return “1″ if found etc.


Comments are closed.