-
Notifications
You must be signed in to change notification settings - Fork 0
/
papermc.sh
executable file
·50 lines (43 loc) · 1.18 KB
/
papermc.sh
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
48
49
50
#!/bin/bash
# Set umask
umask 0007
# Enter server directory
cd papermc
# Get version information and build download URL and jar name
URL=https://papermc.io/api/v2/projects/paper
if [ ${MC_VERSION} = latest ]
then
# Get the latest MC version
MC_VERSION=$(wget -qO - $URL | jq -r '.versions[-1]') # "-r" is needed because the output has quotes otherwise
fi
URL=${URL}/versions/${MC_VERSION}
if [ ${PAPER_BUILD} = latest ]
then
# Get the latest build
PAPER_BUILD=$(wget -qO - $URL | jq '.builds[-1]')
fi
JAR_NAME=paper-${MC_VERSION}-${PAPER_BUILD}.jar
URL=${URL}/builds/${PAPER_BUILD}/downloads/${JAR_NAME}
# Update if necessary
if [ ! -e ${JAR_NAME} ]
then
# Remove old server jar(s)
rm -f *.jar
# Download new server jar
wget ${URL} -O ${JAR_NAME}
# If this is the first run, accept the EULA
if [ ! -e eula.txt ]
then
# Run the server once to generate eula.txt
java -jar ${JAR_NAME}
# Edit eula.txt to accept the EULA
sed -i 's/false/true/g' eula.txt
fi
fi
# Add RAM options to Java options if necessary
if [ ! -z "${MC_RAM}" ]
then
JAVA_OPTS="-Xms${MC_RAM} -Xmx${MC_RAM} ${JAVA_OPTS}"
fi
# Start server
exec java -server ${JAVA_OPTS} -jar ${JAR_NAME} nogui