NConf Deployer

nconf nice nagios configurator works awesome but i had issue with the addon script.
So i have modified to work in my environment it's not special but it working since i deployed without any issue.
I also added to keep Backup of previous working nagios configuration.

Please make sure all directory writable to script owner.
i run this script in cron every Minute.
It only execute if there is change so should be good.

| deploy_local.sh
#!/bin/bash
## Original Script taken from source of Nconf.
## Updated by k2patel@hotmail.com
 
 
 
OUTPUT_DIR="nagconf.com/output/"                 ## This is where it stores the output
NAGIOS_DIR="/etc/nagios/"                        ## Location for Nagios
TEMP_DIR=${NAGIOS_DIR}"import/"                  ## this is where it move files from output
CONF_ARCHIVE="NagiosConfig.tgz"                  ## Archive Name
BK_UP_DIR=${NAGIOS_DIR}"0ld_backup/"             ## Backup which keep previous working configuration just incase
 
if [ ! -e ${TEMP_DIR} ] ; then
mkdir -p ${TEMP_DIR}
fi
 
if [ ! -e ${BK_UP_DIR} ] ; then
mkdir -p ${BK_UP_DIR}
fi
 
if [ ${OUTPUT_DIR}${CONF_ARCHIVE} -nt ${TEMP_DIR}${CONF_ARCHIVE} ] ; then
cp -p ${OUTPUT_DIR}${CONF_ARCHIVE} ${TEMP_DIR}${CONF_ARCHIVE}
rm -rf ${BK_UP_DIR}/Default_collector ${BK_UP_DIR}/global ${BK_UP_DIR}/static_cfg
mv -f ${NAGIOS_DIR}/Default_collector ${BK_UP_DIR}/
mv -f ${NAGIOS_DIR}/global ${BK_UP_DIR}/
mv -f ${NAGIOS_DIR}/static_cfg ${BK_UP_DIR}/ 
tar -xf ${TEMP_DIR}${CONF_ARCHIVE} -C ${NAGIOS_DIR}
/etc/init.d/nagios reload
rm -f ${OUTPUT_DIR}${CONF_ARCHIVE}
fi
 
exit