Browse Source

Updated code

Now parses any repo in /var/lib/ansible/ and compares
master
dave 2 years ago
parent
commit
988f629673
  1. 33
      usr.local.sbin/synch-from-repos.sh

33
usr.local.sbin/synch-from-repos.sh

@ -1,3 +1,4 @@
#!/bin/sh
## keeps the ansible playbooks updated from gitea ## keeps the ansible playbooks updated from gitea
## a quick check confirms alterationa to local files ## a quick check confirms alterationa to local files
## else.. those are updated with latest from gitea ## else.. those are updated with latest from gitea
@ -7,22 +8,26 @@ set -u
## -- path to the Ansible dirs ## -- path to the Ansible dirs
ANSBASE=/var/lib/ansible/ ANSBASE=/var/lib/ansible/
echo "$(date +'%F_%R:%S') ==== START ==== " echo "$(date +'%F_%R:%S'): ==== $(basename $0) START ==== "
## -- check each repo in turn ## -- check each repo in turn
cd ${ANSBASE} cd ${ANSBASE}
echo -e "$(date +'%F_%R:%S') checking ${ANSBASE} ... \c" for REPO in $(ls -d *)
STATUS="$(git status | tail -n1)" do
if [[ ! ${STATUS} =~ "nothing to commit" ]] echo -e "$(date +'%F_%R:%S') checking ${REPO} ... \c"
then cd ${ANSBASE}/${REPO}
echo "need to fix $ANSBASE, showing diff on next line" STATUS="$(git status | tail -n1)"
git diff if [[ ! ${STATUS} =~ "nothing to commit" ]]
git fetch origin &> /dev/null then
git reset --hard origin/master &> /dev/null echo "need to fix $ANSBASE, showing diff on next line"
else git diff
echo " ${STATUS}" git fetch origin &> /dev/null
fi git reset --hard origin/master &> /dev/null
git pull &> /dev/null else
echo " ${STATUS}"
fi
git pull &> /dev/null
done
echo "$(date +'%F_%R:%S') ------ END ------" echo "$(date +'%F_%R:%S'): ------ $(basename $0) END ------"

Loading…
Cancel
Save