Created
July 7, 2016 22:19
-
-
Save StefanoBelli/868f668970eb33f5004934dd849d8c83 to your computer and use it in GitHub Desktop.
Gets GitHub server status / last message
This file contains 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/sh | |
if ! which jq 2>/dev/null >>/dev/null; | |
then | |
echo "You need to install jq" | |
exit 2 | |
fi | |
if ! which curl 2>/dev/null >>/dev/null; | |
then | |
echo "You need to install curl" | |
exit 2 | |
fi | |
GHSTATUSAPI="https://status.github.com/api/status.json" | |
GHMSGAPI="https://status.github.com/api/last-message.json" | |
echo -ne '[FETCH-STATUS] \r' | |
status_response=$(curl -L $GHSTATUSAPI 2>/dev/null | jq '.status' 2>/dev/null | sed 's:"::g') | |
echo -ne '[FETCH-MESSAGE] \r' | |
msg_response=$(curl -L $GHMSGAPI 2>/dev/null | jq '.body' 2>/dev/null | sed 's:"::g') | |
if [[ "$status_response" == "" ]] || [[ "$msg_response" == "" ]]; | |
then | |
echo -ne " :( " | |
exit 1 | |
fi | |
echo " ---GitHub service status--- " | |
echo " * Status: $status_response" | |
echo " * Message: $msg_response" | |
echo " --- --- " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment