summaryrefslogtreecommitdiffstats
path: root/Reaktor/commands/nag
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2014-07-15 11:14:37 +0200
committermakefu <github@syntax-fehler.de>2014-07-15 11:14:37 +0200
commit34738b34fa674b1e55a001053dd1542fc446bffb (patch)
tree4c69e771654f4e3f363a96aab7cf74a2c48a0604 /Reaktor/commands/nag
parent0994d118cc3292e4464e97349da3015998d5beaa (diff)
parent141401974b683db6ab9be473b634f494c05c5565 (diff)
Merge branch 'master' of ssh://github.com/krebscode/painload
Diffstat (limited to 'Reaktor/commands/nag')
-rwxr-xr-xReaktor/commands/nag32
1 files changed, 32 insertions, 0 deletions
diff --git a/Reaktor/commands/nag b/Reaktor/commands/nag
new file mode 100755
index 00000000..68035831
--- /dev/null
+++ b/Reaktor/commands/nag
@@ -0,0 +1,32 @@
+#! /bin/sh
+set -euf
+
+cd "$workdir"
+
+if test -e nag.hosts; then
+ echo "nag seems to run already... if not, then delete $workdir/nag.*, please"
+ exit 23
+fi
+
+trap 'rm -f nag.hosts nag.services nag.patch' EXIT INT QUIT
+
+(cd "$hostsdir" && ls | sort) > nag.hosts
+(cd "$servicesdir" && ls | sort) > nag.services
+
+diff -u nag.hosts nag.services > nag.patch || :
+
+missing_services=$(sed -n '1d;2d;s/^-\(.*\)/\1/p' nag.patch | tr '\n' ' ')
+superfluous_services=$(sed -n '1d;2d;s/^+\(.*\)/\1/p' nag.patch | tr '\n' ' ')
+
+#
+# output
+#
+if test -n "$missing_services"; then
+ echo missing services: $missing_services
+fi
+if test -n "$superfluous_services"; then
+ echo superfluous services: $superfluous_services
+fi
+if test -z "$missing_services$superfluous_services"; then
+ echo hosts and services are in sync
+fi