From 96b8fec9278eb891aa2c3947f889669b949a6205 Mon Sep 17 00:00:00 2001 From: Dave on FENDER Date: Sun, 17 Apr 2022 11:45:43 +0100 Subject: [PATCH] added /usr/local/bin content --- usr.local.bin/altdir | 17 +++++++++++++++++ usr.local.bin/repofix | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 usr.local.bin/altdir create mode 100644 usr.local.bin/repofix diff --git a/usr.local.bin/altdir b/usr.local.bin/altdir new file mode 100644 index 0000000..51798ae --- /dev/null +++ b/usr.local.bin/altdir @@ -0,0 +1,17 @@ +#!/bin/bash +# HEADER: =========================================================== +# HEADER: This file is automanaged by puppet +# HEADER: While it can still be managed manually, it is definitely not recommended. +# HEADER: Any manual changes to this file run the risk of being overwritten! +# HEADER: =========================================================== + +if [ "$1" = "" ] +then + echo -e "Directory: \c" + pwd + ls -alFh --color=always |more +else + echo "Directory of: $1*" + ls -aldFh --color=always $1* |more +fi + diff --git a/usr.local.bin/repofix b/usr.local.bin/repofix new file mode 100644 index 0000000..7a1fb7d --- /dev/null +++ b/usr.local.bin/repofix @@ -0,0 +1,48 @@ +#!/bin/bash + +# HEADER: =========================================================== +# HEADER: This file is automanaged by puppet +# HEADER: While it can still be managed manually, it is definitely not recommended. +# HEADER: Any manual changes to this file run the risk of being overwritten! +# HEADER: =========================================================== + +## "repofix" keeps the puppet manifests updated from gitea +## a quick check confirms alterationa to local files +## else.. those are updated with latest from gitea + +set -u + +## -- path to the Puppet manifest dirs +REPOBASE=/var/lib/puppet/manifests + +## location of logfiles +LOGPATH=/var/log/repofix +LOGFILE=${LOGPATH}/repofix.log + +## -- just check that the logpath exists +[ ! -d ${LOGPATH} ] && mkdir -p ${LOGPATH} + +echo "$(date +'%F_%R:%S') ==== START ==== " >> ${LOGFILE} + +## -- check each repo in turn +cd ${REPOBASE} +for REPO in $(ls -d *) +do + cd ${REPOBASE}/${REPO} + echo -e "$(date +'%F_%R:%S') checking ${REPO} ... \c" + STATUS="$(git status | tail -n1)" + if [[ ! ${STATUS} =~ "nothing to commit" ]] + then + echo "need to fix $REPO, 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 >> ${LOGFILE} + +echo "$(date +'%F_%R:%S') ------ END ------" >> ${LOGFILE} + +