blob: 3b23f49a1f9ac123817283f89f03f376e8e1c2c4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#!/sbin/openrc-run
name=minecraft
description='Minecraft server'
MCPATH=/srv/minecraft
JAR=$MCPATH/paper.server.jar
CMD="java -Xmx1G -Xms1G -jar $JAR nogui"
SESSION=minecraft
depend() {
use net
}
start() {
if which shiftdown > /dev/null && shiftdown
then
eerror Not starting Minecraft server because Shift is held.
eend 1
return 1
else
ebegin Starting Minecraft server
(cd $MCPATH && screen -h 1024 -dmS $SESSION $CMD)
if pgrep -f "$JAR" > /dev/null
then
eend 0
return 0
else
eend 1
return 1
fi
fi
}
stop() {
if pgrep -f "$JAR" > /dev/null
then
screen -p 0 -S $SESSION -X eval 'stuff "stop"\015'
ebegin Waiting for Minecraft server to shut down
while pgrep -f "$JAR" > /dev/null
do
sleep 0.2
done
fi
einfo Minecraft server is shut down.
eend 0
}
|