Skip to content

Commit

Permalink
update dev script (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
MateoLostanlen authored Apr 11, 2024
1 parent 7c8cca9 commit 2c322cb
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions scripts/update_script_develop.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 hour
# 0 * * * * bash /home/pi/pyro-engine/scripts/update_script.sh
# 0 * * * * bash /home/pi/pyro-engine/scripts/update_script_develop.sh >> /home/pi/pyro-engine/logfile.log 2>&1


if [ `git -C /home/pi/pyro-engine pull origin develop | 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 develop
HEADHASH=$(git rev-parse HEAD)
UPSTREAMHASH=$(git rev-parse origin/develop)

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

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

0 comments on commit 2c322cb

Please sign in to comment.