[Pkg-nagios-changes] [SCM] Debian packaging for lconf branch, master, updated. 55c830d5bfe0d8efe96193f2b447fb06da82ac93
Birger Schmidt
birger.schmidt at netways.de
Mon Jun 20 10:11:54 UTC 2011
The following commit has been merged in the master branch:
commit cb428fc6746cd4fe713735c430bf8f3f1e7d9422
Author: Birger Schmidt <birger.schmidt at netways.de>
Date: Tue Apr 5 17:24:05 2011 +0200
* check config in a tmp dir before overwriting the previous config
diff --git a/source/lconf_deploy.sh b/source/lconf_deploy.sh
index 5520603..f579daf 100644
--- a/source/lconf_deploy.sh
+++ b/source/lconf_deploy.sh
@@ -8,6 +8,14 @@
SATELLIT="satellit1 satellit2 satellit3"
LCONFDIR="/etc/icinga/lconf"
LCONFTMP="/etc/icinga/lconf.tmp"
+ICINGACONFIG=/etc/icinga/icinga.cfg
+ICINGATMPCONFIG=/etc/icinga/icinga.tmp.cfg
+
+RUNUSER=$(whoami)
+SUDOCOMMAND=""
+if [ "$RUNUSER" != "icinga" ] ; then
+ SUDOCOMMAND="sudo -u icinga"
+fi
#################################################
@@ -18,33 +26,41 @@ install -d -o icinga -g icinga $LCONFDIR
install -d -o icinga -g icinga $LCONFTMP
-echo export config from LDAP
-# export original full config from LDAP
-(cd /usr/local/LConf/ ; sudo -u icinga ./LConfExport.pl -o $LCONFTMP)
+# alter the icinga.cfg to check against the tmp dir
+install -o icinga -g icinga -m 640 $ICINGACONFIG $ICINGATMPCONFIG
+sed 's/^\(cfg_.*\)/#lconftest#\1/' $ICINGACONFIG > $ICINGATMPCONFIG
+echo cfg_dir=$LCONFTMP >> $ICINGATMPCONFIG
-# copy the preliminary config in place to pass the check
-rsync -a --del "$LCONFTMP"/* "$LCONFDIR"
-# generate config for satellites
-# this process may alter the original config
-# (disable checks of satellite components on the master...)
-if ( icinga -v /etc/icinga/icinga.cfg ) then
-
+echo export config from LDAP
+# export original full config from LDAP
+(cd /usr/local/LConf/ ; $SUDOCOMMAND ./LConfExport.pl -o $LCONFTMP)
+
+
+# first test the config within the tmp dir
+if ( icinga -v $ICINGATMPCONFIG ) then
+
+ # copy the preliminary config in place to pass the check
+ $SUDOCOMMAND rsync -a --del "$LCONFTMP"/* "$LCONFDIR"
+
+ # generate config for satellites
+ # this process may alter the original config
+ # (disable checks of satellite components on the master...)
for HOST in $SATELLIT ; do
echo deploy config on $HOST
(cd /usr/local/LConf/ ; \
- sudo -u icinga \
+ $SUDOCOMMAND \
./LConfSlaveExport.pl -H $HOST \
-s $LCONFTMP \
-t $LCONFDIR -v )
done
# copy the final config in place
- rsync -a --del "$LCONFTMP"/* "$LCONFDIR"
+ $SUDOCOMMAND rsync -a --del "$LCONFTMP"/* "$LCONFDIR"
# reload the final config on the master
echo reload config on Master $(hostname -f)
- /etc/init.d/icinga reload
+ $SUDOCOMMAND /etc/init.d/icinga reload
fi
--
Debian packaging for lconf
More information about the Pkg-nagios-changes
mailing list