-
-
Save molotovbliss/863d5afac8b9d68f6e0076297c1300cc to your computer and use it in GitHub Desktop.
Uses git to detect changes in web root and email administrators daily
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/env bash | |
# | |
# Example use: Add the following line to your crontab to run the script on a daily basis. | |
# | |
# 1 6 * * * ~/bin/compare_and_email.sh <full_path_to_webroot> "Email Subject Line" "[email protected] [email protected]" | |
# | |
date=`date +%Y%m%d` | |
gitdir="$1" | |
subject="$2" | |
emails="$3" | |
cd "$gitdir" | |
bash -c 'echo "## changes sha1sum" $(echo $(git diff -a && git diff -a --cached) | sha1sum) "HEAD ref" $(git rev-parse HEAD) && git status -sb' > ~/daily_status/status/${date}_git_status.txt | |
results=`git diff ~/daily_status/yesterday.txt ~/daily_status/status/${date}_git_status.txt` | |
changed=$? | |
cp ~/daily_status/status/${date}_git_status.txt ~/daily_status/yesterday.txt | |
if [ $changed -ne 0 ] | |
then | |
echo -e "$results" | mail -s "$subject" "$emails" | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment