|
|
|
@ -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 '<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
|
<methodCall>
|
|
|
|
|
<methodName>getZoneRecords</methodName>
|
|
|
|
|
<params>
|
|
|
|
|
<param>
|
|
|
|
|
<value><string>%s</string></value>
|
|
|
|
|
</param>
|
|
|
|
|
<param>
|
|
|
|
|
<value><string>%s</string></value>
|
|
|
|
|
</param>
|
|
|
|
|
<param>
|
|
|
|
|
<value><string>%s</string></value>
|
|
|
|
|
</param>
|
|
|
|
|
<param>
|
|
|
|
|
<value><string>%s</string></value>
|
|
|
|
|
</param>
|
|
|
|
|
</params>
|
|
|
|
|
</methodCall>' $LOOPIA_User $LOOPIA_Password "$domain" "$sub_domain")
|
|
|
|
|
|
|
|
|
|
response="$(_post "$xml_content" "$LOOPIA_Api" "" "POST")"
|
|
|
|
|
if ! _contains "$response" "<array>"; 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 '<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
|
<methodCall>
|
|
|
|
|
<methodName>updateZoneRecord</methodName>
|
|
|
|
|
<methodName>addZoneRecord</methodName>
|
|
|
|
|
<params>
|
|
|
|
|
<param>
|
|
|
|
|
<value><string>%s</string></value>
|
|
|
|
@ -176,10 +207,6 @@ _loopia_update_record() {
|
|
|
|
|
<name>rdata</name>
|
|
|
|
|
<value><string>%s</string></value>
|
|
|
|
|
</member>
|
|
|
|
|
<member>
|
|
|
|
|
<name>record_id</name>
|
|
|
|
|
<value><int>0</int></value>
|
|
|
|
|
</member>
|
|
|
|
|
</struct>
|
|
|
|
|
</param>
|
|
|
|
|
</params>
|
|
|
|
@ -194,10 +221,42 @@ _loopia_update_record() {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_loopia_add_record() {
|
|
|
|
|
_sub_domain_exists() {
|
|
|
|
|
domain=$1
|
|
|
|
|
sub_domain=$2
|
|
|
|
|
|
|
|
|
|
xml_content=$(printf '<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
|
<methodCall>
|
|
|
|
|
<methodName>getSubdomains</methodName>
|
|
|
|
|
<params>
|
|
|
|
|
<param>
|
|
|
|
|
<value><string>%s</string></value>
|
|
|
|
|
</param>
|
|
|
|
|
<param>
|
|
|
|
|
<value><string>%s</string></value>
|
|
|
|
|
</param>
|
|
|
|
|
<param>
|
|
|
|
|
<value><string>%s</string></value>
|
|
|
|
|
</param>
|
|
|
|
|
</params>
|
|
|
|
|
</methodCall>' $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 '<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
|
<methodCall>
|
|
|
|
|
<methodName>addSubdomain</methodName>
|
|
|
|
|