[Pm-utils] [PATCH] use service unconditionally
Peter Jones
pjones at redhat.com
Wed Mar 14 09:00:45 PDT 2007
On Mon, 2007-03-12 at 08:25 +0100, Stefan Seyfried wrote:
> > It appears that is inevitable that we introduce distro specific
> > functions here, because you do not appear to have /etc/init.d and we
> > don't have service.
>
> how about (untested!):
Yeah, I think that's the right idea, but I think the patch below is
slightly better (also untested!).
BTW, isn't the $": blah blah blah" the right thing to do rather than
setting LC_ALL?
Obviously not applied yet.
Index: functions
===================================================================
RCS file: /cvs/pm-utils/pm-utils/pm/functions,v
retrieving revision 1.39
diff -u -p -r1.39 functions
--- functions 14 Mar 2007 15:37:04 -0000 1.39
+++ functions 14 Mar 2007 15:51:45 -0000
@@ -174,6 +174,19 @@ pm_main()
return 0
}
+_service=$(type -p service)
+if [ -z "$_service" ]; then
+ service() {
+ if [ -x "/etc/init.d/$1" ]; then
+ "/etc/init.d/$@"
+ else
+ echo "$1" $": unrecognized service" 1>&2
+ return 1
+ fi
+ }
+fi
+unset _service
+
_rmmod() {
if modprobe -r $1; then
echo "export RESUME_MODULES=\"$1 \$RESUME_MODULES\"" \
@@ -232,10 +245,10 @@ modreload()
stopservice()
{
service "$1" status 2>/dev/null | grep -c -q running
- if [ "$?" == "0" -a -x "/etc/init.d/$1" ]; then
+ if [ "$?" == "0" ]; then
N=${1//[_.]/_}
echo "export ${N}_SERVICE_ACTIVATE=yes" >> /var/run/pm-suspend
- "/etc/init.d/$1" stop 2>&1
+ service "$1" stop
fi
}
@@ -244,7 +257,7 @@ restartservice()
N=${1//[-.]/_}
if [ "x$(eval echo \$${N}_SERVICE_ACTIVATE)" == "xyes" \
-a -x "/etc/init.d/$1" ]; then
- "/etc/init.d/$1" start 2>&1
+ service "$1" start
fi
}
--
Peter
More information about the Pm-utils
mailing list