Last active
October 5, 2022 22:30
-
-
Save frgomes/2b52f79928fbdbaf53d35b3afddae795 to your computer and use it in GitHub Desktop.
etckeeper - rollback and reboot in case of not committed changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sleep 300 | |
[[ -d /etc/.git ]] && cd /etc && \ | |
[[ $(git status --short | wc -l) -gt 0 ]] && \ | |
git stash && \ | |
logger etckeeper-roolback: reverted /etc to a previous state && \ | |
sync; sync; sync && \ | |
reboot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Scenario
You are remotely changint the network configuration of your server.
If you make a mistake, you will not be able to connect to your server after reboot.
Solution
The script
/etc/etckeeper/rollback-reboot
shown above reverts the changes in your/etc
and performs a reboot, in case you do not kill it in 5 minutes.Requirements
You must have the following packages installed:
You also must call /etc/etckeeper/rollback-reboot like this in your
/etc/rc.local
like this: