diff --git a/apps/talk.sh b/apps/talk.sh index 136ffac7..93a4532a 100644 --- a/apps/talk.sh +++ b/apps/talk.sh @@ -83,31 +83,27 @@ lowest_compatible_nc 19 # Check if Nextcloud is installed with TLS check_nextcloud_https "Nextclod Talk" -# Let the user choose port. TURN_PORT in msg_box is taken from lib.sh and later changed if user decides to. -msg_box "The default port for Talk used in this script is port $TURN_PORT. +while : +do + # Let the user choose port. TURN_PORT in msg_box is taken from lib.sh and later changed if user decides to. + msg_box "The default port for Talk used in this script is port $TURN_PORT. You can read more about that port here: https://www.speedguide.net/port.php?port=$TURN_PORT You will now be given the option to change this port to something of your own. Please keep in mind NOT to use the following ports as they are likely in use already: ${NONO_PORTS[*]}" -if yesno_box_no "Do you want to change port?" -then - # Ask for port - TURN_PORT=$(input_box_flow "Please enter the port you will use for Nextcloud Talk") -fi + if yesno_box_no "Do you want to change port?" + then + # Ask for port + TURN_PORT=$(input_box_flow "Please enter the port you will use for Nextcloud Talk") + fi -containsElement () { - local e match="$1" - shift - for e; do [[ "$e" == "$match" ]] && return 0; done - return 1 -} - -if containsElement "$TURN_PORT" "${NONO_PORTS[@]}" -then - msg_box "You have to choose another port. Please start over." - exit 1 -fi + # Check if port is taken and exit if that's the case + if check_nono_ports "$TURN_PORT" + then + break + fi +done # Install TURN check_command install_if_not coturn diff --git a/lets-encrypt/activate-tls.sh b/lets-encrypt/activate-tls.sh index 2c377324..f7ecdb42 100644 --- a/lets-encrypt/activate-tls.sh +++ b/lets-encrypt/activate-tls.sh @@ -227,6 +227,30 @@ then then openssl dhparam -dsaparam -out "$DHPARAMS_TLS" 4096 fi + # Choose which port for public access + while : + do + msg_box "You will now be able to choose which port you want to put your Nextcloud on for public access.\n +Please keep in mind NOT to use the following ports as they are likely in use already: +${NONO_PORTS[*]}" + # Ask for port + DEDYNPORT=$(input_box_flow "Please choose which port you want between 1024 - 49151.\n\nPlease remember to open this port in your firewall.") + if (("$DEDYNPORT" >= 1024 && "$DEDYNPORT" <= 49151)) + then + if check_nono_ports "$DEDYNPORT" + then + print_text_in_color "$ICyan" "Changing to port $DEDYNPORT for public access..." + sed -i "s|VirtualHost *:443|VirtualHost *:$DEDYNPORT|g" "$tls_conf" + if restart_webserver + then + msg_box "Congrats! You should now be able to access Nextcloud on: https://$TLSDOMAIN:$DEDYNPORT" + break + fi + fi + else + msg_box "The port number needs to be between 1024 - 49151, please try again." + fi + done fi else if generate_cert "$TLSDOMAIN" diff --git a/lib.sh b/lib.sh index 26e88b99..9f999768 100644 --- a/lib.sh +++ b/lib.sh @@ -50,6 +50,7 @@ INTERNET_DNS="9.9.9.9" # Default Quad9 DNS servers, overwritten by the systemd global DNS defined servers, if set DNS1="9.9.9.9" DNS2="149.112.112.112" +NONO_PORTS=(22 25 53 80 443 1024 3012 3306 5178 5179 5432 7867 7983 8983 10000 8081 8443 9443) use_global_systemd_dns() { if [ -f "/etc/systemd/resolved.conf" ] then @@ -177,7 +178,6 @@ turn_install() { JANUS_API_KEY=$(gen_passwd "$SHUF" "a-zA-Z0-9@#*=") NC_SECRET=$(gen_passwd "$SHUF" "a-zA-Z0-9@#*=") SIGNALING_SERVER_CONF=/etc/signaling/server.conf - NONO_PORTS=(22 25 53 80 443 1024 3012 3306 5178 5179 5432 7867 7983 8983 10000 8081 8443 9443) } [ -n "$TURN_INSTALL" ] && turn_install # TODO: remove this line someday @@ -1664,6 +1664,21 @@ then fi } +test_nono_ports() { + local e match="$1" + shift + for e; do [[ "$e" == "$match" ]] && return 0; done + return 1 +} + +check_nono_ports() { +if test_nono_ports "${1}" "${NONO_PORTS[@]}" +then + msg_box "You have to choose another port than $1. Please start over." + return 1 +fi +} + ## bash colors # Reset Color_Off='\e[0m' # Text Reset