Last active
April 5, 2023 17:22
-
-
Save troeger/649166137f8086474fd5d14122707c6f 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
Installation guide:
minecraft-server
into/etc/init.d
./usr/local/minecraft-server/
.startup.sh
into/usr/local/minecraft-server/
.useradd --home-dir /usr/local/minecraft-server --no-create-home -g daemon --shell /bin/false minecraft-server
/usr/local/minecraft-server/
. The kids often demand specific versions for their hacks / mods / skins, https://mcversions.net is your friend.startup.sh
manually once, so that the server application creates all config files in their default version. Editeula.txt
as you've been told./usr/local/minecraft-server/ops.json
(see here) for playing god. http://minecraft-techworld.com/uuid-lookup-tool is your friend.chkconfig --add minecraft-server
once.