Customising interactive installer for the mesh variant

This commit is contained in:
Bob Mottram 2015-07-19 14:59:00 +01:00
parent 32c290857e
commit 50b2b7860c
1 changed files with 157 additions and 151 deletions

View File

@ -487,7 +487,7 @@ function interactive_configuration {
7 Social off \ 7 Social off \
8 Media off \ 8 Media off \
9 Developer off \ 9 Developer off \
10 Mesh off 2> $data 10 Mesh off 2> $data
sel=$? sel=$?
case $sel in case $sel in
1) exit 1;; 1) exit 1;;
@ -508,8 +508,8 @@ function interactive_configuration {
save_configuration_file save_configuration_file
if [[ SYSTEM_TYPE == "$VARIANT_MESH" ]]; then if [[ SYSTEM_TYPE == "$VARIANT_MESH" ]]; then
ENABLE_BATMAN="yes" ENABLE_BATMAN="yes"
ENABLE_CJDNS="no" ENABLE_CJDNS="no"
fi fi
data=$(tempfile 2>/dev/null) data=$(tempfile 2>/dev/null)
@ -562,27 +562,29 @@ function interactive_configuration {
fi fi
save_configuration_file save_configuration_file
interactive_gpg if [[ SYSTEM_TYPE != "$VARIANT_MESH" ]]; then
interactive_gpg
data=$(tempfile 2>/dev/null) data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15 trap "rm -f $data" 0 1 2 5 15
SOCIAL_KEY_STR="\nDo you wish to enable social key management, otherwise known as \"the unforgettable key\"?\n\nThis means that fragments of your GPG key will be included with any remote backups so that if you later lose your key then it can be reconstructed from your friends servers. If you select \"no\" then you can still do social key management, but offline using physical USB thumb drives, which is more secure but less convenient." SOCIAL_KEY_STR="\nDo you wish to enable social key management, otherwise known as \"the unforgettable key\"?\n\nThis means that fragments of your GPG key will be included with any remote backups so that if you later lose your key then it can be reconstructed from your friends servers. If you select \"no\" then you can still do social key management, but offline using physical USB thumb drives, which is more secure but less convenient."
if [[ $(grep "ENABLE_SOCIAL_KEY_MANAGEMENT" temp.cfg | awk -F '=' '{print $2}') == "yes" ]]; then if [[ $(grep "ENABLE_SOCIAL_KEY_MANAGEMENT" temp.cfg | awk -F '=' '{print $2}') == "yes" ]]; then
dialog --title "Social Key Management" \ dialog --title "Social Key Management" \
--backtitle "Freedombone Configuration" \ --backtitle "Freedombone Configuration" \
--yesno "$SOCIAL_KEY_STR" 15 60 --yesno "$SOCIAL_KEY_STR" 15 60
else else
dialog --title "Social Key Management" \ dialog --title "Social Key Management" \
--backtitle "Freedombone Configuration" \ --backtitle "Freedombone Configuration" \
--defaultno \ --defaultno \
--yesno "$SOCIAL_KEY_STR" 15 60 --yesno "$SOCIAL_KEY_STR" 15 60
fi
sel=$?
case $sel in
0) ENABLE_SOCIAL_KEY_MANAGEMENT="yes";;
255) exit 1;;
esac
save_configuration_file
fi fi
sel=$?
case $sel in
0) ENABLE_SOCIAL_KEY_MANAGEMENT="yes";;
255) exit 1;;
esac
save_configuration_file
data=$(tempfile 2>/dev/null) data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15 trap "rm -f $data" 0 1 2 5 15
@ -804,83 +806,86 @@ function interactive_configuration {
esac esac
save_configuration_file save_configuration_file
data=$(tempfile 2>/dev/null) if [[ SYSTEM_TYPE != "$VARIANT_MESH" ]]; then
trap "rm -f $data" 0 1 2 5 15
dialog --backtitle "Freedombone Configuration" \
--radiolist "Choose Dynamic DNS provider:" 15 40 14 \
1 dyndns off \
2 freedns on \
3 zoneedit off \
4 no-ip off \
5 easydns off \
6 tzo off \
7 3322 off \
8 dnsomatic off \
9 tunnelbroker off \
10 dns.he.net off \
11 dynsip off \
12 sitelutions off \
13 dnsexit off \
14 changeip off 2> $data
sel=$?
case $sel in
1) exit 1;;
255) exit 1;;
esac
case $(cat $data) in
1) DDNS_PROVIDER="default@dyndns.org";;
2) DDNS_PROVIDER="default@freedns.afraid.org";;
3) DDNS_PROVIDER="default@zoneedit.com";;
4) DDNS_PROVIDER="default@no-ip.com";;
5) DDNS_PROVIDER="default@easydns.com";;
6) DDNS_PROVIDER="default@tzo.com";;
7) DDNS_PROVIDER="dyndns@3322.org";;
8) DDNS_PROVIDER="default@dnsomatic.com";;
9) DDNS_PROVIDER="ipv6tb@he.net";;
10) DDNS_PROVIDER="dyndns@he.net";;
11) DDNS_PROVIDER="default@dynsip.org";;
12) DDNS_PROVIDER="default@sitelutions.com";;
13) DDNS_PROVIDER="default@dnsexit.com";;
14) DDNS_PROVIDER="default@changeip.com";;
255) exit 1;;
esac
save_configuration_file
while [ ! $DDNS_USERNAME ]
do
data=$(tempfile 2>/dev/null) data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15 trap "rm -f $data" 0 1 2 5 15
dialog --backtitle "Freedombone Configuration" \ dialog --backtitle "Freedombone Configuration" \
--inputbox "Dynamic DNS provider username" 10 30 "$(grep 'DDNS_USERNAME' temp.cfg | awk -F '=' '{print $2}')" 2> $data --radiolist "Choose Dynamic DNS provider:" 15 40 14 \
1 dyndns off \
2 freedns on \
3 zoneedit off \
4 no-ip off \
5 easydns off \
6 tzo off \
7 3322 off \
8 dnsomatic off \
9 tunnelbroker off \
10 dns.he.net off \
11 dynsip off \
12 sitelutions off \
13 dnsexit off \
14 changeip off 2> $data
sel=$? sel=$?
case $sel in case $sel in
0) DDNS_USERNAME=$(cat $data);;
1) exit 1;; 1) exit 1;;
255) exit 1;; 255) exit 1;;
esac esac
done case $(cat $data) in
save_configuration_file 1) DDNS_PROVIDER="default@dyndns.org";;
2) DDNS_PROVIDER="default@freedns.afraid.org";;
3) DDNS_PROVIDER="default@zoneedit.com";;
4) DDNS_PROVIDER="default@no-ip.com";;
5) DDNS_PROVIDER="default@easydns.com";;
6) DDNS_PROVIDER="default@tzo.com";;
7) DDNS_PROVIDER="dyndns@3322.org";;
8) DDNS_PROVIDER="default@dnsomatic.com";;
9) DDNS_PROVIDER="ipv6tb@he.net";;
10) DDNS_PROVIDER="dyndns@he.net";;
11) DDNS_PROVIDER="default@dynsip.org";;
12) DDNS_PROVIDER="default@sitelutions.com";;
13) DDNS_PROVIDER="default@dnsexit.com";;
14) DDNS_PROVIDER="default@changeip.com";;
255) exit 1;;
esac
save_configuration_file
while [ ! $DDNS_PASSWORD ] while [ ! $DDNS_USERNAME ]
do do
data=$(tempfile 2>/dev/null) data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15 trap "rm -f $data" 0 1 2 5 15
dialog --backtitle "Freedombone Configuration" \ dialog --backtitle "Freedombone Configuration" \
--clear \ --inputbox "Dynamic DNS provider username" 10 30 "$(grep 'DDNS_USERNAME' temp.cfg | awk -F '=' '{print $2}')" 2> $data
--insecure \ sel=$?
--passwordbox "Dynamic DNS provider password" 10 30 "$(grep 'DDNS_PASSWORD' temp.cfg | awk -F '=' '{print $2}')" 2> $data case $sel in
sel=$? 0) DDNS_USERNAME=$(cat $data);;
case $sel in 1) exit 1;;
0) DDNS_PASSWORD=$(cat $data);; 255) exit 1;;
1) exit 1;; esac
255) exit 1;; done
esac save_configuration_file
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 while [ ! $DDNS_PASSWORD ]
DDNS_PASSWORD="" do
fi data=$(tempfile 2>/dev/null)
done trap "rm -f $data" 0 1 2 5 15
save_configuration_file 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) DDNS_PASSWORD=$(cat $data);;
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_file
fi
while [ ! $MY_NAME ] while [ ! $MY_NAME ]
do do
@ -1236,78 +1241,79 @@ function interactive_configuration {
save_configuration_file save_configuration_file
fi fi
DEFAULT_DOMAIN_DETAILS_COMPLETE= if [[ SYSTEM_TYPE != "$VARIANT_MESH" ]]; then
while [ ! $DEFAULT_DOMAIN_DETAILS_COMPLETE ] DEFAULT_DOMAIN_DETAILS_COMPLETE=
do while [ ! $DEFAULT_DOMAIN_DETAILS_COMPLETE ]
data=$(tempfile 2>/dev/null) do
trap "rm -f $data" 0 1 2 5 15 data=$(tempfile 2>/dev/null)
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then trap "rm -f $data" 0 1 2 5 15
dialog --backtitle "Freedombone Configuration" \ if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
--title "Default Domain" \ dialog --backtitle "Freedombone Configuration" \
--form "\nWhich domain name should your email/XMPP/IRC/VoIP be associated with?" 11 55 3 \ --title "Default Domain" \
"Domain:" 1 1 "$(grep 'DEFAULT_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 16 25 30 \ --form "\nWhich domain name should your email/XMPP/IRC/VoIP be associated with?" 11 55 3 \
"Code:" 2 1 "$(grep 'DEFAULT_DOMAIN_CODE' temp.cfg | awk -F '=' '{print $2}')" 2 16 25 30 \ "Domain:" 1 1 "$(grep 'DEFAULT_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 16 25 30 \
2> $data "Code:" 2 1 "$(grep 'DEFAULT_DOMAIN_CODE' temp.cfg | awk -F '=' '{print $2}')" 2 16 25 30 \
sel=$? 2> $data
case $sel in sel=$?
1) exit 1;; case $sel in
255) exit 1;; 1) exit 1;;
esac 255) exit 1;;
DEFAULT_DOMAIN_NAME=$(cat $data | sed -n 1p) esac
DEFAULT_DOMAIN_CODE=$(cat $data | sed -n 2p) DEFAULT_DOMAIN_NAME=$(cat $data | sed -n 1p)
DEFAULT_DOMAIN_CODE=$(cat $data | sed -n 2p)
if [ $DEFAULT_DOMAIN_NAME ]; then
if [ ${#DEFAULT_DOMAIN_CODE} -lt 30 ]; then
DEFAULT_DOMAIN_NAME=
dialog --title "FreeDNS code" --msgbox "$FREEDNS_MESSAGE" 15 50
fi
fi
else
dialog --backtitle "Freedombone Configuration" \
--inputbox "Which domain name should your email/XMPP/IRC/VoIP be associated with?" 10 45 \
"$(grep 'DEFAULT_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 2> $data
sel=$?
case $sel in
0) DEFAULT_DOMAIN_NAME=$(cat $data);;
1) exit 1;;
255) exit 1;;
esac
fi
if [ $DEFAULT_DOMAIN_NAME ]; then if [ $DEFAULT_DOMAIN_NAME ]; then
if [ ${#DEFAULT_DOMAIN_CODE} -lt 30 ]; then TEST_DOMAIN_NAME=$DEFAULT_DOMAIN_NAME
validate_domain_name
if [[ $TEST_DOMAIN_NAME != $DEFAULT_DOMAIN_NAME ]]; then
DEFAULT_DOMAIN_NAME= DEFAULT_DOMAIN_NAME=
dialog --title "FreeDNS code" --msgbox "$FREEDNS_MESSAGE" 15 50 dialog --title "Domain name validation" --msgbox "$TEST_DOMAIN_NAME" 15 50
else
DEFAULT_DOMAIN_DETAILS_COMPLETE="yes"
fi fi
fi fi
else done
save_configuration_file
while [ ${#MY_EMAIL_ADDRESS} -lt 5 ]
do
EMAIL_ADDRESS=$(grep 'MY_EMAIL_ADDRESS' temp.cfg | awk -F '=' '{print $2}')
if [ ! $EMAIL_ADDRESS ]; then
EMAIL_ADDRESS=$MY_USERNAME@$DEFAULT_DOMAIN_NAME
fi
if [ ${#MY_EMAIL_ADDRESS} -lt 5 ]; then
EMAIL_ADDRESS=$MY_USERNAME@$DEFAULT_DOMAIN_NAME
fi
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --backtitle "Freedombone Configuration" \ dialog --backtitle "Freedombone Configuration" \
--inputbox "Which domain name should your email/XMPP/IRC/VoIP be associated with?" 10 45 \ --inputbox "Your email address" 10 30 "$EMAIL_ADDRESS" 2> $data
"$(grep 'DEFAULT_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 2> $data
sel=$? sel=$?
case $sel in case $sel in
0) DEFAULT_DOMAIN_NAME=$(cat $data);; 0) MY_EMAIL_ADDRESS=$(cat $data);;
1) exit 1;; 1) exit 1;;
255) exit 1;; 255) exit 1;;
esac esac
fi done
if [ $DEFAULT_DOMAIN_NAME ]; then save_configuration_file
TEST_DOMAIN_NAME=$DEFAULT_DOMAIN_NAME fi
validate_domain_name
if [[ $TEST_DOMAIN_NAME != $DEFAULT_DOMAIN_NAME ]]; then
DEFAULT_DOMAIN_NAME=
dialog --title "Domain name validation" --msgbox "$TEST_DOMAIN_NAME" 15 50
else
DEFAULT_DOMAIN_DETAILS_COMPLETE="yes"
fi
fi
done
save_configuration_file
while [ ${#MY_EMAIL_ADDRESS} -lt 5 ]
do
EMAIL_ADDRESS=$(grep 'MY_EMAIL_ADDRESS' temp.cfg | awk -F '=' '{print $2}')
if [ ! $EMAIL_ADDRESS ]; then
EMAIL_ADDRESS=$MY_USERNAME@$DEFAULT_DOMAIN_NAME
fi
if [ ${#MY_EMAIL_ADDRESS} -lt 5 ]; then
EMAIL_ADDRESS=$MY_USERNAME@$DEFAULT_DOMAIN_NAME
fi
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --backtitle "Freedombone Configuration" \
--inputbox "Your email address" 10 30 "$EMAIL_ADDRESS" 2> $data
sel=$?
case $sel in
0) MY_EMAIL_ADDRESS=$(cat $data);;
1) exit 1;;
255) exit 1;;
esac
done
save_configuration_file
# delete the temporary configuration file # delete the temporary configuration file
if [ -f temp.cfg ]; then if [ -f temp.cfg ]; then