-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
57e8b85
commit 2fb681b
Showing
1 changed file
with
10 additions
and
17 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,26 @@ | ||
#!/bin/bash | ||
# This script performs: | ||
# fetch origin main | ||
#- if any change: | ||
# 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 >> /home/pi/pyro-engine/logfile.log 2>&1 | ||
|
||
# This script fetches changes from the main branch and updates if there are any. | ||
|
||
# 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 | ||
# Fetch main branch specifically and update local tracking | ||
git fetch origin main:refs/remotes/origin/main | ||
|
||
# Get the lamain commit hash of the current HEAD and the remote main branch | ||
HEADHASH=$(git rev-parse HEAD) | ||
UPSTREAMHASH=$(git rev-parse origin/main) | ||
UPSTREAMHASH=$(git rev-parse refs/remotes/origin/main) | ||
|
||
# Compare hashes and update if they are different | ||
if [ "$HEADHASH" != "$UPSTREAMHASH" ] | ||
then | ||
echo "$(date): New changes detected ! Updating and executing script..." | ||
echo "$(date): New changes detected! Updating and executing script..." | ||
git pull origin main | ||
# Add any action here | ||
echo "$(date): Update done !" | ||
|
||
# Add any additional actions here | ||
echo "$(date): Update done!" | ||
else | ||
echo "$(date): No changes detected" | ||
fi | ||
|