Created
March 3, 2012 19:52
-
-
Save thomd/1967878 to your computer and use it in GitHub Desktop.
poor man's intrusion detection
This file contains hidden or 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 | |
# poor man's intrusion detection. | |
# | |
# usage: | |
# | |
# (1) add website to git: | |
# ssh my-webserver | |
# cd web-root-folder | |
# git init | |
# git add . | |
# git ci -m "my uncompromised website" | |
# | |
# (2) setup cronjob (check every 6 hours): | |
# MAILTO="" | |
# 0 */6 * * * /this/script /path/to/workingcopy/to/observe mail-address | |
# | |
die() { | |
echo >&2 "$@" | |
exit 1 | |
} | |
function parse_git_dirty { | |
[[ $(/usr/local/bin/ --git-dir=$1/.git --work-tree=$1 status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] | |
} | |
[ "$#" -eq 2 ] || die "usage:\n $(basename $0) <workingcopy> <mailto>" | |
if ( parse_git_dirty $1 ); then | |
/usr/local/bin/ --git-dir=$1/.git --work-tree=$1 status | mail -s "changes on $(hostname) in $1" $2 | |
fi | |
# vim:ft=sh | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment