On Sun, Jan 11, 2009 at 02:21:44PM +0100, Pacho Ramos wrote:
> I have seen that stopservice function is looking for "running", while
> gentoo init.d scripts report "started". Would be nice if it would look
> for both words:
> 
> stopservice()
> {
>         if service "$1" status 2>/dev/null | grep -c -q running; then
>                 touch "${STORAGEDIR}/service:$1"
>                 service "$1" stop
>         fi
> }
> 
> 
> I have tried to patch myself but I have been unable to do so :'(, please
> let me know the proper solution for learning a bit
> 
> Thanks a lot

I believe the patch below should work.

--
Dan

>From df99431ba8ee5a2a5b552f32950ae98eec9757d2 Mon Sep 17 00:00:00 2001
From: Dan Nicholson <dbn.li...@gmail.com>
Date: Sun, 18 Jan 2009 11:20:47 -0800
Subject: [PATCH] Match gentoo message "started" when checking for running 
services

Gentoo uses the convention of printing the message "started" when
showing the status of services. Augment stopservice() to check this in
addition to "running". This also drops the unnecessary -c argument from
the grep command.

Signed-off-by: Dan Nicholson <dbn.li...@gmail.com>
---
 pm/functions.in |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/pm/functions.in b/pm/functions.in
index 70740cb..019e8d2 100644
--- a/pm/functions.in
+++ b/pm/functions.in
@@ -141,7 +141,8 @@ fi
 
 stopservice()
 {
-       if service "$1" status 2>/dev/null | grep -c -q running; then
+       if service "$1" status 2>/dev/null | grep -q -e running -e started
+       then
                touch "${STORAGEDIR}/service:$1"
                service "$1" stop
        fi
-- 
1.5.6.6
_______________________________________________
Pm-utils mailing list
Pm-utils@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pm-utils

Reply via email to