Ultimamente mi sono trovato davanti ad alcuni sistemi i cui LOG erano per gran parte composti da informazioni riguardanti gli update di DynDNS o il parsing degli IP seguito da "Update non necessario".
Forse avrò compilato io uno script troppo "logorroico", fatto sta che l'ho snellito un po' ed a mio parere è molto più comodo!
Volevo solo condividere con voi questo script, non si sa mai che a qualcuno torni utile!
![ok [ok]](./images/smilies/oh73.gif)
- Codice: Seleziona tutto
####### VARIABILI LOCALI #######
:local username “ACCOUNT”
:local password “PASSWORD”
:local hostname “INDIRIZZO.DYNDNS.COM”
:global dyndnsForce "false"
:global previousIP
####### CONTROLLO DEGLI IP #######
/tool fetch mode=http address="checkip.dyndns.org" src-path="/" dst-path="/dyndns.checkip.html"
:local result [/file get dyndns.checkip.html contents]
####### IP PARSING #######
:local resultLen [:len $result]
:local startLoc [:find $result ": " -1]
:set startLoc ($startLoc + 2)
:local endLoc [:find $result "</body>" -1]
:local currentIP [:pick $result $startLoc $endLoc]
####### NECESSITA' DI UPDATE #######
:if (($currentIP != $previousIP) || ($dyndnsForce = true)) do={
:log info "======================== DYNDNS UPDATE ========================="
:log info ("UpdateDynDNS: hostname = $hostname")
:log info ("UpdateDynDNS: previousIP = $previousIP")
:log info "UpdateDynDNS: currentIP = $currentIP"
:set dyndnsForce false
:set previousIP $currentIP
/tool fetch user=$username password=$password mode=http address="members.dyndns.org" \
src-path="nic/update?system=dyndns&hostname=$hostname&myip=$currentIP&wildcard=no" \
dst-path="/dyndns.txt"
:local result [/file get dyndns.txt contents]
:log info ("UpdateDynDNS: Dyndns Update Result: ".$result)
:log info "================================================================"
:put ("Dyndns Update Result: ".$result)
} else={
:log info "================================================================"
:log info " DNS CHECK NOT NEEDED ON $currentIP "
:log info "================================================================"
}
Spero di esservi stato utile, a presto!!
![bye [bye]](./images/smilies/oh56.gif)