Skip to content

Instantly share code, notes, and snippets.

@louisswarren
Last active October 25, 2016 07:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save louisswarren/96461c51ac2b548c18e5cc09ef17d298 to your computer and use it in GitHub Desktop.
Save louisswarren/96461c51ac2b548c18e5cc09ef17d298 to your computer and use it in GitHub Desktop.
Automatically revert change to a config file
#!/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