Last active
December 14, 2015 14:08
-
-
Save magcks/5098315 to your computer and use it in GitHub Desktop.
Debian minecraft startup script.http://www.minecraftwiki.net/wiki/Tutorials/Server_startup_script
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 | |
# Minecraft | |
# conf | |
DIR="/home/minecraft" # the root directory of the minecraft server | |
SCRIPT="./starter.sh" # the script which executes the jar | |
NAME="minecraft" # screen name | |
screen=$(which screen) | |
function start { | |
echo -n "Starting minecraft" | |
cd $DIR && $screen -dmS $NAME $SCRIPT | |
echo "." | |
} | |
function stop { | |
echo -n "Stopping minecraft" | |
$screen -p 0 -S $NAME -X eval 'stuff "say SERVER SHUTTING DOWN IN 10 SECONDS. Saving map..."\015' | |
$screen -p 0 -S $NAME -X eval 'stuff "save-all"\015' | |
sleep 10 | |
$screen -p 0 -S $NAME -X eval 'stuff "stop"\015' | |
echo "." | |
} | |
function reload { | |
echo -n "Reloading minecraft" | |
$screen -p 0 -S $NAME -X eval 'stuff "reload"\015' | |
echo "." | |
} | |
function restart { | |
stop | |
start | |
} | |
case "$1" in | |
start) start | |
;; | |
stop) stop | |
;; | |
reload) reload | |
;; | |
restart) | |
restart | |
;; | |
*) echo "Usage: ./minecraft.sh (start|restart|stop|reload)" | |
exit 1 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment