-
Notifications
You must be signed in to change notification settings - Fork 0
/
vanilla.sh
39 lines (33 loc) · 1017 Bytes
/
vanilla.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
SERVER_LOCATION=/home/pi/mcserver
SERVER_JAR_URL=https://piston-data.mojang.com/v1/objects/f69c284232d7c7580bd89a5a4931c3581eae1378/server.jar
JAVA_AVG_RAM=1024
JAVA_MAX_RAM=1024
SWAP_SIZE=1820
# UPDATE PI
sudo apt update
sudo apt upgrade -y
sudo apt install -y openjdk-17-jre
# MINECRAFT
mkdir -p "${SERVER_LOCATION}"
cd "${SERVER_LOCATION}"
curl -s "${SERVER_JAR_URL}" --output server.jar
## INITIAL RUN AND ACCEPT EULA
java -Xms${JAVA_AVG_RAM}M -Xmx${JAVA_MAX_RAM}M -jar server.jar
sed -i "s|eula=false|eula=true|g" eula.txt
## SETUP STARTUP SCRIPT
cat << DATA > run.sh
#!/bin/bash
cd ${SERVER_LOCATION}
while true
do
java -Xms${JAVA_AVG_RAM}M -Xmx${JAVA_MAX_RAM}M -jar server.jar --nogui >> output.\$(date +%Y%m%d).txt
sleep 10
done
DATA
chmod a+x run.sh
(crontab -u pi -l; echo "@reboot ${SERVER_LOCATION}/run.sh" ) | crontab -u pi -
# INCREASE SWAP
sudo dphys-swapfile swapoff
sudo sed -i "s|CONF_SWAPSIZE=100|CONF_SWAPSIZE=${SWAP_SIZE}|g" /etc/dphys-swapfile
sudo dphys-swapfile swapon
sudo reboot