upgrading script
This commit is contained in:
parent
f3046ecf48
commit
3b5ebbe665
68
script.sh
68
script.sh
@ -1,58 +1,56 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
echo "Better to run as root, because of permisions handeling."
|
printf "Better to run as root, because of permisions handeling."
|
||||||
|
|
||||||
sleep 2
|
sleep 2
|
||||||
|
|
||||||
echo "Do you want to set up firewall rules by iptables? [Y/n]: "
|
printf "Do you want to set up firewall rules by iptables? [Y/n]: "
|
||||||
read ansFirewallSetup
|
read ansFirewallSetup
|
||||||
|
|
||||||
if [[ "n" != "$ansFirewallSetup" ]]; then
|
|
||||||
echo "\n Do you want to block non-LAN ssh connections? [Y/n/ip range]: "
|
if [[ "$ansFirewallSetup" =~ ("N"|"n") ]]; then
|
||||||
read -n 1 sshBlockRange
|
|
||||||
|
printf "+ Thanks, working on next bit\n"
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
printf "Do you want to block non-LAN ssh connections? [Y/n/ip range]: "
|
||||||
|
read sshBlockRange
|
||||||
|
|
||||||
|
|
||||||
if [[ "$sshBlockRange" == "y"
|
if [[ $sshBlockRange =~ ("n"|"N") ]]; then
|
||||||
||"$sshBlockRange" == "Y"
|
|
||||||
||"$sshBlockRange" == "" ]]; then
|
#$sshBlockRange = ""
|
||||||
|
printf 'N\n'
|
||||||
|
|
||||||
|
elif [[ $sshBlockRange =~ ("y"|"Y") || -z $sshBlockRange ]]; then
|
||||||
|
|
||||||
### Have to found how to locate LAN
|
### Have to found how to locate LAN
|
||||||
$sshBlockRange = "y"
|
#$sshBlockRange = "y"
|
||||||
|
printf 'Y\n'
|
||||||
|
|
||||||
elif [[ "$sshBlockRange" == "n"
|
else
|
||||||
|| "$sshBlockRange" == "N"]]; then
|
printf "\nHope you know what you are doing, I am not checking these :]"
|
||||||
|
printf "\nyou typed $sshBlockRange"
|
||||||
$sshBlockRange = ""
|
sleep 2
|
||||||
|
printf "\nDont worry you will have time to chack if it is looking righ later.\n"
|
||||||
|
|
||||||
elif [[ -n "$sshBlockRange" ]]; then
|
|
||||||
|
|
||||||
echo "Hope you know what you are doing, I am not checking these :]"
|
|
||||||
|
|
||||||
echo "You have 5 seconds to stope this by pressing Ctrl+C"
|
|
||||||
|
|
||||||
sleep 5
|
|
||||||
|
|
||||||
echo "OK, lets go now"
|
|
||||||
|
|
||||||
echo "Dont worry you will have time to chack if it is looking righ later."
|
|
||||||
|
|
||||||
sleep 2
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Just to be shure
|
# Just to be shure
|
||||||
echo "\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
|
||||||
echo "\n+ Installing depandencies \n\n"
|
printf "\n+ Installing depandencies \n\n"
|
||||||
sudo apt install openjdk-17-jre-headless screen p7zip-full iptables -y
|
sudo apt install openjdk-17-jre-headless screen p7zip-full iptables -y
|
||||||
|
|
||||||
# User and groupe managment
|
# User and groupe managment
|
||||||
echo "\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
|
||||||
@ -65,7 +63,7 @@ mv Forge-1.20.1.jar /opt/minecraft/
|
|||||||
cd /opt/minecraft/
|
cd /opt/minecraft/
|
||||||
|
|
||||||
# Installing server
|
# Installing server
|
||||||
echo "+ 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
|
||||||
|
|
||||||
@ -79,16 +77,16 @@ mv run.sh /opt/minecraft
|
|||||||
|
|
||||||
mkdir /opt/minecraft/mods
|
mkdir /opt/minecraft/mods
|
||||||
|
|
||||||
echo "\n+ Unpacking mods \n \n"
|
printf "\n+ Unpacking mods \n \n"
|
||||||
|
|
||||||
7z x Mods.zip -o/opt/minecraft/mods/
|
7z x Mods.zip -o/opt/minecraft/mods/
|
||||||
|
|
||||||
# Permision handeling
|
# Permision handeling
|
||||||
echo "\n+ Permision handeling"
|
printf "\n+ Permision handeling"
|
||||||
chown -R minecraft:minecraft /opt/minecraft
|
chown -R minecraft:minecraft /opt/minecraft
|
||||||
|
|
||||||
# SystemD service
|
# SystemD service
|
||||||
echo "+ Preparign systemD service"
|
printf "+ Preparign systemD service"
|
||||||
cp mc-forge.service /etc/systemd/system/
|
cp mc-forge.service /etc/systemd/system/
|
||||||
|
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
@ -102,7 +100,7 @@ systemctl enable mc-forge
|
|||||||
|
|
||||||
if [[ "n" != "$ansFirewallSetup" ]]; then
|
if [[ "n" != "$ansFirewallSetup" ]]; then
|
||||||
|
|
||||||
echo "+ Executing firewall setup"
|
printf "+ Executing firewall setup"
|
||||||
|
|
||||||
iptables -P INPUT ACCEPT #Clears existing rules
|
iptables -P INPUT ACCEPT #Clears existing rules
|
||||||
|
|
||||||
@ -117,7 +115,7 @@ if [[ "n" != "$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
|
||||||
|
|
||||||
echo "\n Does it looks right? [Y/n]: "
|
printf "\n Does it looks right? [Y/n]: "
|
||||||
read ansFirewallOK
|
read ansFirewallOK
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user