Unotelly Update

This script was written from scratch using what I learned from the No IP Script.

I have two pppoe clients configured, this script will only run if one of them is up.

This script runs every 15 minutes (can be a longer delay), and is called from the switch_isp scripts

# unotelly_update
### Unotelly Script Settings ###

:local UNOtellyToken "your_token_goes_here";

########################
# This variable is set via other scripts. The intent is so that this script
# doesn't call the API if it doesn't need to.
:global unotellyUpdateRequired;

:if ($unotellyUpdateRequired) do={
   :local inetup false;

   :if ([/interface get pppoe-out1 value-name=running] && !$inetup) do={
      :set inetup true;
   }

   :if ([/interface get pppoe-out2 value-name=running] && !$inetup) do={
      :set inetup true;
   }

   :if ($inetup) do={
        /tool fetch url="http://api.unotelly.com/api/v1/network/update_by_hash_api\3Fuser_hash=$UNOtellyToken" mode=http keep-result=no
        :log info "Unotelly Updated: Success";
        :set unotellyUpdateRequired false;
   } else={ :log info "Unotelly Update: No WAN interfaces are up" }
} else={ :log info "Unotelly Update: No update necessary" }