add a script to automatically pull changes from git
This commit is contained in:
27
autoupdate.sh
Normal file
27
autoupdate.sh
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
LOCKFILE="/tmp/git_pull_lock"
|
||||||
|
|
||||||
|
if [ -f "$LOCKFILE" ]; then
|
||||||
|
echo "Script is already running. Exiting."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
touch "$LOCKFILE"
|
||||||
|
|
||||||
|
trap 'rm -f "$LOCKFILE"' EXIT
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
output=$(git pull 2>&1)
|
||||||
|
|
||||||
|
# Check if git pull actually fetched changes
|
||||||
|
if echo "$output" | grep -q "Already up[[:space:]]*to[[:space:]]*date\|up-to-date"; then
|
||||||
|
echo "No changes. $(date)"
|
||||||
|
else
|
||||||
|
echo "Changes pulled. $(date)"
|
||||||
|
echo "$output"
|
||||||
|
./start.sh
|
||||||
|
fi
|
||||||
|
|
||||||
|
sleep 60
|
||||||
|
done
|
||||||
Reference in New Issue
Block a user