Skip to content

Instantly share code, notes, and snippets.

@kirb
Created November 23, 2012 06:14
Show Gist options
  • Save kirb/4134217 to your computer and use it in GitHub Desktop.
Save kirb/4134217 to your computer and use it in GitHub Desktop.
Bash script to alert when the Apple Store comes back up
#!/bin/bash
isup=0
check=0
store=au # change this to your country code
player=play
sound=/System/Library/Sounds/Tink.aiff
if [[ "$(which afplay)" != "" ]]; then
player=afplay
fi
if [[ -f "/System/Library/Audio/UISounds/Tink.caf" ]]; then
sound=/System/Library/Audio/UISounds/Tink.caf
fi
while [[ "$isup" != "1" ]]; do
check=$((check + 1))
(curl -I "http://store.apple.com/$store" | grep -E "^HTTP/1.1 503") > /dev/null 2>/dev/null
if [[ $? != 0 ]]; then
echo "$(date): STORE IS UP - checked $check times"
isup=1
"$player" "$sound"
"$player" "$sound"
else
echo -n .
sleep 90
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment