Add wrappers that check the MODE in /etc/nut/nut.conf to avoid starting the daemons if nut is not configured (Closes: #747863).

This commit is contained in:
Laurent Bigonville 2015-01-25 12:54:03 +01:00
parent fedf671e4d
commit 241119d464
6 changed files with 49 additions and 1 deletions

4
debian/changelog vendored
View File

@ -4,8 +4,10 @@ nut (2.7.2-2) UNRELEASED; urgency=medium
* debian/rules: Revert the changes made in the previous NMU, I don't think
that dropping the .service file that late in the release cycle is a good
idea and anyway this was causing left-over files on upgrade.
* Add wrappers that check the MODE in /etc/nut/nut.conf to avoid starting
the daemons if nut is not configured (Closes: #747863).
-- Laurent Bigonville <bigon@debian.org> Sun, 25 Jan 2015 12:47:47 +0100
-- Laurent Bigonville <bigon@debian.org> Sun, 25 Jan 2015 12:53:03 +0100
nut (2.7.2-1.1) unstable; urgency=medium

19
debian/local/upsd vendored Executable file
View File

@ -0,0 +1,19 @@
#!/bin/sh
# Include NUT nut.conf
[ -r /etc/nut/nut.conf ] && . /etc/nut/nut.conf
case "$MODE" in
standalone|netserver)
exec /lib/nut/upsd "$@"
;;
none|netclient)
echo "upsd disabled, please adjust the configuration to your needs"
echo "Then set MODE to a suitable value in /etc/nut/nut.conf to enable it"
# exit success to avoid breaking the install process!
exit 0
;;
*)
exit 1
;;
esac

19
debian/local/upsmon vendored Executable file
View File

@ -0,0 +1,19 @@
#!/bin/sh
# Include NUT nut.conf
[ -r /etc/nut/nut.conf ] && . /etc/nut/nut.conf
case "$MODE" in
standalone|netserver|netclient)
exec /lib/nut/upsmon "$@"
;;
none)
echo "upsmon disabled, please adjust the configuration to your needs"
echo "Then set MODE to a suitable value in /etc/nut/nut.conf to enable it"
# exit success to avoid breaking the install process!
exit 0
;;
*)
exit 1
;;
esac

View File

@ -3,6 +3,7 @@ debian/tmp/bin/upsc
debian/tmp/bin/upsrw
debian/tmp/bin/upscmd
debian/tmp/sbin/upsmon
debian/tmp/lib/nut/upsmon
debian/tmp/sbin/upssched
debian/tmp/bin/upssched-cmd
debian/tmp/etc/nut/nut.conf

View File

@ -1,4 +1,5 @@
debian/tmp/sbin/upsd
debian/tmp/lib/nut/upsd
debian/tmp/sbin/upsdrvctl
debian/tmp/usr/share/nut/cmdvartab
debian/tmp/usr/share/nut/driver.list

6
debian/rules vendored
View File

@ -77,6 +77,12 @@ common-install-arch::
ln -s /lib/$(DEB_HOST_MULTIARCH)/libupsclient.so.4 \
$(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/libupsclient.so
# Move daemons and install wrappers
mv $(CURDIR)/debian/tmp/sbin/upsmon $(CURDIR)/debian/tmp/lib/nut/upsmon
mv $(CURDIR)/debian/tmp/sbin/upsd $(CURDIR)/debian/tmp/lib/nut/upsd
install -m 0755 debian/local/upsmon $(CURDIR)/debian/tmp/sbin/upsmon
install -m 0755 debian/local/upsd $(CURDIR)/debian/tmp/sbin/upsd
# Install systemd files only on systems where it's supported
ifeq (linux,$(DEB_HOST_ARCH_OS))
install -m 644 -D $(CURDIR)/debian/tmp/lib/$(DEB_HOST_MULTIARCH)/systemd/system/nut-monitor.service \