You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
1.7 KiB

  1. #.Distributed under the terms of the GNU General Public License (GPL) version 2.0
  2. #.2018 Michal Lipka <michal at sysadmin dot care>
  3. local __DUMMY
  4. local __URL="https://freedns.42.pl/xmlrpc.php"
  5. [ -z "$username" ] && write_log 14 "Service section not configured correctly! Missing 'username'"
  6. [ -z "$password" ] && write_log 14 "Service section not configured correctly! Missing 'password'"
  7. [ $ip_dynamic -eq 1 ] && __IP='\&lt;dynamic\&gt;'
  8. PROG="$(command -v curl) -sk"
  9. write_log 7 "sending update to freedns.42.pl with ip $__IP"
  10. XMLDATA="<?xml version='1.0'?><methodCall><methodName>xname.updateArecord</methodName><params><param><value><struct><member><name>name</name><value><string>[RECORDNAME]</string></value></member><member><name>zone</name><value><string>[ZONENAME]</string></value></member><member><name>oldaddress</name><value><string>*</string></value></member><member><name>updatereverse</name><value><string>0</string></value></member><member><name>user</name><value><string>[USERNAME]</string></value></member><member><name>ttl</name><value><string>600</string></value></member><member><name>newaddress</name><value><string>[IP]</string></value></member><member><name>password</name><value><string>[PASSWORD]</string></value></member></struct></value></param></params></methodCall>"
  11. XMLDATA=$(echo $XMLDATA | sed -e "s#\[USERNAME\]#$URL_USER#g" -e "s#\[PASSWORD\]#$URL_PASS#g" \
  12. -e "s#\[ZONENAME\]#$zone#g" -e "s#\[RECORDNAME\]#$record#g" -e "s#\[IP\]#$__IP#g")
  13. $PROG -d "$XMLDATA" -o $DATFILE $__URL || return 1
  14. write_log 7 "'freedns.42.pl' answered:${N}$(cat $DATFILE)"
  15. grep "<fault>" $DATFILE > /dev/null 2>&1 && return 1
  16. grep '<name>serial</name>' $DATFILE >/dev/null 2>&1
  17. return $?