Last active
October 25, 2016 07:05
-
-
Save louisswarren/96461c51ac2b548c18e5cc09ef17d298 to your computer and use it in GitHub Desktop.
Automatically revert change to a config file
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/sh | |
# Example: | |
# deadman /etc/network/interfaces 120 && service networking restart & | |
# | |
# After two minutes, changes are reverted and the service is restarted. | |
# No getting locked out! | |
# (you were root weren't you?) | |
backup=`cat "$1"` | |
if [ -z "$2" ] | |
then | |
sleep 60 | |
else | |
sleep "$2" | |
fi | |
echo "$backup" > "$1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment