# Find/isolate the root zone to work with in createRecord() and deleteRecord()
# Find/isolate the root zone to work with in createRecord() and deleteRecord()
rootZone=""
rootZone=""
if["$checkMultiZones"="true"];then
if["$checkMultiZones"="true"];then
rootZone=$(for zone in$(echo"$result" | tr-d'\n'' ');do
#rootZone=$(for x in $(printf "%s" "${result3}" | tr ',' '\n' | sed -n 's/.*"name":"\(.*\)",.*/\1/p'); do if [ "$(echo "$domain" | grep "$x")" != "" ]; then echo "$x"; fi; done)
if["$(echo"$domain" | grep"$zone")"!=""];then
rootZone=$(for x in$(printf"%s\n""${result3}" | tr',''\n' | grep name | cut-d'"'-f4);do if["$(echo"$domain" | grep"$x")"!=""];then echo"$x";fi;done)
_debug2 _get_root "- trying to figure out if $zone is in $domain"
if["$rootZone"!=""];then
echo"$zone"
_debug2 _rootZone "- root zone for $domain is $rootZone"
break
else
_err "Could not find root zone for $domain, is it correctly typed?"
_err "You didn't specify a dnsla api id and key yet."
return 1
fi
#save the api key and email to the account conf file.
_saveaccountconf_mutable LA_Id "$LA_Id"
_saveaccountconf_mutable LA_Key "$LA_Key"
_debug "First detect the root zone"
if! _get_root "$fulldomain";then
_err "invalid domain"
return 1
fi
_debug _domain_id "$_domain_id"
_debug _sub_domain "$_sub_domain"
_debug _domain "$_domain"
_info "Adding record"
if _la_rest "record.ashx?cmd=create&apiid=$LA_Id&apipass=$LA_Key&rtype=json&domainid=$_domain_id&host=$_sub_domain&recordtype=TXT&recorddata=$txtvalue&recordline=";then