From c33867906914531543852f99ef7b645723f31a13 Mon Sep 17 00:00:00 2001
From: Bob Mottram <bob@robotics.uk.to>
Date: Wed, 26 Oct 2016 12:13:55 +0100
Subject: [PATCH] optionally include a mail subdomain code

---
 src/freedombone-config       | 15 ++++++++++++---
 src/freedombone-utils-config |  1 +
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/freedombone-config b/src/freedombone-config
index 7a2eae9bd..eefd78dc1 100755
--- a/src/freedombone-config
+++ b/src/freedombone-config
@@ -190,9 +190,10 @@ function choose_default_domain_name {
             if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
                 dialog --backtitle $"Freedombone Configuration" \
                        --title $"Your main domain name" \
-                       --form $"\nWhich domain name should your email/XMPP/IRC/Mumble be associated with?" 11 55 3 \
-                       $"Domain:" 1 1 "$(grep 'DEFAULT_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 16 33 40 \
-                       $"Code:" 2 1 "$(grep 'DEFAULT_DOMAIN_CODE' temp.cfg | awk -F '=' '{print $2}')" 2 16 33 255 \
+                       --form $"\nWhich domain name should your email/XMPP/IRC/Mumble be associated with?" 12 55 4 \
+                       $"Domain:" 1 1 "$(grep 'DEFAULT_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 24 33 40 \
+                       $"Code:" 2 1 "$(grep 'DEFAULT_DOMAIN_CODE' temp.cfg | awk -F '=' '{print $2}')" 2 24 33 255 \
+                       $"mail subdomain Code:" 3 1 "$(grep 'EMAIL_DOMAIN_CODE' temp.cfg | awk -F '=' '{print $2}')" 3 24 33 255 \
                        2> $data
                 sel=$?
                 case $sel in
@@ -201,12 +202,20 @@ function choose_default_domain_name {
                 esac
                 DEFAULT_DOMAIN_NAME=$(cat $data | sed -n 1p)
                 DEFAULT_DOMAIN_CODE=$(cat $data | sed -n 2p)
+                EMAIL_DOMAIN_CODE=$(cat $data | sed -n 2p)
                 if [ $DEFAULT_DOMAIN_NAME ]; then
                     validate_freedns_code "$DEFAULT_DOMAIN_CODE"
                     if [ ! $VALID_CODE ]; then
                         DEFAULT_DOMAIN_NAME=
                     fi
                 fi
+                if [ $EMAIL_DOMAIN_CODE ]; then
+                    validate_freedns_code "$EMAIL_DOMAIN_CODE"
+                    if [ ! $VALID_CODE ]; then
+                        DEFAULT_DOMAIN_NAME=
+                        EMAIL_DOMAIN_CODE=
+                    fi
+                fi
             else
                 dialog --backtitle $"Freedombone Configuration" \
                        --inputbox $"Which domain name should your email/XMPP/IRC/Mumble be associated with?" 10 45 \
diff --git a/src/freedombone-utils-config b/src/freedombone-utils-config
index 463afc8f0..cfe923313 100755
--- a/src/freedombone-utils-config
+++ b/src/freedombone-utils-config
@@ -47,6 +47,7 @@ configuration_variables=(FRIENDS_MIRRORS_SERVER
                          DOMAIN_NAME
                          DEFAULT_DOMAIN_NAME
                          DEFAULT_DOMAIN_CODE
+                         EMAIL_DOMAIN_CODE
                          NAMESERVER1
                          NAMESERVER2
                          GET_IP_ADDRESS_URL
-- 
GitLab