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"
11 _debug NC_Apikey
"$NC_Apikey"
13 if [ "$NC_Apikey" = "" ] ||
[ "$NC_Apipw" = "" ] ||
[ "$NC_CID" = "" ]; then
14 _err
"No Credentials given"
17 _saveaccountconf_mutable NC_Apikey
"$NC_Apikey"
18 _saveaccountconf_mutable NC_Apipw
"$NC_Apipw"
19 _saveaccountconf_mutable NC_CID
"$NC_CID"
23 exit=$
(echo "$fulldomain" |
tr -dc '.' |
wc -c)
24 exit=$
(_math
"$exit" + 1)
30 tmp
=$
(echo "$fulldomain" | cut
-d'.' -f"$exit")
31 if [ "$(_math "$i" - "$exit")" -eq 0 ]; then
36 if [ "$(_math "$i" - "$exit")" -ge 1 ]; then
37 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")
39 if [ "$(_getfield "$msg" "5" | sed 's/"statuscode
"://g')" != 5028 ]; then
40 if [ "$(_getfield "$msg" "4" | sed s/\"status\":\"//g | sed s/\"//g)" != "success" ]; then
48 exit=$
(_math
"$exit" - 1)
59 exit=$
(echo "$fulldomain" |
tr -dc '.' |
wc -c)
60 exit=$
(_math
"$exit" + 1)
67 tmp
=$
(echo "$fulldomain" | cut
-d'.' -f"$exit")
68 if [ "$(_math "$i" - "$exit")" -eq 0 ]; then
73 if [ "$(_math "$i" - "$exit")" -ge 1 ]; then
74 msg
=$
(_post
"{\"action\": \"infoDnsRecords\", \"param\": {\"apikey\": \"$NC_Apikey\", \"apisessionid\": \"$sid\", \"customernumber\": \"$NC_CID\", \"domainname\": \"$domain\"}}" "$end" "" "POST")
75 rec
=$
(echo "$msg" |
sed 's/\[//g' |
sed 's/\]//g' |
sed 's/{\"serverrequestid\".*\"dnsrecords\"://g' |
sed 's/},{/};{/g' |
sed 's/{//g' |
sed 's/}//g')
77 if [ "$(_getfield "$msg" "5" | sed 's/"statuscode
"://g')" != 5028 ]; then
78 if [ "$(_getfield "$msg" "4" | sed s/\"status\":\"//g | sed s/\"//g)" != "success" ]; then
86 exit=$
(_math
"$exit" - 1)
96 specrec
=$
(_getfield
"$rec" "$i" ";")
98 ida
=$
(_getfield
"$specrec" "1" "," |
sed 's/\"id\":\"//g' |
sed 's/\"//g')
99 txtv
=$
(_getfield
"$specrec" "5" "," |
sed 's/\"destination\":\"//g' |
sed 's/\"//g')
101 if [ "$txtvalue" = "$txtv" ]; then
105 if [ "$ida" = "$idv" ]; then
109 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")
111 if [ "$(_getfield "$msg" "4" | sed s/\"status\":\"//g | sed s/\"//g)" != "success" ]; then
119 tmp
=$
(_post
"{\"action\": \"login\", \"param\": {\"apikey\": \"$NC_Apikey\", \"apipassword\": \"$NC_Apipw\", \"customernumber\": \"$NC_CID\"}}" "$end" "" "POST")
120 sid
=$
(echo "$tmp" |
tr '{}' '\n' |
grep apisessionid | cut
-d '"' -f 4)
122 if [ "$(_getfield "$tmp" "4" | sed s/\"status\":\"//g | sed s/\"//g)" != "success" ]; then
128 tmp
=$
(_post
"{\"action\": \"logout\", \"param\": {\"apikey\": \"$NC_Apikey\", \"apisessionid\": \"$sid\", \"customernumber\": \"$NC_CID\"}}" "$end" "" "POST")
130 if [ "$(_getfield "$tmp" "4" | sed s/\"status\":\"//g | sed s/\"//g)" != "success" ]; then