Automate Heathergraph Update from GitHub
For heathergraph, based on How to check if a Git pull is needed. Makes a bit of a mess of logging to console but does the job.
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
0 0,8,12,16 * * * /home/pi/heathergraph_update.sh > /home/pi/heathergraph_update.log 2>&1 |
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 | |
GIT='git -C /home/pi/heathergraph/' | |
$GIT fetch | |
UPSTREAM=${1:-'@{u}'} | |
LOCAL=$($GIT rev-parse @) | |
REMOTE=$($GIT rev-parse "$UPSTREAM") | |
BASE=$($GIT merge-base @ "$UPSTREAM") | |
if [ $LOCAL = $REMOTE ]; then | |
echo "Git: Up-to-date" | |
elif [ $LOCAL = $BASE ]; then | |
echo "Git: Pulling" | |
$GIT stash | |
$GIT merge | |
$GIT stash pop | |
sudo python ./heathergraph/server.py restart | |
elif [ $REMOTE = $BASE ]; then | |
echo "Git: Need to push" | |
else | |
echo "Git: Oh dear" | |
fi | |