top of page
Ninja_JumpKick_bashedev-resized.png

>Linux - Bash Script

I wrote the script I'm presenting below to allow for the user directory synchronisation on the multiple production devices.  The problem I had was that the device could be powered down at any time and stay offline for days missing an update.  The update has to be done whilst the device was running in production, which was also problematic as rsync is locking access to the directory during the update.

Another problem I encouraged was the fact that the popular approach of using the md5 checksum to determinate if the update is needed was too time consuming.

I overcome this with the simple, but effective method of using a list of the file properties of the remote directory and the local directory and comparing them, if they were different rsync was lunched to perform the synchronisation.

To avoid a folder lock issue or corrupting the application due to the sudden power down cycle I used two directories.

One which was in current use and one for synchronisation and I edit app settings file to switch between them once the process was completed.

The script was launched after each boot or could be triggered by publishing the MQTT message.

The script was edited to remove the sensitive information.

bottom of page