Skip to content

Instantly share code, notes, and snippets.

@StefanoBelli
Created July 7, 2016 22:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save StefanoBelli/868f668970eb33f5004934dd849d8c83 to your computer and use it in GitHub Desktop.
Save StefanoBelli/868f668970eb33f5004934dd849d8c83 to your computer and use it in GitHub Desktop.
Gets GitHub server status / last message
#!/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