Skip to content

Instantly share code, notes, and snippets.

@dcai
Last active October 26, 2017 03:39
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 dcai/6632745 to your computer and use it in GitHub Desktop.
Save dcai/6632745 to your computer and use it in GitHub Desktop.
cron-git-update-equella.sh
#!/bin/bash
GITLOG="/var/log/equella/cron-update.log"
LOGFILE="/tmp/equellacodeupdate.log"
HTMLFILE="/tmp/equellacodeupdate.html"
EMAILADDR="equellacode@tux.im"
FROMEMAILADDR="git@tux.im"
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