Last active
June 26, 2016 10:17
-
-
Save esolitos/af3e045552a87b513715e854d4a3fe16 to your computer and use it in GitHub Desktop.
Auto restart Mc server with mscs
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 | |
# | |
# 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