#!/bin/bash
#
#  Configure rsyslog and icinga
#

set -e

fcopy -r /etc/rsyslog.d/
fcopy /etc/icinga/objects/hostgroups_icinga.cfg
fcopy /etc/icinga/objects/services_icinga.cfg
fcopy /etc/icinga/objects/commands.cfg

if [ "$FAI_ACTION" == "install" ] || [ "$CONVERT" == "true" ] ; then
    ## Machines are added here, so do not overwrite them on softupdate:
    fcopy /etc/icinga/objects/hosts.cfg
    sed -i "s#\$GATEWAY#$GATEWAY#" $target/etc/icinga/objects/hosts.cfg
    mv $target/etc/icinga/objects/localhost_icinga.cfg $target/etc/icinga/objects/localhost_icinga.cfg_orig || true
fi
