summaryrefslogtreecommitdiffstats
path: root/Reaktor/commands/nag
blob: e5380fc31e641deba09ebc401fee353f6e157459 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#! /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

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.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' ' ')


#
# output
#
if test -n "$missing_services"; then
  echo missing services: $missing_services
fi
if test -n "$obsolete_services"; then
  echo obsolete services: $obsolete_services
fi