From 85376174bda403937bb5dc543fbf8267fa8bc69d Mon Sep 17 00:00:00 2001 From: mateo Date: Fri, 12 Apr 2024 16:59:05 +0200 Subject: [PATCH 1/4] fix update --- scripts/update_script.sh | 26 +++++++++++--------------- scripts/update_script_develop.sh | 28 ++++++++++++---------------- 2 files changed, 23 insertions(+), 31 deletions(-) diff --git a/scripts/update_script.sh b/scripts/update_script.sh index 37890836..4ab89c11 100644 --- a/scripts/update_script.sh +++ b/scripts/update_script.sh @@ -1,33 +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 !" - + # Add any additional actions her + echo "$(date): Update done!" else echo "$(date): No changes detected" fi - diff --git a/scripts/update_script_develop.sh b/scripts/update_script_develop.sh index 91cd927a..bc6348e1 100644 --- a/scripts/update_script_develop.sh +++ b/scripts/update_script_develop.sh @@ -1,13 +1,8 @@ #!/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" @@ -15,19 +10,20 @@ 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 !" - + # Add any additional actions her + echo "$(date): Update done!" else echo "$(date): No changes detected" fi - From bfc1083661a2a8513960ab3fbd92e6867bf7cb77 Mon Sep 17 00:00:00 2001 From: mateo Date: Mon, 15 Apr 2024 17:34:50 +0200 Subject: [PATCH 2/4] add debug script --- scripts/debug_script.sh | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 scripts/debug_script.sh diff --git a/scripts/debug_script.sh b/scripts/debug_script.sh new file mode 100644 index 00000000..830fb776 --- /dev/null +++ b/scripts/debug_script.sh @@ -0,0 +1,2 @@ +#!/bin/bash +echo "$(date): Debug script executed !" \ No newline at end of file From d752cd72cb5e82b15d1f77194de1e463aaedf9fa Mon Sep 17 00:00:00 2001 From: mateo Date: Mon, 15 Apr 2024 17:36:22 +0200 Subject: [PATCH 3/4] execute debug script --- scripts/update_script.sh | 7 ++++--- scripts/update_script_develop.sh | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/scripts/update_script.sh b/scripts/update_script.sh index 4ab89c11..38a18339 100644 --- a/scripts/update_script.sh +++ b/scripts/update_script.sh @@ -7,7 +7,7 @@ # Print current date and time echo "$(date): Checking for updates" -# Navigate to the repository directory +# Navigate to the repository cd /home/pi/pyro-engine # Fetch main branch specifically and update local tracking @@ -20,10 +20,11 @@ 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 additional actions her + bash /home/pi/pyro-engine/scripts/debug_script.sh echo "$(date): Update done!" else echo "$(date): No changes detected" fi + diff --git a/scripts/update_script_develop.sh b/scripts/update_script_develop.sh index bc6348e1..0c97ac53 100644 --- a/scripts/update_script_develop.sh +++ b/scripts/update_script_develop.sh @@ -7,7 +7,7 @@ # Print current date and time echo "$(date): Checking for updates" -# Navigate to the repository directory +# Navigate to the repository cd /home/pi/pyro-engine # Fetch develop branch specifically and update local tracking @@ -20,10 +20,11 @@ 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 additional actions her + bash /home/pi/pyro-engine/scripts/debug_script.sh echo "$(date): Update done!" else echo "$(date): No changes detected" fi + From 961337bec39ac798d619bce4d2ce97d599d3c5b0 Mon Sep 17 00:00:00 2001 From: mateo Date: Mon, 15 Apr 2024 17:37:39 +0200 Subject: [PATCH 4/4] missing comment and blanck line --- scripts/debug_script.sh | 2 +- scripts/update_script.sh | 2 +- scripts/update_script_develop.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/debug_script.sh b/scripts/debug_script.sh index 830fb776..68b63d0a 100644 --- a/scripts/debug_script.sh +++ b/scripts/debug_script.sh @@ -1,2 +1,2 @@ #!/bin/bash -echo "$(date): Debug script executed !" \ No newline at end of file +echo "$(date): Debug script executed !" diff --git a/scripts/update_script.sh b/scripts/update_script.sh index 38a18339..ee862811 100644 --- a/scripts/update_script.sh +++ b/scripts/update_script.sh @@ -7,7 +7,7 @@ # Print current date and time echo "$(date): Checking for updates" -# Navigate to the repository +# Navigate to the repository directory cd /home/pi/pyro-engine # Fetch main branch specifically and update local tracking diff --git a/scripts/update_script_develop.sh b/scripts/update_script_develop.sh index 0c97ac53..4b1c1b20 100644 --- a/scripts/update_script_develop.sh +++ b/scripts/update_script_develop.sh @@ -7,7 +7,7 @@ # Print current date and time echo "$(date): Checking for updates" -# Navigate to the repository +# Navigate to the repository directory cd /home/pi/pyro-engine # Fetch develop branch specifically and update local tracking