From ea578470ebf74ca8c8c01101ebcb838fd5bbc136 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Wed, 12 Aug 2009 00:26:29 +0200 Subject: [PATCH] triggers/openrc-service: stop services in pre-remove. --HG-- extra : convert_revision : 33ec8f3658010a878fc7599fba64129e0d653326 --- triggers/openrc-service | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/triggers/openrc-service b/triggers/openrc-service index ff7eabf7f66..6f2e1ffcafa 100755 --- a/triggers/openrc-service +++ b/triggers/openrc-service @@ -7,6 +7,8 @@ # $2 = target [post-install/pre-remove] # $3 = pkgname # +initdir=etc/init.d + case "$1" in targets) echo "post-install pre-remove" @@ -16,10 +18,11 @@ run) [ ! -x sbin/rc-service ] && exit 0 [ -z "$openrc_services" ] && exit 1 - if [ "$2" = "pre-remove" ]; then + target=$2 + if [ "$target" = "pre-remove" ]; then text="Unr" rcupdate_args="del" - elif [ "$2" = "post-install" ]; then + elif [ "$target" = "post-install" ]; then text="R" rcupdate_args="add" else @@ -31,13 +34,20 @@ run) set -- ${openrc_services} while [ $# -gt 0 ]; do if sbin/rc-service -e ${1}; then + # Stop the service if it's running. + if [ "$target" = "pre-remove" -a -f $initdir/$1 ]; then + $initdir/$1 -q status + if [ $? -eq 0 ]; then + $initdir/$1 stop + fi + fi + # (Un)register the service. echo "${text}egistering ${1} OpenRC service..." sbin/rc-update ${rcupdate_args} ${1} ${2} - [ $? -ne 0 ] && exit $? - sbin/rc-update -u fi shift; shift; done + sbin/rc-update -u ;; *)