beepy
beepy copied to clipboard
making setup script re-runnable
just a tiny bit of extra bash
What if instead of checking for the existence of a previous setup attempt, the setup script cleaned up after itself instead? i.e. the script should delete its temporary directories and leave the home dir in the same state as before it was run.
I've changed the script to clean out the directories on failure and before exit. Haven't tested it so it's probably riddled with syntax errors
i think you will want to run cleanup at the beginning, regardless.
this will handle if the script fails or the user hits ctrl+c or a power outage etc.
there are still remaining files that could be a hazard, as-is.
even using a trap won't handle all scenarios. (trap may have been a bit more reliable or less tedious for you to setup than this way in some ways, but mostly equivalent with it's own issues)