diff --git a/debian/changelog b/debian/changelog index e31806e..d2a67f2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +nut (2.7.2-4) UNRELEASED; urgency=medium + + * Really fix package initial installation when PID1 is systemd (Closes: + #747863) + + -- Laurent Bigonville Fri, 20 Mar 2015 00:44:01 +0100 + nut (2.7.2-3) unstable; urgency=medium * debian/NEWS: Fix NEWS file syntax diff --git a/debian/nut-client.postinst b/debian/nut-client.postinst index 4b04850..5d68dae 100644 --- a/debian/nut-client.postinst +++ b/debian/nut-client.postinst @@ -1,5 +1,16 @@ #!/bin/sh -e +handle_start_failure () { +# The nut client part (upsmon) must run in all cases except when MODE in +# /etc/nut/nut.conf is set to "none" or not set at all. + [ -r /etc/nut/nut.conf ] && . /etc/nut/nut.conf + if [ -d /run/systemd/system ] && [ "$MODE" = "none" -o -z "$MODE" ]; then + return 0 + else + return 1 + fi +} + case "$1" in configure) diff --git a/debian/nut-client.prerm b/debian/nut-client.prerm new file mode 100644 index 0000000..e45a69b --- /dev/null +++ b/debian/nut-client.prerm @@ -0,0 +1,13 @@ +#!/bin/sh +set -e + +handle_start_failure () { +# The MODE defined in /etc/nut/nut.conf shouldn't affect the exit code when the +# daemon is stopped. If it fails to stop, the maintainer script should fail +# too. + return 1 +} + +#DEBHELPER# + +exit 0 diff --git a/debian/nut-server.postinst b/debian/nut-server.postinst index 3322126..f0e05c2 100644 --- a/debian/nut-server.postinst +++ b/debian/nut-server.postinst @@ -1,5 +1,18 @@ #!/bin/sh -e +handle_start_failure () { +# The nut server part (upsd) must run in all cases except when MODE in +# /etc/nut/nut.conf is set to "none", not set at all or if the machine is a +# client. + [ -r /etc/nut/nut.conf ] && . /etc/nut/nut.conf + if [ -d /run/systemd/system ] \ + && [ "$MODE" = "none" -o "$MODE" = "netclient" -o -z "$MODE" ]; then + return 0 + else + return 1 + fi +} + case "$1" in configure) diff --git a/debian/nut-server.prerm b/debian/nut-server.prerm index 6292ef8..b68c6d8 100644 --- a/debian/nut-server.prerm +++ b/debian/nut-server.prerm @@ -4,6 +4,13 @@ # because we don't want the daemon to be # stopped during an upgrade +handle_start_failure () { +# The MODE defined in /etc/nut/nut.conf shouldn't affect the exit code when the +# daemon is stopped. If it fails to stop, the maintainer script should fail +# too. + return 1 +} + case "$1" in remove) diff --git a/debian/rules b/debian/rules index c667da4..26bab23 100755 --- a/debian/rules +++ b/debian/rules @@ -119,8 +119,8 @@ common-install-indep:: binary-install/nut-monitor:: dh_python2 -pnut-monitor -DEB_DH_INSTALLINIT_ARGS_nut-server := --init-script=nut-server --restart-after-upgrade -DEB_DH_INSTALLINIT_ARGS_nut-client := --init-script=nut-client --restart-after-upgrade +DEB_DH_INSTALLINIT_ARGS_nut-server := --init-script=nut-server --restart-after-upgrade --error-handler=handle_start_failure +DEB_DH_INSTALLINIT_ARGS_nut-client := --init-script=nut-client --restart-after-upgrade --error-handler=handle_start_failure DEB_DH_SYSTEMD_START_ARGS_nut-server := --restart-after-upgrade DEB_DH_SYSTEMD_START_ARGS_nut-client := --restart-after-upgrade DEB_DH_COMPRESS_ARGS_nut-doc := -X.pdf