#!/bin/bash
PING_URL=www.google.com
WAIT_FOR=30 # seconds
trap "exit 1" SIGTERM
sleep $WAIT_FOR && kill $$ &
while ! ping -c1 $PING_URL 2>/dev/null 1>&2; do sleep 1; done
kill %-
exit 0

