Created
November 23, 2012 06:14
-
-
Save kirb/4134217 to your computer and use it in GitHub Desktop.
Bash script to alert when the Apple Store comes back up
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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