diff options
Diffstat (limited to 'netsaint/netsaint.sh')
-rwxr-xr-x | netsaint/netsaint.sh | 41 |
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 |