From 3b5ebbe6651cfa317f9f6e5d98c4a620b9d725e0 Mon Sep 17 00:00:00 2001 From: godot Date: Sun, 14 Jul 2024 17:09:36 +0200 Subject: [PATCH] upgrading script --- script.sh | 68 +++++++++++++++++++++++++++---------------------------- 1 file changed, 33 insertions(+), 35 deletions(-) diff --git a/script.sh b/script.sh index 6d1ab9d..b10f7c7 100755 --- a/script.sh +++ b/script.sh @@ -1,58 +1,56 @@ #!/bin/bash -echo "Better to run as root, because of permisions handeling." +printf "Better to run as root, because of permisions handeling." 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 -if [[ "n" != "$ansFirewallSetup" ]]; then - echo "\n Do you want to block non-LAN ssh connections? [Y/n/ip range]: " - read -n 1 sshBlockRange + +if [[ "$ansFirewallSetup" =~ ("N"|"n") ]]; then + + 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" - ||"$sshBlockRange" == "Y" - ||"$sshBlockRange" == "" ]]; then + if [[ $sshBlockRange =~ ("n"|"N") ]]; then + + #$sshBlockRange = "" + printf 'N\n' + + elif [[ $sshBlockRange =~ ("y"|"Y") || -z $sshBlockRange ]]; then ### Have to found how to locate LAN - $sshBlockRange = "y" + #$sshBlockRange = "y" + printf 'Y\n' - elif [[ "$sshBlockRange" == "n" - || "$sshBlockRange" == "N"]]; then - - $sshBlockRange = "" + else + printf "\nHope you know what you are doing, I am not checking these :]" + printf "\nyou typed $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 # 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 upgrade -y # 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 # User and groupe managment -echo "\n+ Creating user minecraft and basic file structure" +printf "\n+ Creating user minecraft and basic file structure" groupadd 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/ # 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 @@ -79,16 +77,16 @@ mv run.sh /opt/minecraft mkdir /opt/minecraft/mods -echo "\n+ Unpacking mods \n \n" +printf "\n+ Unpacking mods \n \n" 7z x Mods.zip -o/opt/minecraft/mods/ # Permision handeling -echo "\n+ Permision handeling" +printf "\n+ Permision handeling" chown -R minecraft:minecraft /opt/minecraft # SystemD service -echo "+ Preparign systemD service" +printf "+ Preparign systemD service" cp mc-forge.service /etc/systemd/system/ systemctl daemon-reload @@ -102,7 +100,7 @@ systemctl enable mc-forge if [[ "n" != "$ansFirewallSetup" ]]; then - echo "+ Executing firewall setup" + printf "+ Executing firewall setup" 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 - echo "\n Does it looks right? [Y/n]: " + printf "\n Does it looks right? [Y/n]: " read ansFirewallOK