-
-
Save jsnod/1002c4327259e958de19a6c4dd8523a0 to your computer and use it in GitHub Desktop.
Running a Minecraft server as daemon on Amazon Linux
This file contains hidden or 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/bash | |
# | |
# chkconfig: 2345 95 05 | |
# | |
### BEGIN INIT INFO | |
# Provides: minecraft-server | |
# Required-Start: $network $local_fs $remote_fs | |
# Required-Stop: $network $local_fs $remote_fs | |
# Should-Start: $syslog | |
# Should-Stop: $syslog | |
# Short-Description: start and stop minecraft server | |
# Description: Minecraft Server | |
### END INIT INFO | |
# Source function library. | |
. /etc/init.d/functions | |
# Source networking configuration. | |
. /etc/sysconfig/network | |
prog=minecraft-server | |
realprog=startup.sh | |
workingdir=/usr/local/minecraft-server | |
lockfile=/var/lock/subsys/$prog | |
start() { | |
[ "$EUID" != "0" ] && exit 4 | |
[ "$NETWORKING" = "no" ] && exit 1 | |
# Start daemon. | |
echo -n $"Starting $prog: " | |
cd $workingdir | |
daemon $workingdir/$realprog -u minecraft-server:daemon -p /var/run/minecraft-server.pid $OPTIONS | |
RETVAL=$? | |
echo | |
[ $RETVAL -eq 0 ] && touch $lockfile | |
return $RETVAL | |
} | |
stop() { | |
[ "$EUID" != "0" ] && exit 4 | |
echo -n $"Shutting down $prog: " | |
killproc $realprog | |
RETVAL=$? | |
echo | |
[ $RETVAL -eq 0 ] && rm -f $lockfile | |
return $RETVAL | |
} | |
# See how we were called. | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
status) | |
status $prog | |
;; | |
restart|force-reload) | |
stop | |
start | |
;; | |
try-restart|condrestart) | |
if status $prog > /dev/null; then | |
stop | |
start | |
fi | |
;; | |
reload) | |
exit 3 | |
;; | |
*) | |
echo $"Usage: $0 {start|stop|status|restart|try-restart|force-reload}" | |
exit 2 | |
esac |
This file contains hidden or 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 | |
/usr/bin/java -jar /usr/local/minecraft-server/server.jar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment