From 19c5ac37ef87aeb3d3c30aa35cd61b6f3a8414bf Mon Sep 17 00:00:00 2001 From: James Page Date: Tue, 21 May 2013 09:20:53 +0100 Subject: [PATCH] Use invoke-rc.d in maintainer scripts Upstart configurations and sysv init scripts should be started and stopped using invoke-rc.d in maintainer scripts. This ensures the correct behaviour across both Debian (sysv) and Ubuntu (upstart) and in restricted environments such as schroot where start/stop of services from maintainer scripts is normally disabled. Signed-off-by: James Page --- debian/ceph-mds.postinst | 10 +++++++++- debian/ceph-mds.prerm | 16 ++++++++++++++-- debian/ceph.postinst | 10 +++++++++- debian/ceph.prerm | 16 ++++++++++++++-- 4 files changed, 46 insertions(+), 6 deletions(-) diff --git a/debian/ceph-mds.postinst b/debian/ceph-mds.postinst index 7fcbf5c62304..316aa7b1040c 100644 --- a/debian/ceph-mds.postinst +++ b/debian/ceph-mds.postinst @@ -1,4 +1,5 @@ #!/bin/sh +# vim: set noet ts=8: # postinst script for ceph-mds # # see: dh_installdeb(1) @@ -20,7 +21,14 @@ set -e case "$1" in configure) - [ -x /sbin/start ] && start ceph-mds-all || : + invoke-rc.d ceph-mds-all start || { + RESULT=$? + # Ignore if ceph-mds-all upstart config does not + # exist or upstart is not in use + if [ $RESULT != 100 ]; then + exit $RESULT + fi + } ;; abort-upgrade|abort-remove|abort-deconfigure) : diff --git a/debian/ceph-mds.prerm b/debian/ceph-mds.prerm index c4af0994d948..e4cd62c985f9 100644 --- a/debian/ceph-mds.prerm +++ b/debian/ceph-mds.prerm @@ -1,5 +1,17 @@ #!/bin/sh +# vim: set noet ts=8: -[ -x /sbin/stop ] && stop ceph-mds-all || : +set -e -exit 0 \ No newline at end of file +invoke-rc.d ceph-mds-all stop || { + RESULT=$? + # Ignore if ceph-all upstart config does not + # exist or upstart is not in use + if [ $RESULT != 100 ]; then + exit $RESULT + fi +} + +#DEBHELPER# + +exit 0 diff --git a/debian/ceph.postinst b/debian/ceph.postinst index 090a91aa9bb3..cf760d02c09b 100644 --- a/debian/ceph.postinst +++ b/debian/ceph.postinst @@ -1,4 +1,5 @@ #!/bin/sh +# vim: set noet ts=8: # postinst script for ceph # # see: dh_installdeb(1) @@ -27,7 +28,14 @@ set -e case "$1" in configure) rm -f /etc/init/ceph.conf - [ -x /sbin/start ] && start ceph-all || : + invoke-rc.d ceph-all start || { + RESULT=$? + # Ignore if ceph-all upstart config does not + # exist or upstart is not in use + if [ $RESULT != 100 ]; then + exit $RESULT + fi + } ;; abort-upgrade|abort-remove|abort-deconfigure) : diff --git a/debian/ceph.prerm b/debian/ceph.prerm index 557a1dbdac05..17f8bcc30971 100644 --- a/debian/ceph.prerm +++ b/debian/ceph.prerm @@ -1,5 +1,17 @@ #!/bin/sh +# vim: set noet ts=8: -[ -x /sbin/stop ] && stop ceph-all || : +set -e -exit 0 \ No newline at end of file +invoke-rc.d ceph-all stop || { + RESULT=$? + # Ignore if ceph-all upstart config does not + # exist or upstart is not in use + if [ $RESULT != 100 ]; then + exit $RESULT + fi +} + +#DEBHELPER# + +exit 0 -- 2.47.3