2 #developed by linux-insideDE
4 NC_Apikey
="${NC_Apikey:-$(_readaccountconf_mutable NC_Apikey)}"
5 NC_Apipw
="${NC_Apipw:-$(_readaccountconf_mutable NC_Apipw)}"
6 NC_CID
="${NC_CID:-$(_readaccountconf_mutable NC_CID)}"
7 end
="https://ccp.netcup.net/run/webservice/servers/endpoint.php?JSON"
12 if [ "$NC_Apikey" = "" ] ||
[ "$NC_Apipw" = "" ] ||
[ "$NC_CID" = "" ]; then
13 _err
"No Credentials given"
16 _saveaccountconf_mutable NC_Apikey
"$NC_Apikey"
17 _saveaccountconf_mutable NC_Apipw
"$NC_Apipw"
18 _saveaccountconf_mutable NC_CID
"$NC_CID"
22 exit=$
(echo "$fulldomain" |
tr -dc '.' |
wc -c)
23 exit=$
(_math
"$exit" + 1)
29 tmp
=$
(echo "$fulldomain" | cut
-d'.' -f"$exit")
30 if [ "$(_math "$i" - "$exit")" -eq 0 ]; then
35 if [ "$(_math "$i" - "$exit")" -ge 1 ]; then
36 msg
=$
(_post
"{\"action\": \"updateDnsRecords\", \"param\": {\"apikey\": \"$NC_Apikey\", \"apisessionid\": \"$sid\", \"customernumber\": \"$NC_CID\",\"clientrequestid\": \"$client\" , \"domainname\": \"$domain\", \"dnsrecordset\": { \"dnsrecords\": [ {\"id\": \"\", \"hostname\": \"$fulldomain.\", \"type\": \"TXT\", \"priority\": \"\", \"destination\": \"$txtvalue\", \"deleterecord\": \"false\", \"state\": \"yes\"} ]}}}" "$end" "" "POST")
38 if [ "$(_getfield "$msg" "5" | sed 's/"statuscode
"://g')" != 5028 ]; then
39 if [ "$(_getfield "$msg" "4" | sed s/\"status\":\"//g | sed s/\"//g)" != "success" ]; then
47 exit=$
(_math
"$exit" - 1)
58 exit=$
(echo "$fulldomain" |
tr -dc '.' |
wc -c)
59 exit=$
(_math
"$exit" + 1)
66 tmp
=$
(echo "$fulldomain" | cut
-d'.' -f"$exit")
67 if [ "$(_math "$i" - "$exit")" -eq 0 ]; then
72 if [ "$(_math "$i" - "$exit")" -ge 1 ]; then
73 msg
=$
(_post
"{\"action\": \"infoDnsRecords\", \"param\": {\"apikey\": \"$NC_Apikey\", \"apisessionid\": \"$sid\", \"customernumber\": \"$NC_CID\", \"domainname\": \"$domain\"}}" "$end" "" "POST")
74 rec
=$
(echo "$msg" |
sed 's/\[//g' |
sed 's/\]//g' |
sed 's/{\"serverrequestid\".*\"dnsrecords\"://g' |
sed 's/},{/};{/g' |
sed 's/{//g' |
sed 's/}//g')
76 if [ "$(_getfield "$msg" "5" | sed 's/"statuscode
"://g')" != 5028 ]; then
77 if [ "$(_getfield "$msg" "4" | sed s/\"status\":\"//g | sed s/\"//g)" != "success" ]; then
85 exit=$
(_math
"$exit" - 1)
95 specrec
=$
(_getfield
"$rec" "$i" ";")
97 ida
=$
(_getfield
"$specrec" "1" "," |
sed 's/\"id\":\"//g' |
sed 's/\"//g')
98 txtv
=$
(_getfield
"$specrec" "5" "," |
sed 's/\"destination\":\"//g' |
sed 's/\"//g')
100 if [ "$txtvalue" = "$txtv" ]; then
104 if [ "$ida" = "$idv" ]; then
108 msg
=$
(_post
"{\"action\": \"updateDnsRecords\", \"param\": {\"apikey\": \"$NC_Apikey\", \"apisessionid\": \"$sid\", \"customernumber\": \"$NC_CID\",\"clientrequestid\": \"$client\" , \"domainname\": \"$domain\", \"dnsrecordset\": { \"dnsrecords\": [ {\"id\": \"$ids\", \"hostname\": \"$fulldomain.\", \"type\": \"TXT\", \"priority\": \"\", \"destination\": \"$txtvalue\", \"deleterecord\": \"TRUE\", \"state\": \"yes\"} ]}}}" "$end" "" "POST")
110 if [ "$(_getfield "$msg" "4" | sed s/\"status\":\"//g | sed s/\"//g)" != "success" ]; then
118 tmp
=$
(_post
"{\"action\": \"login\", \"param\": {\"apikey\": \"$NC_Apikey\", \"apipassword\": \"$NC_Apipw\", \"customernumber\": \"$NC_CID\"}}" "$end" "" "POST")
119 sid
=$
(_getfield
"$tmp" "8" |
sed s
/\"responsedata
\":\
{\"apisessionid
\":\"//g |
sed 's/\"\}\}//g')
121 if [ "$(_getfield "$msg" "4" | sed s/\"status\":\"//g | sed s/\"//g)" != "success" ]; then
127 tmp
=$
(_post
"{\"action\": \"logout\", \"param\": {\"apikey\": \"$NC_Apikey\", \"apisessionid\": \"$sid\", \"customernumber\": \"$NC_CID\"}}" "$end" "" "POST")
129 if [ "$(_getfield "$msg" "4" | sed s/\"status\":\"//g | sed s/\"//g)" != "success" ]; then