a little more work for sarge transitioning
This commit is contained in:
parent
200334e244
commit
f0bf0b77eb
43
debian/functions
vendored
43
debian/functions
vendored
|
@ -1,26 +1,31 @@
|
|||
# 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(){
|
||||
local newinst
|
||||
if [ -z "$1" ]; then
|
||||
newinst="yes"
|
||||
tmpfile=`mktemp -t nagios-plugins.XXXXXX`
|
||||
if [ ! -f "$tmpfile" ]; then
|
||||
echo "error creating tempfile >&2"
|
||||
exit 1
|
||||
fi
|
||||
(
|
||||
cd $templdir
|
||||
for f in *cfg; do
|
||||
dest=${npconfdir}/$f
|
||||
if is_pristine_sarge_file $f; then
|
||||
cp $f $dest
|
||||
fi
|
||||
ucf $f $dest
|
||||
done
|
||||
);
|
||||
fi
|
||||
(
|
||||
cd $templdir
|
||||
for f in *cfg; do
|
||||
dest=/etc/nagios-plugins/config/$f
|
||||
if [ "$newinst" = "yes" ] && [ -f $dest ]; then
|
||||
cat $dest > $tmpfile
|
||||
ucf $tmpfile $dest
|
||||
fi
|
||||
ucf $f /etc/nagios-plugins/config/$f
|
||||
done
|
||||
);
|
||||
if [ "$newinst" = "yes" ]; then rm -f $tmpfile; fi
|
||||
}
|
||||
|
|
21
debian/rules
vendored
21
debian/rules
vendored
|
@ -17,10 +17,11 @@ DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
|
|||
|
||||
CFLAGS = -Wall -g
|
||||
|
||||
DEBIANDIR=$(CURDIR)/debian
|
||||
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_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
|
||||
|
||||
std_plugins:=check_breeze check_ifoperstatus check_hpjd check_ifstatus \
|
||||
|
@ -118,7 +119,7 @@ really-clean:
|
|||
-rm -f platform.h auto-include.h
|
||||
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 \;
|
||||
-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
|
||||
|
||||
install: build
|
||||
|
@ -137,21 +138,21 @@ install: build
|
|||
# now do the same for their configs, copying them into seperate
|
||||
# "template" directories outside of /usr/share/doc for ucf to use.
|
||||
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
|
||||
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
|
||||
# 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.
|
||||
sed -e 's/@BASIC_PLUGINS@/${basic_plugin_cfgs}/' \
|
||||
< debian/nagios-plugins-basic.postrm.in \
|
||||
> debian/nagios-plugins-basic.postrm
|
||||
< $(DEBIANDIR)/nagios-plugins-basic.postrm.in \
|
||||
> $(DEBIANDIR)/nagios-plugins-basic.postrm
|
||||
sed -e 's/@STD_PLUGINS@/${std_plugin_cfgs}/' \
|
||||
< debian/nagios-plugins-standard.postrm.in \
|
||||
> debian/nagios-plugins-standard.postrm
|
||||
< $(DEBIANDIR)/nagios-plugins-standard.postrm.in \
|
||||
> $(DEBIANDIR)/nagios-plugins-standard.postrm
|
||||
# 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
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue