aboutsummaryrefslogtreecommitdiff
path: root/minecraft
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2020-10-30 01:00:10 +0100
committerJohn Ankarström <john@ankarstrom.se>2020-10-30 01:00:10 +0100
commitd622b9c0c27f7359cda5aa83fa1b7816bf7981a2 (patch)
tree3c8fd3ce630e1b38c00571d28d0af1a750b4e9cd /minecraft
downloadalpine-d622b9c0c27f7359cda5aa83fa1b7816bf7981a2.tar.gz
Add Minecraft server config
Diffstat (limited to 'minecraft')
-rw-r--r--minecraft/install5
-rw-r--r--minecraft/minecraft30
2 files changed, 35 insertions, 0 deletions
diff --git a/minecraft/install b/minecraft/install
new file mode 100644
index 0000000..7d58d11
--- /dev/null
+++ b/minecraft/install
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+VERSION=1.16.3
+build=`curl +s https://papermc.io/api/v1/paper/$VERSION | sed 's/.*"latest":"\([0-9]*\)".*/\1/'`
+curl -o paper.server.jar https://papermc.io/api/v1/paper/$VERSION/$build/download \ No newline at end of file
diff --git a/minecraft/minecraft b/minecraft/minecraft
new file mode 100644
index 0000000..2bec0d7
--- /dev/null
+++ b/minecraft/minecraft
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+MCPATH=/srv/minecraft
+SESSION=minecraft
+JAR=paper.server.jar
+CMD="java -Xmx1G -Xms1G -jar $JAR nogui"
+
+start() {
+ echo Starting Minecraft server...
+ (cd $MCPATH && screen -h 1024 -dmS $SESSION $CMD)
+}
+
+stop() {
+ if pgrep -f "$JAR" > /dev/null
+ then
+ screen -p 0 -S $SESSION -X eval 'stuff "stop"\015'
+ echo Waiting for Minecraft server to shut down...
+ while pgrep -f "$JAR" > /dev/null
+ do
+ sleep 0.2
+ done
+ fi
+ echo Minecraft server is shut down.
+}
+
+case "$1" in
+ start) start;;
+ stop) stop;;
+# *) echo "Usage: $0 start|stop" 1>&2; exit 2;;
+esac