Default domain code

This commit is contained in:
Bob Mottram 2015-02-15 14:49:32 +00:00
parent ac81c37bf4
commit e188a4d06b
2 changed files with 52 additions and 9 deletions

View File

@ -55,6 +55,7 @@ VARIANT_MEDIA="media"
VARIANT_TOR_DONGLE="tordongle"
DEFAULT_DOMAIN_NAME=
DEFAULT_DOMAIN_CODE=
MY_USERNAME=
SYSTEM_TYPE=$VARIANT_FULL
@ -720,6 +721,9 @@ function read_configuration {
if grep -q "DEFAULT_DOMAIN_NAME" $CONFIGURATION_FILE; then
DEFAULT_DOMAIN_NAME=$(grep "DEFAULT_DOMAIN_NAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if grep -q "DEFAULT_DOMAIN_CODE" $CONFIGURATION_FILE; then
DEFAULT_DOMAIN_CODE=$(grep "DEFAULT_DOMAIN_CODE" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if grep -q "NAMESERVER1" $CONFIGURATION_FILE; then
NAMESERVER1=$(grep "NAMESERVER1" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi

View File

@ -54,6 +54,7 @@ VARIANT_TOR_DONGLE="tordongle"
MY_USERNAME=
DEFAULT_DOMAIN_NAME=
DEFAULT_DOMAIN_CODE=
MY_EMAIL_ADDRESS=
SYSTEM_TYPE=
INSTALLING_ON_BBB=
@ -141,6 +142,9 @@ function save_configuration_file {
echo "MY_USERNAME=$MY_USERNAME" > $CONFIGURATION_FILE
echo "DEFAULT_DOMAIN_NAME=$DEFAULT_DOMAIN_NAME" >> $CONFIGURATION_FILE
if [ $DEFAULT_DOMAIN_CODE ]; then
echo "DEFAULT_DOMAIN_CODE=$DEFAULT_DOMAIN_CODE" >> $CONFIGURATION_FILE
fi
echo "SYSTEM_TYPE=$SYSTEM_TYPE" >> $CONFIGURATION_FILE
echo "INSTALLING_ON_BBB=$INSTALLING_ON_BBB" >> $CONFIGURATION_FILE
echo "DDNS_PROVIDER=$DDNS_PROVIDER" >> $CONFIGURATION_FILE
@ -864,22 +868,54 @@ function interactive_configuration {
save_configuration_file
fi
if [ ! $DEFAULT_DOMAIN_NAME ]; then
while [ ! $DEFAULT_DOMAIN_NAME ]
do
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
DEFAULT_DOMAIN_DETAILS_COMPLETE=
while [ ! $DEFAULT_DOMAIN_DETAILS_COMPLETE ]
do
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
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
--title "Default Domain" \
--form "\nWhich domain name should your email/XMPP/IRC/VoIP be associated with?" 11 55 3 \
"Domain:" 1 1 "$(grep 'DEFAULT_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 16 25 30 \
"Code:" 2 1 "$(grep 'DEFAULT_DOMAIN_CODE' temp.cfg | awk -F '=' '{print $2}')" 2 16 25 30 \
2> $data
sel=$?
case $sel in
1) exit 0;;
255) exit 0;;
esac
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 5 ]; 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 0;;
255) exit 0;;
esac
done
save_configuration_file
fi
fi
if [ $DEFAULT_DOMAIN_NAME ]; then
TEST_DOMAIN_NAME=$DEFAULT_DOMAIN_NAME
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 ]
do
@ -935,6 +971,9 @@ function read_configuration {
if grep -q "DEFAULT_DOMAIN_NAME" $CONFIGURATION_FILE; then
DEFAULT_DOMAIN_NAME=$(grep "DEFAULT_DOMAIN_NAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if grep -q "DEFAULT_DOMAIN_CODE" $CONFIGURATION_FILE; then
DEFAULT_DOMAIN_CODE=$(grep "DEFAULT_DOMAIN_CODE" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if grep -q "NAMESERVER1" $CONFIGURATION_FILE; then
NAMESERVER1=$(grep "NAMESERVER1" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi