query_recordid() { if [ "$Host" = "@" ] then send_request "DescribeSubDomainRecords""SignatureMethod=HMAC-SHA1&SignatureNonce=$timestamp&SignatureVersion=1.0&SubDomain=$Domain&Timestamp=$timestamp&Type=A" elif [ "$Host" = "*" ] then send_request "DescribeSubDomainRecords""SignatureMethod=HMAC-SHA1&SignatureNonce=$timestamp&SignatureVersion=1.0&SubDomain=%2A.$Domain&Timestamp=$timestamp&Type=A" else send_request "DescribeSubDomainRecords""SignatureMethod=HMAC-SHA1&SignatureNonce=$timestamp&SignatureVersion=1.0&SubDomain=$Host.$Domain&Timestamp=$timestamp&Type=A" fi }
update_record() { if [ "$Host" = "@" ] then send_request "UpdateDomainRecord""RR=%40&RecordId=$1&SignatureMethod=HMAC-SHA1&SignatureNonce=$timestamp&SignatureVersion=1.0&TTL=600&Timestamp=$timestamp&Type=A&Value=$ip" elif [ "$Host" = "*" ] then send_request "UpdateDomainRecord""RR=%2A&RecordId=$1&SignatureMethod=HMAC-SHA1&SignatureNonce=$timestamp&SignatureVersion=1.0&TTL=600&Timestamp=$timestamp&Type=A&Value=$ip" else send_request "UpdateDomainRecord""RR=$Host&RecordId=$1&SignatureMethod=HMAC-SHA1&SignatureNonce=$timestamp&SignatureVersion=1.0&TTL=600&Timestamp=$timestamp&Type=A&Value=$ip" fi }
add_record() { if [ "$Host" = "@" ] then send_request "AddDomainRecord&DomainName=$Domain""RR=%40&SignatureMethod=HMAC-SHA1&SignatureNonce=$timestamp&SignatureVersion=1.0&TTL=600&Timestamp=$timestamp&Type=A&Value=$ip" elif [ "$Host" = "*" ] then send_request "AddDomainRecord&DomainName=$Domain""RR=%2A&SignatureMethod=HMAC-SHA1&SignatureNonce=$timestamp&SignatureVersion=1.0&TTL=600&Timestamp=$timestamp&Type=A&Value=$ip" else send_request "AddDomainRecord&DomainName=$Domain""RR=$Host&SignatureMethod=HMAC-SHA1&SignatureNonce=$timestamp&SignatureVersion=1.0&TTL=600&Timestamp=$timestamp&Type=A&Value=$ip" fi }
if [ "$aliddns_record_id" = "" ] then aliddns_record_id=`query_recordid | get_recordid` fi if [ "$aliddns_record_id" = "" ] then aliddns_record_id=`add_record | get_recordid` else update_record $aliddns_record_id fi
if [ $? -eq 0 ]; then /sbin/ddns_custom_updated 1 else /sbin/ddns_custom_updated 0 fi