summaryrefslogtreecommitdiff
path: root/netsaint/netsaint.sh
blob: c01cc2add279c35861b73694de5e3ce90d61172f (plain)
  1. #!/bin/bash
  2. #
  3. # /etc/local-COMMON/netsaint/netsaint.sh
  4. # Copyright 2003 Jonas Smedegaard <dr@jones.dk>
  5. #
  6. # $Id: netsaint.sh,v 1.1 2003-04-06 13:30:00 jonas Exp $
  7. #
  8. # Splice netsaint config together from netgroup parts
  9. #
  10. set -e
  11. metaconfdir='/etc/local-COMMON/netsaint'
  12. confdir='/etc/netsaint'
  13. conffile="$confdir/netsaint_local.cfg"
  14. host=`hostname -f`
  15. hostfile="${metaconfdir}/hosts_${host}.cfg"
  16. if [ ! -f "$hostfile" ]; then
  17. echo "ERROR: Host config \"$hostfile\" not found!"
  18. exit 1
  19. fi
  20. if [ -f "$conffile" ]; then
  21. mv $conffile $conffile.old
  22. fi
  23. echo "###" > $conffile
  24. echo "### This file was auto-created. Manual edits will be lost!" >> $conffile
  25. echo "###" >> $conffile
  26. cat $hostfile | grep -v '^cfg_file' >> $conffile || true
  27. netgroupfiles=`cat $hostfile | grep '^cfg_file' | tr -d ' ' | sed -e 's/^cfg_file=//'`
  28. for netgroupfile in $netgroupfiles; do
  29. if [ ! -f "$netgroupfile" ]; then
  30. echo "ERROR: Netgroup config \"$netgroupfile\" not found!"
  31. exit 1
  32. fi
  33. echo "## NETGROUP $netgroupfile" >> $conffile
  34. cat "$netgroupfile" >> $conffile
  35. done