RAM integration

This commit is contained in:
godot 2024-07-19 09:24:39 +02:00
parent 10a345008a
commit 9137a8faa9

View File

@ -4,6 +4,8 @@ printf "Better to run as root, because of permisions handeling.\n"
sleep 2 sleep 2
### Firewall ###
printf "Do you want to set up firewall rules by iptables? [Y/n]: \n" printf "Do you want to set up firewall rules by iptables? [Y/n]: \n"
read ansFirewallSetup read ansFirewallSetup
@ -48,15 +50,68 @@ else
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"
echo "-Xmx?G # in place of ? put number of RAM you want to set ass maximum"
$maxRam="Error"
elif [[ "$maxRam" =~ ("G"|"M") ]]; then
printf "\n+ Allocating $maxRam as RAM maximum."
echo "-Xmx$maxRam" >> data/user_jvm_args.txt
elif [[ -z $maxRam ]]; then
$maxRam=4G
printf "\n+ Allocating $MaxRam as RAM maximum"
echo "-Xmx$maxRam" >> data/user_jvm_args.txt
elif [[ ! "$maxRam" =~ ("G"|"MB") ]]; then
printf "\n+ Allocating ${maxRam}G as RAM maximum"
echo "-Xmx${maxRam}G" >> data/user_jvm_args.txt
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"
echo "-Xmx?G # in place of ? put number of RAM you want to set ass maximum"
fi
if [[ "$minRam" > "$maxRam" ]]; then
echo "-Xms?G # in place of ? put number of RAM you want to se ass minimum"
elif [[ "$minRam" =~ ("G"|"M") ]]; then
printf "\n+ Allocating $minRam as RAM minimum."
echo "-Xms$minRam" >> data/user_jvm_args.txt
elif [[ -z $minRam ]]; then
$minRam=1G
printf "\n+ Allocating $minRam as RAM minimum"
echo "-Xms$minRam" >> data/user_jvm_args.txt
elif [[ ! "$minRam" =~ ("G"|"MB") ]]; then
printf "Allocating ${minRam}G as RAM maximum"
echo "-Xms${minRam}G" >> data/user_jvm_args.txt
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"
echo "-Xms?G # in place of ? put number of RAM you want to set ass minimum"
fi
sleep 2 sleep 2
# Just to be shure ### Update ###
printf "\n+ Starting to upgrade base system\n\n" printf "\n+ Starting to upgrade base system\n\n"
sudo apt update sudo apt update
sudo apt upgrade -y sudo apt upgrade -y
# Installing depandencies ### Installing depandencies ###
printf "\n+ Installing depandencies \n\n" printf "\n+ Installing depandencies \n\n"
sudo apt install openjdk-17-jre-headless screen p7zip-full -y sudo apt install openjdk-17-jre-headless screen p7zip-full -y
@ -66,20 +121,20 @@ if [[ "$ansFirewallSetup" =~ ("Y"|"y") || -z $ansFirewallSetup ]]; then
fi fi
# User and groupe managment ### User and groupe managment ###
printf "\n+ Creating user minecraft and basic file structure" printf "\n+ Creating user minecraft and basic file structure"
groupadd minecraft groupadd minecraft
useradd --system --shell /usr/sbin/nologin --home /opt/minecraft -g minecraft minecraft useradd --system --shell /usr/sbin/nologin --home /opt/minecraft -g minecraft minecraft
# File strukture and basic install ### File strukture ###
mkdir /opt/minecraft mkdir /opt/minecraft
mv data/Forge-1.20.1.jar /opt/minecraft/ mv data/Forge-1.20.1.jar /opt/minecraft/
cd /opt/minecraft/ cd /opt/minecraft/
# Installing server ### Installing server ###
printf "+ Installing Forge 1.20.1 \n \n" printf "+ Installing Forge 1.20.1 \n \n"
java -Xms512M -Xmx2048M -jar Forge-1.20.1.jar --installServer java -Xms512M -Xmx2048M -jar Forge-1.20.1.jar --installServer
@ -98,20 +153,17 @@ cd data
7z x Mods.zip -o/opt/minecraft/mods/ 7z x Mods.zip -o/opt/minecraft/mods/
cd .. cd ..
# Permision handeling ### Permisions ###
printf "\n+ Permision handeling\n" printf "\n+ Permision handeling\n"
chown -R minecraft:minecraft /opt/minecraft chown -R minecraft:minecraft /opt/minecraft
# SystemD service ### SystemD service ###
printf "+ Preparign systemD service\n" printf "+ Preparign systemD service\n"
mv data/mc-forge.service /etc/systemd/system/ mv data/mc-forge.service /etc/systemd/system/
systemctl daemon-reload systemctl daemon-reload
systemctl start mc-forge.service
systemctl enable mc-forge
### integration of Maxopoly's instructions on firewall ###
# integration of Maxopoly's instructions on firewall
if [[ "$ansFirewallSetup" =~ ("Y"|"y") || -z "$ansFirewallSetup" ]]; then if [[ "$ansFirewallSetup" =~ ("Y"|"y") || -z "$ansFirewallSetup" ]]; then
@ -148,9 +200,17 @@ if [[ "$ansFirewallSetup" =~ ("Y"|"y") || -z "$ansFirewallSetup" ]]; then
printf "\nAfter you are done ramamber to run 'apt install iptables-persistent' to save your config. System will automaticly remove your work after restart" printf "\nAfter you are done ramamber to run 'apt install iptables-persistent' to save your config. System will automaticly remove your work after restart"
fi fi
fi
### Error handeling ###
if [[ "$minRam" = "Error" || "$maxRam" = "Error" ]]; then
printf "\n Encountred some eror in Ram settings"
pritnf "\n Manual configuration needed"
printf "\n Open /opt/minecraft/user_jvm_args.txt in your favorite editor. File contains more instructions"
else
systemctl start mc-forge.service
systemctl enable mc-forge
fi 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:"