31 lines
894 B
Django/Jinja
31 lines
894 B
Django/Jinja
#!/usr/bin/env bash
|
|
|
|
eval `ssh-agent`
|
|
ssh-add "{{ hap_git_key }}"
|
|
|
|
|
|
#variables:
|
|
git_repo="{{ hap_git_repo }}"
|
|
folder_dest="{{ hap_git_dest }}"
|
|
hap_folder="{{ hap_git_folder }}"
|
|
|
|
#update the status of the repo (without pulling or modifing):
|
|
git -C $folder_dest fetch
|
|
|
|
#store the status of the repo:
|
|
git_before=$(git -C $folder_dest rev-parse HEAD)
|
|
git_after=$(git -C $folder_dest rev-parse @{u})
|
|
|
|
#compare the status before and after the fetch, if it's different it mwans there are change in the repo. so we'll need to pull it and update the files:
|
|
if [ "$git_before" != "$git_after" ]; then
|
|
echo "differensies"
|
|
git -C $folder_dest pull --ff-only
|
|
cp $folder_dest/haproxy.cfg $hap_folder/haproxy.cfg
|
|
systemctl restart haproxy
|
|
fi
|
|
|
|
if ! cmp $folder_dest/haproxy.cfg $hap_folder/haproxy.cfg >/dev/null 2>&1
|
|
then
|
|
cp $folder_dest/haproxy.cfg $hap_folder/haproxy.cfg
|
|
systemctl restart haproxy
|
|
fi
|