Created
December 22, 2016 09:48
-
-
Save idiotandrobot/8897bac8f1cfd97677c22554eb46f22f to your computer and use it in GitHub Desktop.
Automate heathergraph update from github
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
0 0,8,12,16 * * * /home/pi/heathergraph_update.sh > /home/pi/heathergraph_update.log 2>&1 |
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/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 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment