summaryrefslogtreecommitdiff
path: root/netsaint/netsaint.sh
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2003-04-06 13:30:00 +0000
committerJonas Smedegaard <dr@jones.dk>2003-04-06 13:30:00 +0000
commitae7dfdf9670068eb8fa1955969084cd03fbcd3c4 (patch)
treeb1018a38b4bfc12241a10ab7b6800746424985aa /netsaint/netsaint.sh
parent14aead0d8924a0ea5e423c7bc4f16366e7152b9f (diff)
First attempt on structured netsaint organisation.
Diffstat (limited to 'netsaint/netsaint.sh')
-rwxr-xr-xnetsaint/netsaint.sh41
1 files changed, 41 insertions, 0 deletions
diff --git a/netsaint/netsaint.sh b/netsaint/netsaint.sh
new file mode 100755
index 0000000..c01cc2a
--- /dev/null
+++ b/netsaint/netsaint.sh
@@ -0,0 +1,41 @@
+#!/bin/bash
+#
+# /etc/local-COMMON/netsaint/netsaint.sh
+# Copyright 2003 Jonas Smedegaard <dr@jones.dk>
+#
+# $Id: netsaint.sh,v 1.1 2003-04-06 13:30:00 jonas Exp $
+#
+# Splice netsaint config together from netgroup parts
+#
+
+set -e
+
+metaconfdir='/etc/local-COMMON/netsaint'
+confdir='/etc/netsaint'
+conffile="$confdir/netsaint_local.cfg"
+
+host=`hostname -f`
+hostfile="${metaconfdir}/hosts_${host}.cfg"
+if [ ! -f "$hostfile" ]; then
+ echo "ERROR: Host config \"$hostfile\" not found!"
+ exit 1
+fi
+
+if [ -f "$conffile" ]; then
+ mv $conffile $conffile.old
+fi
+
+echo "###" > $conffile
+echo "### This file was auto-created. Manual edits will be lost!" >> $conffile
+echo "###" >> $conffile
+cat $hostfile | grep -v '^cfg_file' >> $conffile || true
+
+netgroupfiles=`cat $hostfile | grep '^cfg_file' | tr -d ' ' | sed -e 's/^cfg_file=//'`
+for netgroupfile in $netgroupfiles; do
+ if [ ! -f "$netgroupfile" ]; then
+ echo "ERROR: Netgroup config \"$netgroupfile\" not found!"
+ exit 1
+ fi
+ echo "## NETGROUP $netgroupfile" >> $conffile
+ cat "$netgroupfile" >> $conffile
+done