aboutsummaryrefslogtreecommitdiffstats
path: root/commands/nag
diff options
context:
space:
mode:
authortv <tv@shackspace.de>2014-07-15 12:37:34 +0200
committertv <tv@shackspace.de>2014-07-15 12:37:34 +0200
commitedd937a27961d3584297c048fbced3f95ef1310a (patch)
treecd46731e51a6539e521fe9dd74c82b4e895b4f67 /commands/nag
parentfd74369e3a74419c37c9f4d800fae1bf04e2047f (diff)
Reaktor nag: maintain own copies of git repos
Diffstat (limited to 'commands/nag')
-rwxr-xr-xcommands/nag23
1 files changed, 18 insertions, 5 deletions
diff --git a/commands/nag b/commands/nag
index 56c34c0..e5380fc 100755
--- a/commands/nag
+++ b/commands/nag
@@ -1,17 +1,30 @@
#! /bin/sh
set -euf
-if test -e nag.hosts; then
+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 nag.services nag.patch' EXIT INT QUIT
+trap 'rm -f nag.hosts.ls nag.services.ls nag.patch' EXIT INT QUIT
-(cd "$hostsdir" && ls | sort) > nag.hosts
-(cd "$servicesdir" && ls | sort) > nag.services
+if ! test -d nag.hosts; then
+ git clone "$hosts_repo" nag.hosts | grep -v 'Alreay up-to-date.'
+else
+ (cd nag.hosts && git pull)
+fi
+
+if ! test -d nag.services; then
+ git clone "$services_repo" nag.services | grep -v 'Already up-to-date.'
+else
+ (cd nag.services && git pull)
+fi
+
+
+(cd nag.hosts && ls | sort) > nag.hosts.ls
+(cd nag.services && ls | sort) > nag.services.ls
-diff -u nag.hosts nag.services > nag.patch || :
+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' ' ')