From 432230c5211800942206836a1d5dcd2f8f37d778 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 18 May 2017 16:03:49 +0100 Subject: [PATCH] Simplify dynamic DNS setup --- src/freedombone-config | 291 +++++++++++++++++++++-------------------- 1 file changed, 152 insertions(+), 139 deletions(-) diff --git a/src/freedombone-config b/src/freedombone-config index c2f4308c..bed9b1e9 100755 --- a/src/freedombone-config +++ b/src/freedombone-config @@ -247,152 +247,165 @@ function choose_default_domain_name { save_configuration_values } -function choose_dynamic_dns { - if [[ $SYSTEM_TYPE != "mesh"* && $ONION_ONLY == "no" ]]; then +function dynamic_dns_setup { + data=$(tempfile 2>/dev/null) + trap "rm -f $data" 0 1 2 5 15 + dialog --backtitle $"Freedombone Configuration" \ + --radiolist $"Choose Dynamic DNS provider:" 40 40 40 \ + 1 dyn.com off \ + 2 freedns.afraid.org on \ + 3 zoneedit.com off \ + 4 no-ip.com off \ + 5 easydns.com off \ + 6 tzo.com off \ + 7 3322.org off \ + 8 dnsomatic.com off \ + 9 dns.he.net off \ + 10 tunnelbroker.net off \ + 11 dynsip.org off \ + 12 sitelutions.com off \ + 13 dnsexit.com off \ + 14 changeip.com off \ + 15 zerigo.com off \ + 16 dhis.org off \ + 17 nsupdate.info off \ + 18 duckdns.org off \ + 19 loopia.com off \ + 20 namecheap.com off \ + 21 domains.google.com off \ + 22 ovh.com off \ + 23 dtdns.com off \ + 24 giradns.com off \ + 25 duiadns.net off \ + 26 ddnss.de off \ + 27 dynv6.com off \ + 28 ipv4.dynv6.com off \ + 29 default@spdyn.de off \ + 30 strato.com off \ + 31 freemyip.com off \ + 32 cloudxns.net off \ + 33 none off 2> $data + sel=$? + case $sel in + 1) exit 1;; + 255) exit 1;; + esac + case $(cat $data) in + 1) DDNS_PROVIDER="default@www.dyn.com";; + 2) DDNS_PROVIDER="default@freedns.afraid.org";; + 3) DDNS_PROVIDER="default@www.zoneedit.com";; + 4) DDNS_PROVIDER="default@www.no-ip.com";; + 5) DDNS_PROVIDER="default@www.easydns.com";; + 6) DDNS_PROVIDER="default@www.tzo.com";; + 7) DDNS_PROVIDER="default@www.3322.org";; + 8) DDNS_PROVIDER="default@www.dnsomatic.com";; + 9) DDNS_PROVIDER="default@dns.he.net";; + 10) DDNS_PROVIDER="default@www.tunnelbroker.net";; + 11) DDNS_PROVIDER="default@www.dynsip.org";; + 12) DDNS_PROVIDER="default@www.sitelutions.com";; + 13) DDNS_PROVIDER="default@www.dnsexit.com";; + 14) DDNS_PROVIDER="default@www.changeip.com";; + 15) DDNS_PROVIDER="default@www.zerigo.com";; + 16) DDNS_PROVIDER="default@www.dhis.org";; + 17) DDNS_PROVIDER="default@nsupdate.info";; + 18) DDNS_PROVIDER="default@duckdns.org";; + 19) DDNS_PROVIDER="default@www.loopia.com";; + 20) DDNS_PROVIDER="default@www.namecheap.com";; + 21) DDNS_PROVIDER="default@domains.google.com";; + 22) DDNS_PROVIDER="default@www.ovh.com";; + 23) DDNS_PROVIDER="default@www.dtdns.com";; + 24) DDNS_PROVIDER="default@giradns.com";; + 25) DDNS_PROVIDER="default@www.duiadns.net";; + 26) DDNS_PROVIDER="default@ddnss.de";; + 27) DDNS_PROVIDER="default@dynv6.com";; + 28) DDNS_PROVIDER="default@ipv4.dynv6.com";; + 29) DDNS_PROVIDER="default@spdyn.de";; + 30) DDNS_PROVIDER="default@www.strato.com";; + 31) DDNS_PROVIDER="default@freemyip.com";; + 32) DDNS_PROVIDER="default@www.cloudxns.net";; + 33) DDNS_PROVIDER="none";; + 255) exit 1;; + esac + save_configuration_values - data=$(tempfile 2>/dev/null) - trap "rm -f $data" 0 1 2 5 15 - dialog --backtitle $"Freedombone Configuration" \ - --radiolist $"Choose Dynamic DNS provider:" 40 40 40 \ - 1 dyn.com off \ - 2 freedns.afraid.org on \ - 3 zoneedit.com off \ - 4 no-ip.com off \ - 5 easydns.com off \ - 6 tzo.com off \ - 7 3322.org off \ - 8 dnsomatic.com off \ - 9 dns.he.net off \ - 10 tunnelbroker.net off \ - 11 dynsip.org off \ - 12 sitelutions.com off \ - 13 dnsexit.com off \ - 14 changeip.com off \ - 15 zerigo.com off \ - 16 dhis.org off \ - 17 nsupdate.info off \ - 18 duckdns.org off \ - 19 loopia.com off \ - 20 namecheap.com off \ - 21 domains.google.com off \ - 22 ovh.com off \ - 23 dtdns.com off \ - 24 giradns.com off \ - 25 duiadns.net off \ - 26 ddnss.de off \ - 27 dynv6.com off \ - 28 ipv4.dynv6.com off \ - 29 default@spdyn.de off \ - 30 strato.com off \ - 31 freemyip.com off \ - 32 cloudxns.net off \ - 33 none off 2> $data - sel=$? - case $sel in - 1) exit 1;; - 255) exit 1;; - esac - case $(cat $data) in - 1) DDNS_PROVIDER="default@www.dyn.com";; - 2) DDNS_PROVIDER="default@freedns.afraid.org";; - 3) DDNS_PROVIDER="default@www.zoneedit.com";; - 4) DDNS_PROVIDER="default@www.no-ip.com";; - 5) DDNS_PROVIDER="default@www.easydns.com";; - 6) DDNS_PROVIDER="default@www.tzo.com";; - 7) DDNS_PROVIDER="default@www.3322.org";; - 8) DDNS_PROVIDER="default@www.dnsomatic.com";; - 9) DDNS_PROVIDER="default@dns.he.net";; - 10) DDNS_PROVIDER="default@www.tunnelbroker.net";; - 11) DDNS_PROVIDER="default@www.dynsip.org";; - 12) DDNS_PROVIDER="default@www.sitelutions.com";; - 13) DDNS_PROVIDER="default@www.dnsexit.com";; - 14) DDNS_PROVIDER="default@www.changeip.com";; - 15) DDNS_PROVIDER="default@www.zerigo.com";; - 16) DDNS_PROVIDER="default@www.dhis.org";; - 17) DDNS_PROVIDER="default@nsupdate.info";; - 18) DDNS_PROVIDER="default@duckdns.org";; - 19) DDNS_PROVIDER="default@www.loopia.com";; - 20) DDNS_PROVIDER="default@www.namecheap.com";; - 21) DDNS_PROVIDER="default@domains.google.com";; - 22) DDNS_PROVIDER="default@www.ovh.com";; - 23) DDNS_PROVIDER="default@www.dtdns.com";; - 24) DDNS_PROVIDER="default@giradns.com";; - 25) DDNS_PROVIDER="default@www.duiadns.net";; - 26) DDNS_PROVIDER="default@ddnss.de";; - 27) DDNS_PROVIDER="default@dynv6.com";; - 28) DDNS_PROVIDER="default@ipv4.dynv6.com";; - 29) DDNS_PROVIDER="default@spdyn.de";; - 30) DDNS_PROVIDER="default@www.strato.com";; - 31) DDNS_PROVIDER="default@freemyip.com";; - 32) DDNS_PROVIDER="default@www.cloudxns.net";; - 33) DDNS_PROVIDER="none";; - 255) exit 1;; - esac + valid_ddns_username= + valid_ddns_password= + if [[ "$DDNS_PROVIDER" == "none" ]]; then + if [ -f /etc/systemd/system/inadyn.service ]; then + systemctl stop inadyn + systemctl disable inadyn + fi + else + while [ ! $valid_ddns_username ] + do + data=$(tempfile 2>/dev/null) + trap "rm -f $data" 0 1 2 5 15 + dialog --backtitle $"Freedombone Configuration" \ + --inputbox $"Dynamic DNS provider username" 10 30 "$(grep 'DDNS_USERNAME' temp.cfg | awk -F '=' '{print $2}')" 2> $data + sel=$? + case $sel in + 0) possible_username=$(cat $data) + if [ "$possible_username" ]; then + if [ ${#possible_username} -gt 1 ]; then + valid_ddns_username=$(cat $data) + DDNS_USERNAME=$valid_ddns_username + break; + fi + fi + ;; + 1) exit 1;; + 255) exit 1;; + esac + done save_configuration_values - valid_ddns_username= - valid_ddns_password= - if [[ "$DDNS_PROVIDER" == "none" ]]; then - if [ -f /etc/systemd/system/inadyn.service ]; then - systemctl stop inadyn - systemctl disable inadyn + while [ ! $valid_ddns_password ] + do + data=$(tempfile 2>/dev/null) + trap "rm -f $data" 0 1 2 5 15 + dialog --backtitle $"Freedombone Configuration" \ + --clear \ + --insecure \ + --passwordbox $"Dynamic DNS provider password" 10 30 "$(grep 'DDNS_PASSWORD' temp.cfg | awk -F '=' '{print $2}')" 2> $data + sel=$? + case $sel in + 0) possible_password=$(cat $data) + if [ "$possible_password" ]; then + if [ ${#possible_password} -gt 1 ]; then + valid_ddns_password=$(cat $data) + DDNS_PASSWORD=$valid_ddns_password + break; + fi + fi + ;; + 1) exit 1;; + 255) exit 1;; + esac + if [ ${#DDNS_PASSWORD} -lt $MINIMUM_PASSWORD_LENGTH ]; then + dialog --title $"Password quality check" --msgbox $"The password given was too short. It must be at least $MINIMUM_PASSWORD_LENGTH characters. You may need to change your password on the dynamic DNS provider's web site." 10 40 + DDNS_PASSWORD="" fi - else - while [ ! $valid_ddns_username ] - do - data=$(tempfile 2>/dev/null) - trap "rm -f $data" 0 1 2 5 15 - dialog --backtitle $"Freedombone Configuration" \ - --inputbox $"Dynamic DNS provider username" 10 30 "$(grep 'DDNS_USERNAME' temp.cfg | awk -F '=' '{print $2}')" 2> $data - sel=$? - case $sel in - 0) possible_username=$(cat $data) - if [ "$possible_username" ]; then - if [ ${#possible_username} -gt 1 ]; then - valid_ddns_username=$(cat $data) - DDNS_USERNAME=$valid_ddns_username - break; - fi - fi - ;; - 1) exit 1;; - 255) exit 1;; - esac - done - save_configuration_values - - while [ ! $valid_ddns_password ] - do - data=$(tempfile 2>/dev/null) - trap "rm -f $data" 0 1 2 5 15 - dialog --backtitle $"Freedombone Configuration" \ - --clear \ - --insecure \ - --passwordbox $"Dynamic DNS provider password" 10 30 "$(grep 'DDNS_PASSWORD' temp.cfg | awk -F '=' '{print $2}')" 2> $data - sel=$? - case $sel in - 0) possible_password=$(cat $data) - if [ "$possible_password" ]; then - if [ ${#possible_password} -gt 1 ]; then - valid_ddns_password=$(cat $data) - DDNS_PASSWORD=$valid_ddns_password - break; - fi - fi - ;; - 1) exit 1;; - 255) exit 1;; - esac - if [ ${#DDNS_PASSWORD} -lt $MINIMUM_PASSWORD_LENGTH ]; then - dialog --title $"Password quality check" --msgbox $"The password given was too short. It must be at least $MINIMUM_PASSWORD_LENGTH characters. You may need to change your password on the dynamic DNS provider's web site." 10 40 - DDNS_PASSWORD="" - fi - done - save_configuration_values - fi + done + save_configuration_values fi } +function choose_dynamic_dns { + DDNS_PROVIDER="none" + + if [[ $SYSTEM_TYPE != "mesh"* && $ONION_ONLY == "no" ]]; then + dialog --title $"Dynamic DNS" \ + --backtitle $"Freedombone Configuration" \ + --yesno $"\nConfigure a dynamic DNS service?\n\nIf it is already handled by your internet router then select 'no'." 10 50 + sel=$? + case $sel in + 0) dynamic_dns_setup;; + 255) exit 1;; + esac + fi + save_configuration_values +} + function choose_debian_repo { if [[ $MINIMAL_INSTALL == "no" ]]; then data=$(tempfile 2>/dev/null)