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

new script #178

Merged
merged 3 commits into from
Apr 9, 2024
Merged
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
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

Loading