diff --git a/script.sh b/script.sh index b10f7c7..2c06786 100755 --- a/script.sh +++ b/script.sh @@ -8,36 +8,47 @@ printf "Do you want to set up firewall rules by iptables? [Y/n]: " read ansFirewallSetup + 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]: " + printf "Do you want to block non-LAN ssh connections? [Y/n/castom]: " read sshBlockRange if [[ $sshBlockRange =~ ("n"|"N") ]]; then - #$sshBlockRange = "" - printf 'N\n' + printf "+ OK, working on next bit\n" + ipList="" elif [[ $sshBlockRange =~ ("y"|"Y") || -z $sshBlockRange ]]; then - ### Have to found how to locate LAN - #$sshBlockRange = "y" - printf 'Y\n' + #Pipes all informations about ip interfaces + ipList=$(ip -o -4 a show scope global) + + #Founds data in pattern + ipList=$(echo $ipList | grep -Eo "([0-9]*\.){3}[0-9]*/[0-9]*") + + #substitues space for coma + ipList=$(echo $ipList | tr " " ",") + + printf "+ Accepting SSH connections only on these ip's: $ipList\n" + 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" - + + printf "\nSubmit your IP range to acces SSH in format 192.168.1.1/24 + \nYour IP range: " + read ipList + printf "\n+ Allowing SSH on this range: $ipList \n" fi fi +sleep 2 # Just to be shure printf "\n+ Starting to upgrade base system\n\n"