Scripting Software Updates
I wrote a shell script that can periodically check a URL for updates. It can download and run another script to apply those updates, potentially overwriting the first script if the update mechanism needs to change.  I needed  a way to install the update script initially, so I wrote a Python script to read and escape each line of the update script, then generate an install script which can write the update script if it is not installed.  Following me so far?  Good.
So this update script is on an embedded Linux device and can be completely wiped away if the user does a factory reset or firmware update from the manufacturer. Â If they do that, my enhancements to the device and my upgrade script are gone, making the device useless for the particular application. Â Fortunately, the manufacturer gives me a way to store a one-line setting in an area of flash that doesn’t get erased. Â And even better, the default firmware will read and evaluate this one line setting in the shell on startup. Â AHA!
The aforementioned Python script also takes the install script, packs it into one line, escapes everything again, and creates a bootstrap script, whose sole purpose is to write the one setting that gets read on startup, that runs the install script, which creates the update script, which periodically checks for updates to the whole thing.
And now my head hurts. Â But it works!