Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix update #186

Merged
merged 4 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions scripts/debug_script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
echo "$(date): Debug script executed !"
25 changes: 11 additions & 14 deletions scripts/update_script.sh
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
#!/bin/bash
# This script performs:
# fetch origin main
#- if any change:
# pull changes
# any others change needed
#
# This script fetches changes from the main branch and updates if there are any.
#
# 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


# 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 !"

bash /home/pi/pyro-engine/scripts/debug_script.sh
echo "$(date): Update done!"
else
echo "$(date): No changes detected"
fi
Expand Down
27 changes: 12 additions & 15 deletions scripts/update_script_develop.sh
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
#!/bin/bash
# This script performs:
# fetch origin main
#- if any change:
# pull changes
# any others change needed
#
# This script fetches changes from the develop branch and updates if there are any.
#
# This script must be run with a crontab, run every hour
# 0 * * * * bash /home/pi/pyro-engine/scripts/update_script_develop.sh >> /home/pi/pyro-engine/logfile.log 2>&1

# 0 * * * * bash /home/pi/pyro-engine/scripts/update_script.sh >> /home/pi/pyro-engine/logfile.log 2>&1

# 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
# Fetch develop branch specifically and update local tracking
git fetch origin develop:refs/remotes/origin/develop

# Get the ladevelop commit hash of the current HEAD and the remote develop branch
HEADHASH=$(git rev-parse HEAD)
UPSTREAMHASH=$(git rev-parse origin/develop)
UPSTREAMHASH=$(git rev-parse refs/remotes/origin/develop)

# 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 develop
# Add any action here
echo "$(date): Update done !"

bash /home/pi/pyro-engine/scripts/debug_script.sh
echo "$(date): Update done!"
else
echo "$(date): No changes detected"
fi
Expand Down
Loading