diff --git a/dnsapi/dns_loopia.sh b/dnsapi/dns_loopia.sh
index 5d761187..ece5ef8c 100644
--- a/dnsapi/dns_loopia.sh
+++ b/dnsapi/dns_loopia.sh
@@ -38,8 +38,8 @@ dns_loopia_add() {
_info "Adding record"
- _loopia_add_record "$_domain" "$_sub_domain"
- _loopia_update_record "$_domain" "$_sub_domain" "$txtvalue"
+ _loopia_add_sub_domain "$_domain" "$_sub_domain"
+ _loopia_add_record "$_domain" "$_sub_domain" "$txtvalue"
}
@@ -96,6 +96,37 @@ dns_loopia_rm() {
#################### Private functions below ##################################
+_loopia_get_records() {
+ domain=$1
+ sub_domain=$2
+
+ xml_content=$(printf '
+
+ getZoneRecords
+
+
+ %s
+
+
+ %s
+
+
+ %s
+
+
+ %s
+
+
+ ' $LOOPIA_User $LOOPIA_Password "$domain" "$sub_domain")
+
+ response="$(_post "$xml_content" "$LOOPIA_Api" "" "POST")"
+ if ! _contains "$response" ""; then
+ _err "Error"
+ return 1
+ fi
+ return 0
+}
+
_get_root() {
domain=$1
_debug "get root"
@@ -137,14 +168,14 @@ _get_root() {
}
-_loopia_update_record() {
+_loopia_add_record() {
domain=$1
sub_domain=$2
txtval=$3
xml_content=$(printf '
- updateZoneRecord
+ addZoneRecord
%s
@@ -176,10 +207,6 @@ _loopia_update_record() {
rdata
%s
-
- record_id
- 0
-
@@ -194,10 +221,42 @@ _loopia_update_record() {
return 0
}
-_loopia_add_record() {
+_sub_domain_exists() {
domain=$1
sub_domain=$2
+ xml_content=$(printf '
+
+ getSubdomains
+
+
+ %s
+
+
+ %s
+
+
+ %s
+
+
+ ' $LOOPIA_User $LOOPIA_Password "$domain")
+
+ response="$(_post "$xml_content" "$LOOPIA_Api" "" "POST")"
+
+ if _contains "$response" "$sub_domain"; then
+ return 0
+ fi
+ return 1
+}
+
+_loopia_add_sub_domain() {
+ domain=$1
+ sub_domain=$2
+
+ if _sub_domain_exists "$domain" "$sub_domain"; then
+ return 0
+ fi
+
xml_content=$(printf '
addSubdomain