From 988f629673541d3311d09c5ca1e16d1475a1dba8 Mon Sep 17 00:00:00 2001 From: dave Date: Sat, 10 Jun 2023 12:43:10 +0100 Subject: [PATCH] Updated code Now parses any repo in /var/lib/ansible/ and compares --- usr.local.sbin/synch-from-repos.sh | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/usr.local.sbin/synch-from-repos.sh b/usr.local.sbin/synch-from-repos.sh index 2c7a775..0cafb3b 100644 --- a/usr.local.sbin/synch-from-repos.sh +++ b/usr.local.sbin/synch-from-repos.sh @@ -1,3 +1,4 @@ +#!/bin/sh ## keeps the ansible playbooks updated from gitea ## a quick check confirms alterationa to local files ## else.. those are updated with latest from gitea @@ -7,22 +8,26 @@ set -u ## -- path to the Ansible dirs ANSBASE=/var/lib/ansible/ -echo "$(date +'%F_%R:%S') ==== START ==== " +echo "$(date +'%F_%R:%S'): ==== $(basename $0) START ==== " ## -- check each repo in turn cd ${ANSBASE} -echo -e "$(date +'%F_%R:%S') checking ${ANSBASE} ... \c" -STATUS="$(git status | tail -n1)" -if [[ ! ${STATUS} =~ "nothing to commit" ]] -then - echo "need to fix $ANSBASE, showing diff on next line" - git diff - git fetch origin &> /dev/null - git reset --hard origin/master &> /dev/null -else - echo " ${STATUS}" -fi -git pull &> /dev/null +for REPO in $(ls -d *) +do + echo -e "$(date +'%F_%R:%S') checking ${REPO} ... \c" + cd ${ANSBASE}/${REPO} + STATUS="$(git status | tail -n1)" + if [[ ! ${STATUS} =~ "nothing to commit" ]] + then + echo "need to fix $ANSBASE, showing diff on next line" + git diff + git fetch origin &> /dev/null + git reset --hard origin/master &> /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 ------"