Anyone who works with Linux/UNIX.etc systems has probably experienced the dreaded moment where they change a setting and their SSH session drops never to be seen again. The result is the walk of shame to plug a keyboard and monitor into the system or, even worse, a long trip out to an offsite datacenter! I’ve done this more times than I’d like to admit!
In an attempt to make instances of this less frequent I developed Rewind. Rewind is a simple command line utility which can be used to make changes to a system and revert them after a period of time unless the user confirms that they are happy with the changes. Think of how operating systems like Windows handle changing the screen resolution.
How does it work?
It’s not really as magical as it first sounds! You must come up with two commands – One that makes/applies the changes to the system (known as the change command) and another that will revert the system to its previous state (known as the rollback command). You then supply both of these commands to Rewind. The change command will then be executed and if the user does nothing within 30 seconds the rollback command will be executed. If the user is happy with the changes, they can execute the “rollback keep” command which will prevent the rollback command from being executed.
For example, if you were changing the IP address on a FreeBSD system you could backup /etc/rc.conf to /tmp/rc.conf.bak then make the required changes to it. You would then use rewind with the change command set to
service netif restart && service routing restart which will apply the changes by restarting the networking and routing services. The rollback command would then be
cp /tmp/rc.conf.bak /etc/rc.conf && service netif restart && service routing restart which will restore the configuration from the backup then restart the networking and routing services so that the original settings are applied.
rewind run "touch foo" "rm foo" -t 60 Create a file called “foo”, if the user does not execute the keep command within 60 seconds, the file will be deleted.
rewind run "touch foo && rm bar" "rm foo && touch bar" Multiple commands can be supplied by joining them with “&&”
rewind run "./change.sh" "./rollback.sh" Shell scripts can be supplied instead of bare commands
rewind keep Keep the changes from the previous run (i.e. do not run the rollback command)
How do I get it?
You can find Rewind on Github: https://github.com/camerongray1515/Rewind along with documentation on how to install and use it.
There are releases available as well as the current development source code. There are currently no binary downloads so it needs to be built from source, thankfully there are no major dependencies and build instructions are provided. I am investigating releasing binary builds as well as submitting to various package repositories/ports trees.
I developed Rewind entirely myself and have only really tested it myself. It would be awesome to get feedback, especially bugs/feature requests submitted as issues on Github. Pull requests for improvements are also welcome!