Skip to content

Instantly share code, notes, and snippets.

@idiotandrobot
Created December 22, 2016 09:48
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Automate heathergraph update from github
0 0,8,12,16 * * * /home/pi/heathergraph_update.sh > /home/pi/heathergraph_update.log 2>&1
#!/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