Skip to content

Instantly share code, notes, and snippets.

@simpleauthority
Last active August 6, 2020 21:51
Show Gist options
  • Save simpleauthority/7d200067ef6425a2de5e15fcd6d6a57f to your computer and use it in GitHub Desktop.
Save simpleauthority/7d200067ef6425a2de5e15fcd6d6a57f to your computer and use it in GitHub Desktop.
Get the latest server.properties from the latest available Paper server
#!/bin/sh
CDIR=$(pwd)
rm -rf /tmp/paper
mkdir /tmp/paper
cd /tmp/paper
echo "Determing latest MC version from Paper..."
curl -s "https://papermc.io/api/v1/paper" | grep '"versions"' | awk -F '"' '{ print $8 }' > ./latest-paper
echo "Latest version is $(cat ./latest-paper)!"
echo "Downloading paperclip.jar..."
curl -sLo ./paperclip.jar "https://papermc.io/api/v1/paper/$(cat ./latest-paper)/latest/download"
echo "Agreeing to the EULA..."
echo "eula=true" > ./eula.txt
echo "Starting the server in the background...(if you ctrl+c, you'll need to kill the PID found in /tmp/paper/paperclip-pid...)"
java -jar paperclip.jar -nogui > /dev/null 2>&1 &
echo $! > ./paperclip-pid
echo "Waiting for server to finish starting..."
for i in {30..1}; do
echo $i
sleep 1
done
echo"Stopping the server..."
kill -15 $(cat ./paperclip-pid)
for i in {15..1}; do
echo $i
sleep 1
done
echo "Going back to original directory..."
cd $CDIR
echo "Copying properties..."
cp /tmp/paper/server.properties ./
echo "Cleaning up..."
rm -rf /tmp/paper
echo "Bye."
Determing latest MC version from Paper...
Latest version is 1.16.1!
Downloading paperclip.jar...
Agreeing to the EULA...
Starting the server in the background...(if you ctrl+c, you'll need to kill the PID found in /tmp/paper/paperclip-pid...)
Waiting for server to finish starting...
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
Stopping the server...
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
Going back to original directory...
Copying properties...
Cleaning up...
Bye.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment