Simplify dynamic DNS setup

This commit is contained in:
Bob Mottram 2017-05-18 16:03:49 +01:00
parent fe8e070b7e
commit 432230c521
1 changed files with 152 additions and 139 deletions

View File

@ -247,152 +247,165 @@ function choose_default_domain_name {
save_configuration_values save_configuration_values
} }
function choose_dynamic_dns { function dynamic_dns_setup {
if [[ $SYSTEM_TYPE != "mesh"* && $ONION_ONLY == "no" ]]; then 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) valid_ddns_username=
trap "rm -f $data" 0 1 2 5 15 valid_ddns_password=
dialog --backtitle $"Freedombone Configuration" \ if [[ "$DDNS_PROVIDER" == "none" ]]; then
--radiolist $"Choose Dynamic DNS provider:" 40 40 40 \ if [ -f /etc/systemd/system/inadyn.service ]; then
1 dyn.com off \ systemctl stop inadyn
2 freedns.afraid.org on \ systemctl disable inadyn
3 zoneedit.com off \ fi
4 no-ip.com off \ else
5 easydns.com off \ while [ ! $valid_ddns_username ]
6 tzo.com off \ do
7 3322.org off \ data=$(tempfile 2>/dev/null)
8 dnsomatic.com off \ trap "rm -f $data" 0 1 2 5 15
9 dns.he.net off \ dialog --backtitle $"Freedombone Configuration" \
10 tunnelbroker.net off \ --inputbox $"Dynamic DNS provider username" 10 30 "$(grep 'DDNS_USERNAME' temp.cfg | awk -F '=' '{print $2}')" 2> $data
11 dynsip.org off \ sel=$?
12 sitelutions.com off \ case $sel in
13 dnsexit.com off \ 0) possible_username=$(cat $data)
14 changeip.com off \ if [ "$possible_username" ]; then
15 zerigo.com off \ if [ ${#possible_username} -gt 1 ]; then
16 dhis.org off \ valid_ddns_username=$(cat $data)
17 nsupdate.info off \ DDNS_USERNAME=$valid_ddns_username
18 duckdns.org off \ break;
19 loopia.com off \ fi
20 namecheap.com off \ fi
21 domains.google.com off \ ;;
22 ovh.com off \ 1) exit 1;;
23 dtdns.com off \ 255) exit 1;;
24 giradns.com off \ esac
25 duiadns.net off \ done
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 save_configuration_values
valid_ddns_username= while [ ! $valid_ddns_password ]
valid_ddns_password= do
if [[ "$DDNS_PROVIDER" == "none" ]]; then data=$(tempfile 2>/dev/null)
if [ -f /etc/systemd/system/inadyn.service ]; then trap "rm -f $data" 0 1 2 5 15
systemctl stop inadyn dialog --backtitle $"Freedombone Configuration" \
systemctl disable inadyn --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 fi
else done
while [ ! $valid_ddns_username ] save_configuration_values
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
fi 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 { function choose_debian_repo {
if [[ $MINIMAL_INSTALL == "no" ]]; then if [[ $MINIMAL_INSTALL == "no" ]]; then
data=$(tempfile 2>/dev/null) data=$(tempfile 2>/dev/null)