[Pm-utils] Re: s2both
Peter Jones
pjones at redhat.com
Wed Mar 14 08:14:18 PDT 2007
On Wed, 2007-03-14 at 08:16 +0100, Stefan Seyfried wrote:
> - you cannot stopservice / restartservice services with a "-" in their name
> (patch attached)
(I will reply to the other points in a separate mail)
I really hate using "foo" in real (not "here's some arbitrary example")
code. So, applied as:
Index: ChangeLog
===================================================================
RCS file: /cvs/pm-utils/pm-utils/ChangeLog,v
retrieving revision 1.69
diff -u -p -r1.69 ChangeLog
--- ChangeLog 14 Mar 2007 15:07:11 -0000 1.69
+++ ChangeLog 14 Mar 2007 15:13:25 -0000
@@ -8,6 +8,10 @@
- handle ulsuspend signature (from Stefan)
- fix errant "rc = 1;" (from Stefan)
+ * pm/functions:
+ - make stopservice and restartservice work with dashes and
+ underscores (from Stefan)
+
2007-03-13 Peter Jones <pjones at redhat.com>
* configure.in:
cvs diff: Diffing man
cvs diff: Diffing pm
Index: pm/functions
===================================================================
RCS file: /cvs/pm-utils/pm-utils/pm/functions,v
retrieving revision 1.37
diff -u -p -r1.37 functions
--- pm/functions 13 Mar 2007 14:05:51 -0000 1.37
+++ pm/functions 14 Mar 2007 15:13:25 -0000
@@ -231,14 +231,16 @@ stopservice()
{
service "$1" status 2>/dev/null | grep -c -q running
if [ "$?" == "0" -a -x "/etc/init.d/$1" ]; then
- echo "export ${1}_SERVICE_ACTIVATE=yes" >> /var/run/pm-suspend
+ N=${1//[_.]/_}
+ echo "export ${N}_SERVICE_ACTIVATE=yes" >> /var/run/pm-suspend
"/etc/init.d/$1" stop 2>&1
fi
}
restartservice()
{
- if [ "x$(eval echo \$${1}_SERVICE_ACTIVATE)" == "xyes" \
+ N=${1//[-.]/_}
+ if [ "x$(eval echo \$${N}_SERVICE_ACTIVATE)" == "xyes" \
-a -x "/etc/init.d/$1" ]; then
"/etc/init.d/$1" start 2>&1
fi
--
Peter
More information about the Pm-utils
mailing list