diff options
author | Toby Humphrey <toby00001@users.noreply.github.com> | 2017-06-05 22:55:30 +0300 |
---|---|---|
committer | Daniel Hansson <daniel@techandme.se> | 2017-06-05 22:55:30 +0300 |
commit | acccb8a8e1b4dd8b81f1de45b234b95cfa63170f (patch) | |
tree | ab572530c47dfa32ae4a06e2b899316abe6193c3 /apps | |
parent | 671f71c7a0f3e7663244d9986d89ce578adaadc1 (diff) |
Nmap retention model (#252)
Diffstat (limited to 'apps')
-rw-r--r-- | apps/collabora.sh | 32 | ||||
-rw-r--r-- | apps/onlyoffice.sh | 32 |
2 files changed, 54 insertions, 10 deletions
diff --git a/apps/collabora.sh b/apps/collabora.sh index 6ca34592..faf97fbb 100644 --- a/apps/collabora.sh +++ b/apps/collabora.sh @@ -70,29 +70,51 @@ else exit 1 fi -# Check if 443 is open using nmap, if not notify the user +# Check to see if user already has nmap installed on their system +if [ "$(dpkg-query -s nmap 2> /dev/null | grep -c "ok installed")" == "1" ] +then + NMAPSTATUS=preinstalled +fi + apt update -q4 & spinner_loading -if [ "$(dpkg-query -W -f='${Status}' nmap 2>/dev/null | grep -c "ok installed")" == "1" ] +if [ "$NMAPSTATUS" = "preinstalled" ] then echo "nmap is already installed..." else apt install nmap -y fi + +# Check if 443 is open using nmap, if not notify the user if [ "$(nmap -sS -p 443 "$WANIP4" | grep -c "open")" == "1" ] then printf "${Green}Port 443 is open on $WANIP4!${Color_Off}\n" - apt remove --purge nmap -y + if [ "$NMAPSTATUS" = "preinstalled" ] + then + echo "nmap was previously installed, not removing" + else + apt remove --purge nmap -y + fi else echo "Port 443 is not open on $WANIP4. We will do a second try on $SUBDOMAIN instead." any_key "Press any key to test $SUBDOMAIN... " if [[ "$(nmap -sS -PN -p 443 "$SUBDOMAIN" | grep -m 1 "open" | awk '{print $2}')" = "open" ]] then printf "${Green}Port 443 is open on $SUBDOMAIN!${Color_Off}\n" - apt remove --purge nmap -y + if [ "$NMAPSTATUS" = "preinstalled" ] + then + echo "nmap was previously installed, not removing" + else + apt remove --purge nmap -y + fi else whiptail --msgbox "Port 443 is not open on $SUBDOMAIN. Please follow this guide to open ports in your router: https://www.techandme.se/open-port-80-443/" "$WT_HEIGHT" "$WT_WIDTH" any_key "Press any key to exit... " - apt remove --purge nmap -y + if [ "$NMAPSTATUS" = "preinstalled" ] + then + echo "nmap was previously installed, not removing" + else + apt remove --purge nmap -y + fi exit 1 fi fi diff --git a/apps/onlyoffice.sh b/apps/onlyoffice.sh index 03903dd3..c71467d9 100644 --- a/apps/onlyoffice.sh +++ b/apps/onlyoffice.sh @@ -78,29 +78,51 @@ else exit 1 fi -# Check if 443 is open using nmap, if not notify the user +# Check to see if user already has nmap installed on their system +if [ "$(dpkg-query -s nmap 2> /dev/null | grep -c "ok installed")" == "1" ] +then + NMAPSTATUS=preinstalled +fi + apt update -q4 & spinner_loading -if [ "$(dpkg-query -W -f='${Status}' nmap 2>/dev/null | grep -c "ok installed")" == "1" ] +if [ "$NMAPSTATUS" = "preinstalled" ] then echo "nmap is already installed..." else apt install nmap -y fi + +# Check if 443 is open using nmap, if not notify the user if [ "$(nmap -sS -p 443 "$WANIP4" | grep -c "open")" == "1" ] then printf "${Green}Port 443 is open on $WANIP4!${Color_Off}\n" - apt remove --purge nmap -y + if [ "$NMAPSTATUS" = "preinstalled" ] + then + echo "nmap was previously installed, not removing" + else + apt remove --purge nmap -y + fi else echo "Port 443 is not open on $WANIP4. We will do a second try on $SUBDOMAIN instead." any_key "Press any key to test $SUBDOMAIN... " if [[ "$(nmap -sS -PN -p 443 "$SUBDOMAIN" | grep -m 1 "open" | awk '{print $2}')" = "open" ]] then printf "${Green}Port 443 is open on $SUBDOMAIN!${Color_Off}\n" - apt remove --purge nmap -y + if [ "$NMAPSTATUS" = "preinstalled" ] + then + echo "nmap was previously installed, not removing" + else + apt remove --purge nmap -y + fi else whiptail --msgbox "Port 443 is not open on $SUBDOMAIN. Please follow this guide to open ports in your router: https://www.techandme.se/open-port-80-443/" "$WT_HEIGHT" "$WT_WIDTH" any_key "Press any key to exit... " - apt remove --purge nmap -y + if [ "$NMAPSTATUS" = "preinstalled" ] + then + echo "nmap was previously installed, not removing" + else + apt remove --purge nmap -y + fi exit 1 fi fi |