Skip to content

Instantly share code, notes, and snippets.

@esolitos
Last active June 26, 2016 10:17
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 esolitos/af3e045552a87b513715e854d4a3fe16 to your computer and use it in GitHub Desktop.
Save esolitos/af3e045552a87b513715e854d4a3fe16 to your computer and use it in GitHub Desktop.
Auto restart Mc server with mscs
#!/bin/sh
#
# Checks if a server is running, otherwise it restarts it
SERVER=$1
if [ -z "$SERVER" ]; then
echo "Server name not provided!" 1>&2
exit 1
fi
pid="$(cat /opt/mscs/worlds/$SERVER.pid 2>/dev/null)"
if [ -z "$pid" ]; then
echo "Pid is missing, assume manual shutdown, I will not auto-start." 1>&2
exit 2
fi
# Start the server if it's not runing!
if [ ! -z "$(kill -0 $pid 2>&1)" ]; then
/usr/local/bin/mscs start "$SERVER"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment