Last active
October 26, 2017 03:39
-
-
Save dcai/6632745 to your computer and use it in GitHub Desktop.
cron-git-update-equella.sh
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/bash | |
GITLOG="/var/log/equella/cron-update.log" | |
LOGFILE="/tmp/equellacodeupdate.log" | |
HTMLFILE="/tmp/equellacodeupdate.html" | |
EMAILADDR="[email protected]" | |
FROMEMAILADDR="[email protected]" | |
SUBJECT="EQUELLA code" | |
EQSRC=/var/equella-source/ | |
EQTESTSRC=/home/dcai/src/equella-automated-tests | |
cd "$EQSRC" | |
git fetch upstream &> $LOGFILE | |
cd "$EQTESTSRC" | |
git fetch upstream -q | |
if [[ -s $LOGFILE ]]; then | |
echo "" &>> $LOGFILE | |
date "+%d/%m/%Y %H:%M" &>> $GITLOG | |
echo "##################" &>> $LOGFILE | |
echo "" &>> $LOGFILE | |
git diff master upstream/master &>> $LOGFILE | |
echo "" &>> $LOGFILE | |
echo "##################" &>> $LOGFILE | |
if which mutt &>/dev/null; then | |
echo '<html><head></head><body><pre style="font-size: 12px">' > "${HTMLFILE}" | |
cat -v $LOGFILE >> "${HTMLFILE}" | |
echo "</pre></body></html>" >> "${HTMLFILE}" | |
cat -v "${HTMLFILE}" | /usr/bin/mutt -e 'set content_type="text/html"' -e "my_hdr From:${FROMEMAILADDR}" "${EMAILADDR}" -s "$SUBJECT" | |
rm $HTMLFILE | |
else | |
cat -v $LOGFILE | mail -r "${FROMEMAILADDR}" -s "$SUBJECT" "${EMAILADDR}" | |
fi | |
fi | |
rm -f $LOGFILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment