28 lines
521 B
Bash
Executable File
28 lines
521 B
Bash
Executable File
#!/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
|