diff options
author | tv <tv@shackspace.de> | 2014-07-15 12:37:34 +0200 |
---|---|---|
committer | tv <tv@shackspace.de> | 2014-07-15 12:37:34 +0200 |
commit | 0a39b3ecd80965002044cf7ba9d0a99c94ad1261 (patch) | |
tree | f2c9115c7185638ce66b01286f8f10622ab3e38a | |
parent | 38769e12bfbc963e1bfd3226bdc0c907209bdb09 (diff) |
Reaktor nag: maintain own copies of git repos
-rwxr-xr-x | Reaktor/commands/nag | 23 | ||||
-rw-r--r-- | Reaktor/config.py | 4 |
2 files changed, 20 insertions, 7 deletions
diff --git a/Reaktor/commands/nag b/Reaktor/commands/nag index 56c34c01..e5380fc3 100755 --- a/Reaktor/commands/nag +++ b/Reaktor/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' ' ') diff --git a/Reaktor/config.py b/Reaktor/config.py index a09d1bce..0483d46b 100644 --- a/Reaktor/config.py +++ b/Reaktor/config.py @@ -86,8 +86,8 @@ on_ping = [ 'capname': 'nag', 'argv': [ 'commands/nag' ], 'env': { - 'hostsdir': '/home/tv/krebs/hosts', - 'servicesdir': '/home/tv/krebs/services' + 'hosts_repo': 'https://github.com/krebscode/hosts', + 'services_repo': '/home/tv/krebs/services' }, 'targets': irc_channels } |