summaryrefslogtreecommitdiffstats
path: root/Reaktor/commands/nag
blob: c07ed5b851102db43ce0b4e57046a1fd88b66dbe (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
#! /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' ' ')
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
if test -z "$missing_services$obsolete_services"; then
  echo hosts and services are in sync
fi