updat to paper

This commit is contained in:
godot 2024-07-20 08:53:56 +02:00
parent 33b9bbc76f
commit c9ddec4703
4 changed files with 94 additions and 12 deletions

View File

@ -2,8 +2,9 @@ To switch user use:
`su minecraft -s /bin/bash` `su minecraft -s /bin/bash`
# To DO # To DO
- [ ] Update mc-perfect to mc-paper needs - [x] Update mc-perfect to mc-paper needs
- [ ] test it - [ ] test it
- [ ] Addons support???
- [ ] move to Velocity proxy - [ ] move to Velocity proxy
- [ ] manual set up of min/max RAM - [ ] manual set up of min/max RAM

View File

@ -8,7 +8,7 @@ WantedBy=multi-user.target
[Service] [Service]
ExecReload=/usr/bin/screen -S minecraft -X stuff \"reload^M\" ExecReload=/usr/bin/screen -S minecraft -X stuff \"reload^M\"
ExecStart=/usr/bin/screen -DmS minecraft ./start.sh ExecStart=/usr/bin/screen -DmS minecraft ./run.sh
ExecStop=/usr/bin/screen -p 0 -S minecraft -X eval 'stuff "say SERVER SHUTTING DOWN. Saving map..."\\015' ExecStop=/usr/bin/screen -p 0 -S minecraft -X eval 'stuff "say SERVER SHUTTING DOWN. Saving map..."\\015'
ExecStop=/bin/sh -c '/bin/sleep 5' ExecStop=/bin/sh -c '/bin/sleep 5'

2
data/run.sh Normal file
View File

@ -0,0 +1,2 @@
#!/bin/bash

View File

@ -48,21 +48,73 @@ elif [[ "$ansFirewallSetup" =~ ("Y"|"y") || -z $ansFirewallSetup ]]; then
fi fi
fi fi
### RAM ###
printf "How much of RAM are you willing to allocate in GB (Max) [4G/?G]: \n"
read maxRam
printf "How little you want to let RAM go down to in GB (Min) [1G/?G]: \n"
read minRam
if [[ "$minRam" > "$maxRam" ]]; then
pritf "\n You allocated too low max ram or too much min ram. Manual intervention at the end will be needed\n"
$xmx=$(echo "-Xmx?G")
$maxRam="Error"
elif [[ "$maxRam" =~ ("G"|"M") ]]; then
printf "\n+ Allocating $maxRam as RAM maximum."
$xmx=$(echo "-Xmx$maxRam")
elif [[ -z $maxRam ]]; then
$maxRam=4G
printf "\n+ Allocating $MaxRam as RAM maximum"
$xmx=$(echo "-Xmx$maxRam")
elif [[ ! "$maxRam" =~ ("G"|"MB") ]]; then
printf "\n+ Allocating ${maxRam}G as RAM maximum"
$xmx=$(echo "-Xmx${maxRam}G")
else
pritnf "\n \n!!! Sorry I have no idea what are you trying to do :/ Manual intervention will be needed at the end \n"
$maxRam="Error"
$xmx=$(echo "-Xmx?G")
fi
if [[ "$minRam" > "$maxRam" ]]; then
$xms=$(echo "-Xms?G")
elif [[ "$minRam" =~ ("G"|"M") ]]; then
printf "\n+ Allocating $minRam as RAM minimum."
$xms=$(echo "-Xms$minRam")
elif [[ -z $minRam ]]; then
$minRam=1G
printf "\n+ Allocating $minRam as RAM minimum"
$xms=$(echo "-Xms$minRam")
elif [[ ! "$minRam" =~ ("G"|"MB") ]]; then
printf "Allocating ${minRam}G as RAM maximum"
$xms=$(echo "-Xms${minRam}G")
else
pritnf "\n!!! Sorry I have no idea what are you trying to do :/ Manual intervention will be needed at the end \n"
$minRam="Error"
$xms=$(echo "-Xms?G")
fi
echo "java ${xmx} ${xms} -jar paper-1.20.6-148.jar --nogui" >> data/run.sh
sleep 2 sleep 2
# Just to be shure # Just to be shure
printf "\n+ Starting to upgrade base system\n\n" printf "\n+ Starting to upgrade base system\n\n"
sudo apt update apt update
sudo apt upgrade -y apt upgrade -y
# Installing depandencies # Installing depandencies
printf "\n+ Installing depandencies \n\n" printf "\n+ Installing depandencies \n\n"
sudo apt install openjdk-21-jre-headless screen -y apt install openjdk-21-jre-headless screen -y
if [[ "$ansFirewallSetup" =~ ("y"|"Y") || -z $ansFirewallSetup ]]; then if [[ "$ansFirewallSetup" =~ ("y"|"Y") || -z $ansFirewallSetup ]]; then
sudo apt install iptables -y apt install iptables -y
fi fi
@ -85,10 +137,14 @@ printf "+ Installing Paper 1.20.6 \n \n"
java -Xms512M -Xmx2048M -jar paper-1.20.6-148.jar --nogui java -Xms512M -Xmx2048M -jar paper-1.20.6-148.jar --nogui
rm eula.txt server.properties
cd - cd -
cd data/ cd data/
mv eula.txt server-icon.png server.properties user_jvm_args.txt /opt/minecraft/
mv eula.txt server-icon.png server.properties run.sh /opt/minecraft/
cd .. cd ..
### Addons support??? ### Addons support???
@ -110,8 +166,6 @@ printf "+ Preparign systemD service\n"
mv data/mc-paper.service /etc/systemd/system/ mv data/mc-paper.service /etc/systemd/system/
systemctl daemon-reload systemctl daemon-reload
systemctl start mc-paper
systemctl enable mc-paper
# integration of Maxopoly's instructions on firewall # integration of Maxopoly's instructions on firewall
@ -133,7 +187,7 @@ if [[ "$ansFirewallSetup" =~ ("Y"|"y") || -z "$ansFirewallSetup" ]]; then
iptables -L ### Good place to paste a manual check to not lock yourself out iptables -L ### Good place to paste a manual check to not lock yourself out
printf "\n Does it looks right? [Y/n]: " printf "\n Does it looks right? [Y/n]: "
read ansFirewallOK read ansFirew`allOK
if [[ "$ansFirewallOK" =~ ("Y"|"y") || -z "$ansFirewallOK" ]]; then if [[ "$ansFirewallOK" =~ ("Y"|"y") || -z "$ansFirewallOK" ]]; then
@ -143,7 +197,7 @@ if [[ "$ansFirewallSetup" =~ ("Y"|"y") || -z "$ansFirewallSetup" ]]; then
iptables -P OUTPUT ACCEPT #Allow all outgouing iptables -P OUTPUT ACCEPT #Allow all outgouing
sudo apt install iptables-persistent -y apt install iptables-persistent -y
else else
@ -155,7 +209,32 @@ if [[ "$ansFirewallSetup" =~ ("Y"|"y") || -z "$ansFirewallSetup" ]]; then
fi fi
### Error handeling ###
if [[ "$minRam" = "Error" || "$maxRam" = "Error" ]]; then
printf "\n Encountred some eror in Ram settings. Manual configuration needed"
printf "\n Open /opt/minecraft/run.sh in your favorite editor. File contains more instructions"
printf "\n After manual interventing all erorrs start server with: systemctl start mc-paper"
printf "\n Automatic start of server you can enable by: systemctl enable mc-paper"
echo "# In place of ? write number of RAM you want to allocate" >> /opt/minecraft/run.sh
echo "# You can always change this number. Remamber to restart server after it" >> /opt/minecraft/run.sh
else
printf "Do you want to start server right now? [Y/n]: \n"
read startServer
if [[ "$startServer" =~ ("y"|"Y") || -z $startServer ]]; then
systemctl start mc-paper.serice
fi
systemctl enable mc-paper
fi
printf "\n+ Done, thanks for your time. It is goode idea to chack if everythink is alright by running:" printf "\n+ Done, thanks for your time. It is goode idea to chack if everythink is alright by running:"
printf "\nsystemctl status mc-forge" printf "\nsystemctl status mc-paper"
printf "\nsu minecraft -s /bin/bash" printf "\nsu minecraft -s /bin/bash"
printf "\n+ it is good idea to have some fun with screen before trying to open minecraft conesole 'screen -r' while loged wia minecraft user" printf "\n+ it is good idea to have some fun with screen before trying to open minecraft conesole 'screen -r' while loged wia minecraft user"