Legacy Open Mesh: Custom.sh scripts overview
Topic
This article describes using custom .sh scripts on Datto access points.
Environment
- Datto Access Points
Description
Custom.sh scripts allow you to run a custom script one on an access point.
Custom.sh scripts are considered deprecated. We are not able to directly support your custom.sh scripts. Please strongly consider submitting a feature request, instead of writing a custom.sh script.
United States and Canada
FCC restrictions apply with regards to what scripts you can run. Please read the Custom.sh scripts approval process article, if you havent done so already.
How it works
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
Re-running a script
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. To clear the md5 checksum and re-run an existing script, use http://customsh.cloudtrax.com/noop/ first, then add your original script URL.
If you need to the script to run on a regular basis, it should install itself as a cronjob.
Schedule Script / Cronjob
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.