Skip to content

Instantly share code, notes, and snippets.

@Tschrock
Created July 30, 2014 06:21
Show Gist options
  • Save Tschrock/449c99dba32eb402a503 to your computer and use it in GitHub Desktop.
Save Tschrock/449c99dba32eb402a503 to your computer and use it in GitHub Desktop.
A simple bash script to check status.mojang.com and print out the server statuses (in color!)
#!/bin/bash
CM_STATUS_JSON=$(curl -s https://status.mojang.com/check)
CM_STATUS_TEXT=$(echo "$CM_STATUS_JSON" | grep -o -P "{.*?}" | sed -e "s/\(\"\|{\|}\)//g" -e "s/\:/: /g")
CM_STATUS_COLORED=$(echo "$CM_STATUS_TEXT" | sed -e 's/\://g' \
-r -e 's/([^ ]*) (.* )?(.*$)/\3 \1/' \
-e "s/green /$(echo -e '\033[0;32m')/" \
-e "s/red /$(echo -e '\033[0;31m')/" \
-e "s/yellow /$(echo -e '\033[0;33m')/" && echo -en '\033[0m')
echo -n "$CM_STATUS_COLORED"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment