[Pm-utils] [PATCH] Add Pardus support into helper functios

Stefan Seyfried seife at suse.de
Sat Jan 13 02:28:26 PST 2007


On Sat, Jan 13, 2007 at 03:04:31AM +0200, S.Çağlar Onur wrote:
> Hi;
> 
> Attached patch adds Pardus [1] support into helper functions stopservice and 
> restartservice.

comments in the patch...

> Index: pm/functions
> ===================================================================
> RCS file: /cvs/pm-utils/pm-utils/pm/functions,v
> retrieving revision 1.32
> diff -u -r1.32 functions
> --- pm/functions	30 Nov 2006 20:07:04 -0000	1.32
> +++ pm/functions	13 Jan 2007 01:02:05 -0000
> @@ -1,6 +1,8 @@
>  #!/bin/bash
>  
>  export PATH=/sbin:/usr/sbin:/bin:/usr/bin
> +# To get rid of localized outputs
> +export LC_ALL=C

Probably a good idea

>  # Default values go here.  It is important to _not_ initialize some
>  # variables here.  They are:
> @@ -212,18 +214,30 @@
>  
>  stopservice()
>  {
> -	service "$1" status 2>/dev/null | grep -c -q running
> -	if [ "$?" == "0" -a -x "/etc/init.d/$1" ]; then
> +	if [ -f /etc/pardus-release ]; then
> +		service "$1" info | grep -c -q running
> +	else
> +		service "$1" status 2>/dev/null | grep -c -q running
> +	fi

i always believed "service" was a LSB thing, but could not find it in the 3.1
specification.
On SUSE systems, "service foo {start|stop|restart|status}" just calls the
init script, which has to support "status" anyway. I don't know about the
Pardus init scripts, but wouldn't it be, in the long term, better for you
if you just made your "service" behave like the "rest of the world"? :-)
Means: a patch to "service" to take "status" as an alias for "info" would
probably be as easy as patching this into pm-utils :-)

I might be wrong here, of course, and i am not LSB-enlightened at all.

> +	if [ "$?" == "0" ]; then
>  		echo "export ${1}_SERVICE_ACTIVATE=yes" >> /var/run/pm-suspend
> -		"/etc/init.d/$1" stop 2>&1
> +		if [ -x "/etc/init.d/$1" ]; then
> +			"/etc/init.d/$1" stop 2>&1
> +		elif [ -f /etc/pardus-release ]; then
> +			service "$1" stop 2>&1
> +		fi

IMO we could unconditionally do 'service "$1" stop' here, at least on my
system it would work.

>  	fi
>  }
>  
>  restartservice()
>  {
> -	if [ "x$(eval echo \$${1}_SERVICE_ACTIVATE)" == "xyes" \
> -			-a -x "/etc/init.d/$1" ]; then
> -		"/etc/init.d/$1" start 2>&1
> +	if [ "x$(eval echo \$${1}_SERVICE_ACTIVATE)" == "xyes" ]; then
> +		if [ -x "/etc/init.d/$1" ]; then
> +			"/etc/init.d/$1" start 2>&1
> +		elif [ -f /etc/pardus-release ]; then
> +			service "$1" start 2>&1
> +		fi

same here, we should just do 'service "$1" start' here unconditionally.
IMVHO we should only start to do this distribution specific stuff if it
is absolutely unavoidable.

Best regards,

    Stefan
-- 
Stefan Seyfried
QA / R&D Team Mobile Devices        |              "Any ideas, John?"
SUSE LINUX Products GmbH, Nürnberg  | "Well, surrounding them's out." 


More information about the Pm-utils mailing list