We used to keep our Nagios config up to date through SVN, with users commiting their changes and a script running every 15 minutes. The script checked for updates, then checked those updates parsed the config check, then reloaded the config. Nice and simple, did the job perfectly.
We recently moved to GIT as part of a wider migration towards GIT for other projects and I'm having difficulty reworking this script to match.
Here is the original SVN version:
cd /usr/local/nagios RESULT=`svn update | grep Updated | wc -l` echo $RESULT if [ "$RESULT" != "0" ]; then /etc/init.d/nagios reload fi cd -
And here is my best efforts so far with GIT:
cd /usr/local/nagios RESULT=`git pull 2>&1 | grep Unpacking | wc -l` echo $RESULT if [ "$RESULT" != "0" ]; then /etc/init.d/nagios reload fi cd -
The problem I'm having is I can't seem to get the output parseable so I can match against it. I thought about going a different route by examining the most recent commit in the local working copy, and then checking if the remote most recent commit was different. I can't figure out though how to get this information.
I'm pretty new to GIT and this is driving me nuts, so my huge thanks in advance for any assistance!