chnages by shellcheck
This commit is contained in:
parent
507ccd7717
commit
6119d7673d
@ -1,11 +1,11 @@
|
|||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
#Requirments: jq
|
#Requirments: jq
|
||||||
|
#by linux-insideDE
|
||||||
|
|
||||||
NC_Apikey="${NC_Apikey:-$(_readaccountconf_mutable NC_Apikey)}"
|
NC_Apikey="${NC_Apikey:-$(_readaccountconf_mutable NC_Apikey)}"
|
||||||
NC_Apipw="${NC_Apipw:-$(_readaccountconf_mutable NC_Apipw)}"
|
NC_Apipw="${NC_Apipw:-$(_readaccountconf_mutable NC_Apipw)}"
|
||||||
NC_CID="${NC_CID:-$(_readaccountconf_mutable NC_CID)}"
|
NC_CID="${NC_CID:-$(_readaccountconf_mutable NC_CID)}"
|
||||||
end=https://ccp.netcup.net/run/webservice/servers/endpoint.php?JSON
|
end="https://ccp.netcup.net/run/webservice/servers/endpoint.php?JSON"
|
||||||
client=""
|
client=""
|
||||||
|
|
||||||
dns_netcup_add() {
|
dns_netcup_add() {
|
||||||
@ -19,9 +19,10 @@ dns_netcup_add() {
|
|||||||
tld=""
|
tld=""
|
||||||
domain=""
|
domain=""
|
||||||
exit=0
|
exit=0
|
||||||
for (( i=20; i>0; i--))
|
i=20
|
||||||
|
while [ "$i" -gt 0 ];
|
||||||
do
|
do
|
||||||
tmp=$(cut -d'.' -f$i <<< $fulldomain)
|
tmp=$(echo "$fulldomain" | cut -d'.' -f$i)
|
||||||
if [ "$tmp" != "" ]; then
|
if [ "$tmp" != "" ]; then
|
||||||
if [ "$tld" = "" ]; then
|
if [ "$tld" = "" ]; then
|
||||||
tld=$tmp
|
tld=$tmp
|
||||||
@ -31,9 +32,11 @@ dns_netcup_add() {
|
|||||||
break;
|
break;
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
i=$((i - 1))
|
||||||
done
|
done
|
||||||
inc=""
|
inc=""
|
||||||
for (( i=1; i<($exit); i++))
|
i=1
|
||||||
|
while [ "$i" -lt "$exit" ];
|
||||||
do
|
do
|
||||||
if [ "$((exit-1))" = "$i" ]; then
|
if [ "$((exit-1))" = "$i" ]; then
|
||||||
inc="$inc$i"
|
inc="$inc$i"
|
||||||
@ -45,11 +48,13 @@ dns_netcup_add() {
|
|||||||
inc="$inc$i,"
|
inc="$inc$i,"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
i=$((i + 1))
|
||||||
done
|
done
|
||||||
tmp=$(cut -d'.' -f$inc <<< $fulldomain)
|
|
||||||
msg=$(_post "{\"action\": \"updateDnsRecords\", \"param\": {\"apikey\": \"$NC_Apikey\", \"apisessionid\": \"$sid\", \"customernumber\": \"$NC_CID\",\"clientrequestid\": \"$client\" , \"domainname\": \"$domain.$tld\", \"dnsrecordset\": { \"dnsrecords\": [ {\"id\": \"\", \"hostname\": \"$tmp\", \"type\": \"TXT\", \"priority\": \"\", \"destination\": \"$txtvalue\", \"deleterecord\": \"false\", \"state\": \"yes\"} ]}}}" $end "" "POST")
|
tmp=$(echo "$fulldomain" | cut -d'.' -f$inc)
|
||||||
|
msg=$(_post "{\"action\": \"updateDnsRecords\", \"param\": {\"apikey\": \"$NC_Apikey\", \"apisessionid\": \"$sid\", \"customernumber\": \"$NC_CID\",\"clientrequestid\": \"$client\" , \"domainname\": \"$domain.$tld\", \"dnsrecordset\": { \"dnsrecords\": [ {\"id\": \"\", \"hostname\": \"$tmp\", \"type\": \"TXT\", \"priority\": \"\", \"destination\": \"$txtvalue\", \"deleterecord\": \"false\", \"state\": \"yes\"} ]}}}" "$end" "" "POST")
|
||||||
_debug "$msg"
|
_debug "$msg"
|
||||||
if [ $(echo $msg | jq -r .status) != "success" ]; then
|
if [ "$(echo "$msg" | jq -r .status)" != "success" ]; then
|
||||||
_err "$msg"
|
_err "$msg"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@ -63,9 +68,10 @@ dns_netcup_rm() {
|
|||||||
tld=""
|
tld=""
|
||||||
domain=""
|
domain=""
|
||||||
exit=0
|
exit=0
|
||||||
for (( i=20; i>0; i--))
|
i=20
|
||||||
|
while [ "$i" -gt 0 ];
|
||||||
do
|
do
|
||||||
tmp=$(cut -d'.' -f$i <<< $fulldomain)
|
tmp=$(echo "$fulldomain" | cut -d'.' -f$i)
|
||||||
if [ "$tmp" != "" ]; then
|
if [ "$tmp" != "" ]; then
|
||||||
if [ "$tld" = "" ]; then
|
if [ "$tld" = "" ]; then
|
||||||
tld=$tmp
|
tld=$tmp
|
||||||
@ -75,9 +81,11 @@ dns_netcup_rm() {
|
|||||||
break;
|
break;
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
i=$((i - 1))
|
||||||
done
|
done
|
||||||
inc=""
|
inc=""
|
||||||
for (( i=1; i<($exit); i++))
|
i=1
|
||||||
|
while [ "$i" -lt "$exit" ];
|
||||||
do
|
do
|
||||||
if [ "$((exit-1))" = "$i" ]; then
|
if [ "$((exit-1))" = "$i" ]; then
|
||||||
inc="$inc$i"
|
inc="$inc$i"
|
||||||
@ -89,14 +97,15 @@ dns_netcup_rm() {
|
|||||||
inc="$inc$i,"
|
inc="$inc$i,"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
i=$((i + 1))
|
||||||
done
|
done
|
||||||
tmp=$(cut -d'.' -f$inc <<< $fulldomain)
|
tmp=$(echo "$fulldomain" | cut -d'.' -f$inc)
|
||||||
doma="$domain.$tld"
|
doma="$domain.$tld"
|
||||||
rec=$(getRecords $doma)
|
rec=$(getRecords "$doma")
|
||||||
ids=$(echo $rec | jq -r ".[]|select(.destination==\"$txtvalue\")|.id")
|
ids=$(echo "$rec" | jq -r ".[]|select(.destination==\"$txtvalue\")|.id")
|
||||||
msg=$(_post "{\"action\": \"updateDnsRecords\", \"param\": {\"apikey\": \"$NC_Apikey\", \"apisessionid\": \"$sid\", \"customernumber\": \"$NC_CID\",\"clientrequestid\": \"$client\" , \"domainname\": \"$doma\", \"dnsrecordset\": { \"dnsrecords\": [ {\"id\": \"$ids\", \"hostname\": \"$tmp\", \"type\": \"TXT\", \"priority\": \"\", \"destination\": \"$txtvalue\", \"deleterecord\": \"TRUE\", \"state\": \"yes\"} ]}}}" $end "" "POST")
|
msg=$(_post "{\"action\": \"updateDnsRecords\", \"param\": {\"apikey\": \"$NC_Apikey\", \"apisessionid\": \"$sid\", \"customernumber\": \"$NC_CID\",\"clientrequestid\": \"$client\" , \"domainname\": \"$doma\", \"dnsrecordset\": { \"dnsrecords\": [ {\"id\": \"$ids\", \"hostname\": \"$tmp\", \"type\": \"TXT\", \"priority\": \"\", \"destination\": \"$txtvalue\", \"deleterecord\": \"TRUE\", \"state\": \"yes\"} ]}}}" "$end" "" "POST")
|
||||||
_debug "$msg"
|
_debug "$msg"
|
||||||
if [ $(echo $msg | jq -r .status) != "success" ]; then
|
if [ "$(echo "$msg" | jq -r .status)" != "success" ]; then
|
||||||
_err "$msg"
|
_err "$msg"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@ -104,29 +113,29 @@ dns_netcup_rm() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
login() {
|
login() {
|
||||||
tmp=$(_post '{"action": "login", "param": {"apikey": "'$NC_Apikey'", "apipassword": "'$NC_Apipw'", "customernumber": "'$NC_CID'"}}' $end "" "POST")
|
tmp=$(_post "{\"action\": \"login\", \"param\": {\"apikey\": \"$NC_Apikey\", \"apipassword\": \"$NC_Apipw\", \"customernumber\": \"$NC_CID\"}}" "$end" "" "POST")
|
||||||
sid=$(echo ${tmp} | jq -r .responsedata.apisessionid)
|
sid=$(echo "$tmp" | jq -r .responsedata.apisessionid)
|
||||||
_debug "$tmp"
|
_debug "$tmp"
|
||||||
if [ $(echo $tmp | jq -r .status) != "success" ]; then
|
if [ "$(echo "$tmp" | jq -r .status)" != "success" ]; then
|
||||||
_err "$tmp"
|
_err "$tmp"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
logout() {
|
logout() {
|
||||||
tmp=$(_post '{"action": "logout", "param": {"apikey": "'$NC_Apikey'", "apisessionid": "'$sid'", "customernumber": "'$NC_CID'"}}' $end "" "POST")
|
tmp=$(_post "{\"action\": \"logout\", \"param\": {\"apikey\": \"$NC_Apikey\", \"apisessionid\": \"$sid\", \"customernumber\": \"$NC_CID\"}}" "$end" "" "POST")
|
||||||
_debug "$tmp"
|
_debug "$tmp"
|
||||||
if [ $(echo $tmp | jq -r .status) != "success" ]; then
|
if [ "$(echo "$tmp" | jq -r .status)" != "success" ]; then
|
||||||
_err "$tmp"
|
_err "$tmp"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
getRecords() {
|
getRecords() {
|
||||||
tmp2=$(_post "{\"action\": \"infoDnsRecords\", \"param\": {\"apikey\": \"$NC_Apikey\", \"apisessionid\": \"$sid\", \"customernumber\": \"$NC_CID\", \"domainname\": \"$1\"}}" $end "" "POST")
|
tmp2=$(_post "{\"action\": \"infoDnsRecords\", \"param\": {\"apikey\": \"$NC_Apikey\", \"apisessionid\": \"$sid\", \"customernumber\": \"$NC_CID\", \"domainname\": \"$1\"}}" "$end" "" "POST")
|
||||||
xxd=$(echo ${tmp2} | jq -r '.responsedata.dnsrecords | .[]')
|
xxd=$(echo "$tmp2" | jq -r ".responsedata.dnsrecords | .[]")
|
||||||
xcd=$(echo $xxd | sed 's/} {/},{/g')
|
xcd=$(echo $xxd | sed 's/} {/},{/g')
|
||||||
echo "[ $xcd ]"
|
echo "[ $xcd ]"
|
||||||
_debug "$tmp2"
|
_debug "$tmp2"
|
||||||
if [ $(echo $tmp2 | jq -r .status) != "success" ]; then
|
if [ "$(echo "$tmp2" | jq -r .status)" != "success" ]; then
|
||||||
_err "$tmp2"
|
_err "$tmp2"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user