Commit 121cea62 authored by support@panter.ch's avatar support@panter.ch

feat: add update script to client

parent 49ef059e
#!/usr/bin/env bash
pushd /home/pi/hubscreen/
git fetch
# validate if an update is necessary. Crashes when local repo contains commits not pushed yet
# or when local and remote branches diverged:
UPSTREAM=${1:-'@{u}'}
LOCAL=$(git rev-parse @)
REMOTE=$(git rev-parse "$UPSTREAM")
BASE=$(git merge-base @ "$UPSTREAM")
if [ $LOCAL = $REMOTE ]; then
echo "Already up to date. Aborting update."
exit
elif [ $REMOTE = $BASE ]; then
echo "local repo contains commits not pushed to remote yet. Cleanup and execute this command again. Aborting update."
exit
elif [ $LOCAL = $BASE ]; then
echo "Update available. Pulling and restarting service..."
git pull
systemctl restart hubscreen_client.service
echo "service updated and restarted."
else
echo "Local and remote master branches diverged. Cleanup and execute this command again. Aborting update."
fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment