a little more work for sarge transitioning

This commit is contained in:
Sean Finney 2006-12-06 17:35:02 +00:00
parent 200334e244
commit f0bf0b77eb
2 changed files with 35 additions and 29 deletions

33
debian/functions vendored
View file

@ -1,26 +1,31 @@
# functions for use by nagios plugins maintainer scripts # functions for use by nagios plugins maintainer scripts
# called as "register_cfgs $2" from postinst npconfdir=/etc/nagios-plugins/config
npdpkgdir=/usr/share/nagios-plugins/dpkg
# determine whether the file is the default file shipped in sarge
# (called as is_pristine_sarge_file foo.cfg)
is_pristine_sarge_file(){
sargemd5=`grep "${npconfdir}/$1" ${npdpkgdir}/sarge.md5sums | cut -d' ' -f1`
curmd5=`md5sum "${npconfdir}/$1" | cut -d' ' -f1`
if [ "$curmd5" = "$sargemd5" ]; then return 0; else return 1; fi
}
# we now register all n-p config files via ucf. this means
# we have to do a little bit of hand-holding for sarge migrations...
# (called as "register_cfgs $2" from postinst)
register_cfgs(){ register_cfgs(){
local newinst local newinst
if [ -z "$1" ]; then if [ -z "$1" ]; then
newinst="yes"
tmpfile=`mktemp -t nagios-plugins.XXXXXX`
if [ ! -f "$tmpfile" ]; then
echo "error creating tempfile >&2"
exit 1
fi
fi
( (
cd $templdir cd $templdir
for f in *cfg; do for f in *cfg; do
dest=/etc/nagios-plugins/config/$f dest=${npconfdir}/$f
if [ "$newinst" = "yes" ] && [ -f $dest ]; then if is_pristine_sarge_file $f; then
cat $dest > $tmpfile cp $f $dest
ucf $tmpfile $dest
fi fi
ucf $f /etc/nagios-plugins/config/$f ucf $f $dest
done done
); );
if [ "$newinst" = "yes" ]; then rm -f $tmpfile; fi fi
} }

21
debian/rules vendored
View file

@ -17,10 +17,11 @@ DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
CFLAGS = -Wall -g CFLAGS = -Wall -g
DEBIANDIR=$(CURDIR)/debian
NP_LIBEXEC:=/usr/lib/nagios/plugins NP_LIBEXEC:=/usr/lib/nagios/plugins
NP_BASIC_DIR:=$(CURDIR)/debian/nagios-plugins-basic NP_BASIC_DIR:=$(DEBIANDIR)/nagios-plugins-basic
NP_BASIC_TEMPLATES:=$(NP_BASIC_DIR)/usr/share/nagios-plugins/templates-basic NP_BASIC_TEMPLATES:=$(NP_BASIC_DIR)/usr/share/nagios-plugins/templates-basic
NP_STD_DIR:=$(CURDIR)/debian/nagios-plugins-standard NP_STD_DIR:=$(DEBIANDIR)/nagios-plugins-standard
NP_STD_TEMPLATES:=$(NP_STD_DIR)/usr/share/nagios-plugins/templates-standard NP_STD_TEMPLATES:=$(NP_STD_DIR)/usr/share/nagios-plugins/templates-standard
std_plugins:=check_breeze check_ifoperstatus check_hpjd check_ifstatus \ std_plugins:=check_breeze check_ifoperstatus check_hpjd check_ifstatus \
@ -118,7 +119,7 @@ really-clean:
-rm -f platform.h auto-include.h -rm -f platform.h auto-include.h
find -type d -name build -print0 | xargs -0 -r rm -rf \; find -type d -name build -print0 | xargs -0 -r rm -rf \;
find \( -name config.sub -o -name config.guess \) -print0 | xargs -0 -r rm -f \; find \( -name config.sub -o -name config.guess \) -print0 | xargs -0 -r rm -f \;
-rm -f debian/nagios-plugins-basic.postrm debian/nagios-plugins-standard.postrm -rm -f $(DEBIANDIR)/nagios-plugins-basic.postrm $(DEBIANDIR)/nagios-plugins-standard.postrm
dh_clean dh_clean
install: build install: build
@ -137,21 +138,21 @@ install: build
# now do the same for their configs, copying them into seperate # now do the same for their configs, copying them into seperate
# "template" directories outside of /usr/share/doc for ucf to use. # "template" directories outside of /usr/share/doc for ucf to use.
for c in ${basic_plugin_cfgs}; do \ for c in ${basic_plugin_cfgs}; do \
cp $(CURDIR)/debian/pluginconfig/$${c}.cfg ${NP_BASIC_TEMPLATES}; \ cp $(DEBIANDIR)/pluginconfig/$${c}.cfg ${NP_BASIC_TEMPLATES}; \
done done
for c in ${std_plugin_cfgs}; do \ for c in ${std_plugin_cfgs}; do \
cp $(CURDIR)/debian/pluginconfig/$${c}.cfg ${NP_STD_TEMPLATES}; \ cp $(DEBIANDIR)/pluginconfig/$${c}.cfg ${NP_STD_TEMPLATES}; \
done done
# dynamically create the postrm scripts using a template, so that we # dynamically create the postrm scripts using a template, so that we
# don't have to define the same list of plugin configs over and over. # don't have to define the same list of plugin configs over and over.
sed -e 's/@BASIC_PLUGINS@/${basic_plugin_cfgs}/' \ sed -e 's/@BASIC_PLUGINS@/${basic_plugin_cfgs}/' \
< debian/nagios-plugins-basic.postrm.in \ < $(DEBIANDIR)/nagios-plugins-basic.postrm.in \
> debian/nagios-plugins-basic.postrm > $(DEBIANDIR)/nagios-plugins-basic.postrm
sed -e 's/@STD_PLUGINS@/${std_plugin_cfgs}/' \ sed -e 's/@STD_PLUGINS@/${std_plugin_cfgs}/' \
< debian/nagios-plugins-standard.postrm.in \ < $(DEBIANDIR)/nagios-plugins-standard.postrm.in \
> debian/nagios-plugins-standard.postrm > $(DEBIANDIR)/nagios-plugins-standard.postrm
# copy our dpkg-sourced functions into place # copy our dpkg-sourced functions into place
install -m 644 -D $(CURDIR)/debian/functions \ install -m 644 -D $(DEBIANDIR)/functions $(DEBIANDIR)/sarge.md5sums \
${NP_BASIC_DIR}/usr/share/nagios-plugins/dpkg/functions ${NP_BASIC_DIR}/usr/share/nagios-plugins/dpkg/functions