summaryrefslogtreecommitdiffstats
path: root/Reaktor/reaktor/commands/nag
diff options
context:
space:
mode:
Diffstat (limited to 'Reaktor/reaktor/commands/nag')
-rwxr-xr-xReaktor/reaktor/commands/nag68
1 files changed, 68 insertions, 0 deletions
diff --git a/Reaktor/reaktor/commands/nag b/Reaktor/reaktor/commands/nag
new file mode 100755
index 00000000..f2141392
--- /dev/null
+++ b/Reaktor/reaktor/commands/nag
@@ -0,0 +1,68 @@
+#! /bin/sh
+set -euf
+if test -e nag.hosts.ls; then
+ echo "nag seems to run already... if not, then delete $workdir/nag.*, please"
+ exit 23
+fi
+
+trap 'rm -f nag.hosts.ls nag.services.ls nag.patch' EXIT INT QUIT
+
+
+# usage: git_pull_output_filter REPO_NAME
+git_pull_output_filter() {
+ sed -n 's/^ [0-9]\+ file change/'"$1"': &/p'
+}
+
+
+if ! test -d nag.hosts; then
+ git clone "$hosts_repo" nag.hosts
+else
+ (cd nag.hosts && git pull) | git_pull_output_filter hosts
+fi
+
+if ! test -d nag.services; then
+ git clone "$services_repo" nag.services
+else
+ (cd nag.services && git pull) | git_pull_output_filter services
+fi
+
+
+(cd nag.hosts && ls | sort) > nag.hosts.ls
+(cd nag.services && ls | sort) > nag.services.ls
+
+diff -u nag.hosts.ls nag.services.ls > nag.patch || :
+
+missing_services=$(sed -n '1d;2d;s/^-\(.*\)/\1/p' nag.patch | tr '\n' ' ')
+obsolete_services=$(sed -n '1d;2d;s/^+\(.*\)/\1/p' nag.patch | tr '\n' ' ')
+
+if test "${inspect_services-false}" = true; then
+ missing_owners=$(set +f; cd nag.services && grep '^owner:$' * | cut -d: -f1)
+ missing_mailtos=$(set +f; cd nag.services && grep '^mailto:$' * | cut -d: -f1)
+fi
+
+nag_missing_services='missing services'
+nag_obsolete_services='obsolete services'
+nag_missing_owners='services with missing owner entry'
+nag_missing_mailtos='services with missing mailto entry'
+
+#
+# output
+#
+did_nag=false
+for i in \
+ missing_services \
+ obsolete_services \
+ missing_owners \
+ missing_mailtos
+do
+ eval "offenders=\${$i-}; nag_msg=\$nag_$i"
+ if test -n "$offenders"; then
+ echo $nag_msg: $offenders
+ did_nag=true
+ fi
+done
+
+# if asked directly, answer if there is nothing to nag about
+if test $did_nag = false -a -n "${_from:-}";then
+ echo "nothing to nag about"
+fi