#!/bin/bash # # /etc/local-COMMON/netsaint/netsaint.sh # Copyright 2003 Jonas Smedegaard # # $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