Skip to content

Instantly share code, notes, and snippets.

@necrogami
Last active November 11, 2016 15:31
Show Gist options
  • Select an option

  • Save necrogami/2c21d25ee8ba5ded4eb44c5fe89bf0ae to your computer and use it in GitHub Desktop.

Select an option

Save necrogami/2c21d25ee8ba5ded4eb44c5fe89bf0ae to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ ! -f state ]; then
echo "File not found!"
echo "STATE=false" > state
fi
source state
if [ $STATE = true ] ; then
if screen -list | grep -q "mc-"; then
echo "STATE=true" > state
else
LAST_FILE=`find mc-instances/mc-5813b2829f193/crash-reports/ -cmin -2|tail -n 1`
if [ -n "$LAST_FILE" ] ; then
THEDATA=`cat $LAST_FILE`
PASTEBIN=`curl http://pastie.org/pastes -H 'Expect:' -F 'paste[parser]=plaintext' -F "paste[body]=$THEDATA" -F 'paste[authorization]=burger' -F 'paste[restricted]=1' -s -L -o /dev/null -w '%{url_effective}'`
curl -X POST --data-urlencode 'payload={"channel": "#subservers", "parse": "full", "username": "wyldlifeserver", "text": "@themattabase, @necrogami, @wyld the check script has failed to find the server and it is presumed down. The pastebin url is: '"${PASTEBIN}"'", "icon_emoji": ":ghost:"}' https://hooks.slack.com/services/<redacted>
else
curl -X POST --data-urlencode 'payload={"channel": "#subservers", "parse": "full", "username": "wyldlifeserver", "text": "@themattabase, @necrogami, @wyld the check script has failed to find the server and it is presumed down.", "icon_emoji": ":ghost:"}' https://hooks.slack.com/services/<redacted>
fi
echo "STATE=false" > state
fi
fi
if [ $STATE = false ] ; then
if screen -list | grep -q "mc-"; then
curl -X POST --data-urlencode 'payload={"channel": "#subservers", "parse": "full", "username": "wyldlifeserver", "text": "The server has returned. :wyldHeart:", "icon_emoji": ":ghost:"}' https://hooks.slack.com/services/<redacted>
echo "STATE=true" > state
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment