Custom.sh scripts overview

Prerequisites

If you have not done so already, see the Custom.sh scripts approval process article before following this article.

Procedure

Fill the "custom.sh" field (under Advanced) with the URL (domain + folder) which contains your "custom.sh" script including the trailing slash. For example:

http://www.mydomain.com/subfolder/

The firmware will download the "custom.sh" file from that location each time the dashboard sends a full configuration reply to the device (mainly happens when the 'update network settings' button is pushed). Then its md5 checksum is compared with the previously executed custom.sh file. If the md5 checksums mismatch (the custom.sh has been altered) the custom.sh is executed otherwise it is not, thus ensuring each device executes the custom.sh file only once.

The custom.sh file itself is deleted after the firmware ran it. Only the md5 checksum is stored in the uci config system. To verify whether or not your script ran you can retrieve the checksum with:

uci get node.setting.cs_md5

We save the downloaded custom.sh file as custom_script.sh under the /tmp directory and then execute it using /bin/sh -c /tmp/custom_script.sh

Note that if you wish to run your script more than once (without altering it) you need to delete the stored md5 checksum and force a dashboard config reload by pushing the 'update network settings' button. Because downloading the script over and over is neither efficient nor feasible (you would have to keep pushing the button) it is recommended you install a permanent script onto the device and link it to one of the special purpose folders firmware-ng comes with:

  • /etc/cron.5mins/ - Every script in this folder will be executed every 5 minutes.
  • /etc/cron.hourly/ - Every script in this folder will be executed once per hour.
  • /etc/online.d/ - Every script beginning with a capital 'S' (as in 'start') followed by a number (e.g. 'S13') will be executed as soon an internet connection has been detected. If the script name begins with a 'K' (as in 'kill') followed by a number the script is executed when the internet connection is lost. The purpose of the number is to define the sequence in which the scripts are called.

To clear the md5 and re-run an existing script, use http://customsh.cloudtrax.com/noop/.

For security and compliance purposes, only custom scripts approved by Datto may be run on networking devices. To be eligible for support, scripts must have completed the approval process and be hosted on a Datto server. Custom script support will be deprecated in the future. If custom scripts are critical to your deployment and you require ongoing support after this date, contact your Datto sales representative. If you are a Datto partner and require presence analytics, consider configuring the Datto Networking syslog or presence API features.