2024-01-18 16:21:22 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -e
|
2024-01-19 11:06:49 +01:00
|
|
|
|
2024-01-18 16:21:22 +01:00
|
|
|
nginx -t
|
|
|
|
nginx -g 'daemon off;' &
|
|
|
|
nginx_pid=$!
|
2024-01-19 11:06:49 +01:00
|
|
|
|
|
|
|
trap 'kill "$nginx_pid"' EXIT
|
|
|
|
trap 'kill "$nginx_pid"' SIGTERM
|
|
|
|
|
2024-01-18 16:21:22 +01:00
|
|
|
function checkIsUpToDate() {
|
|
|
|
git fetch
|
|
|
|
git rev-list HEAD...origin/master --count | grep -q "^0$" && {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
function update() {
|
|
|
|
git reset --hard
|
|
|
|
git pull
|
|
|
|
make
|
|
|
|
mv /var/www/html /var/www/html-delme
|
2024-01-26 21:09:44 +01:00
|
|
|
mv public/ /var/www/html
|
2024-01-18 16:21:22 +01:00
|
|
|
rm -rf /var/www/html-delme &
|
|
|
|
git reset --hard
|
|
|
|
}
|
|
|
|
|
|
|
|
cd /repo
|
|
|
|
update
|
|
|
|
(
|
|
|
|
while true; do
|
|
|
|
sleep 15
|
|
|
|
checkIsUpToDate && continue
|
|
|
|
update
|
|
|
|
done
|
|
|
|
|
|
|
|
) &
|
|
|
|
|
2024-01-19 11:06:49 +01:00
|
|
|
(
|
|
|
|
while true; do
|
|
|
|
sleep 1h
|
|
|
|
update
|
|
|
|
|
|
|
|
done
|
|
|
|
) &
|
|
|
|
|
2024-01-18 16:21:22 +01:00
|
|
|
wait "$nginx_pid"
|