Skip to content

Commit

Permalink
new script (#178)
Browse files Browse the repository at this point in the history
* new script

* wrong file name
  • Loading branch information
MateoLostanlen authored Apr 9, 2024
1 parent 2cbe807 commit af11a77
Showing 1 changed file with 27 additions and 13 deletions.
40 changes: 27 additions & 13 deletions scripts/update_script.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
#!/bin/bash
# This script performs:
# pull origin main
# fetch origin main
#- if any change:
# kill container
# rebuild docker compose
# pull changes
# any others change needed
#
# This script must be run with a crontab, run every day at 3am
# 0 3 * * * bash /home/pi/pyro-engine/scripts/update_script.sh
# This script must be run with a crontab, run every hour
# 0 * * * * bash /home/pi/pyro-engine/scripts/update_script.sh >> /home/pi/pyro-engine/logfile.log 2>&1


if [ `git -C /home/pi/pyro-engine pull origin main | grep -c "up to date."` -ne 1 ];
then
echo "pyro-engine up to date";
else
echo "pyro-engine updated from github";
make -C /home/pi/pyro-engine stop
make -C /home/pi/pyro-engine run
fi;
# Print current date and time
echo "$(date): Checking for updates"

# Navigate to the repository directory
cd /home/pi/pyro-engine

# Check for updates and pull
git fetch origin
HEADHASH=$(git rev-parse HEAD)
UPSTREAMHASH=$(git rev-parse origin/main)

if [ "$HEADHASH" != "$UPSTREAMHASH" ]
then
echo "$(date): New changes detected ! Updating and executing script..."
git pull origin main
# Add any action here
echo "$(date): Update done !"

else
echo "$(date): No changes detected"
fi

0 comments on commit af11a77

Please sign in to comment.