From 0bcf005d7da174504d5cb6398a2f1a0ecdd29eba Mon Sep 17 00:00:00 2001 From: Jessie Lee Date: Sun, 6 Oct 2019 09:49:44 -0400 Subject: [PATCH] Adding dns_rimu.sh based on dns_zonomi.sh with changed endpoint --- dnsapi/dns_rimu.sh | 85 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 dnsapi/dns_rimu.sh diff --git a/dnsapi/dns_rimu.sh b/dnsapi/dns_rimu.sh new file mode 100644 index 00000000..0ecff87e --- /dev/null +++ b/dnsapi/dns_rimu.sh @@ -0,0 +1,85 @@ +#!/usr/bin/env sh + +# +#RM_Key="sdfsdfsdfljlbjkljlkjsdfoiwje" +# +#https://rimuhosting.com dns api + +RM_Api="https://rimuhosting.com/dns/dyndns.jsp" + +######## Public functions ##################### + +#Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs" +dns_rimu_add() { + fulldomain=$1 + txtvalue=$2 + + RM_Key="${RM_Key:-$(_readaccountconf_mutable RM_Key)}" + + if [ -z "$RM_Key" ]; then + RM_Key="" + _err "You did not specify a RimuHosting api key." + _err "Please create your key here https://rimuhosting.com/cp/apikeys.jsp and try again." + return 1 + fi + + #save the api key to the account conf file. + _saveaccountconf_mutable RM_Key "$RM_Key" + + _info "Get existing txt records for $fulldomain" + if ! _rm_request "action=QUERY&name=$fulldomain"; then + _err "error" + return 1 + fi + + if _contains "$response" "' | tr "<" "\n" | grep record | grep 'type="TXT"' | cut -d '"' -f 6); do + _debug2 t "$t" + _qstr="$_qstr&action[$_qindex]=SET&type[$_qindex]=TXT&name[$_qindex]=$fulldomain&value[$_qindex]=$t" + _qindex="$(_math "$_qindex" + 1)" + done + _rm_request "$_qstr" + else + _debug "Just add record" + _rm_request "action=SET&type=TXT&name=$fulldomain&value=$txtvalue" + fi + +} + +#fulldomain txtvalue +dns_rimu_rm() { + fulldomain=$1 + txtvalue=$2 + + RM_Key="${RM_Key:-$(_readaccountconf_mutable RM_Key)}" + if [ -z "$RM_Key" ]; then + RM_Key="" + _err "You did not specify a RimuHosting api key." + _err "Please create your key here https://rimuhosting.com/cp/apikeys.jsp and try again." + return 1 + fi + + _rm_request "action=DELETE&type=TXT&name=$fulldomain" + +} + +#################### Private functions below ################################## +#qstr +_rm_request() { + qstr="$1" + + _debug2 "qstr" "$qstr" + + _rm_url="$RM_Api?api_key=$RM_Key&$qstr" + _debug2 "_rm_url" "$_rm_url" + response="$(_get "$_rm_url")" + + if [ "$?" != "0" ]; then + return 1 + fi + _debug2 response "$response" + _contains "$response" "OK:" +}