Attached is an "idea" patch - in other words, I don't intend for this
to be considered for committing upstream; rather, I'm really just
wanting to flesh out whether what I have in mind is horribly bad. :-)
Here's the patch (it's also attached, in case some mail clients munge
the content. My thoughts are *in* the patch ; responses? :-)
diff -Nur pm-utils-1.2.2.1.orig/pm/functions.in pm-utils-1.2.2.1/pm/functions.in
--- pm-utils-1.2.2.1.orig/pm/functions.in 2008-10-05 20:49:09.000000000
-0500
+++ pm-utils-1.2.2.1/pm/functions.in 2008-10-07 14:33:26.081012472 -0500
@@ -124,15 +124,34 @@
done
}
-# Service management is sysv dependent.
-# TODO: modularize this to make it work with other init systems.
+# Some comments...
+#
+# I'm not sure the command_exists() function is broad enough to catch
+# all instances we want. While dbus isn't a good example for actual
+# suspend and such (as we don't want to stop/restart it at all), it *is*
+# a good example of something that command_exists() would miss, as (at
+# least in our case), the service is typically called "dbus," the daemon
+# is called "dbus-daemon," and the init script is named "rc.messagebus"
+# I don't know of a good/better way to handle it though, really.
+#
+# Also, we (Slackware) have some init scripts that don't have a "status"
+# directive in them, so maybe using that to check if something is running
+# won't always work. Is "pgrep $service" acceptable (although that will
+# still miss stuff due to the above paragraph's concerns)?
+
if ! command_exists service; then
service()
{
+ # Pure SysV init
if [ -x "/etc/init.d/$1" ]; then
svc="$1"
shift
"/etc/init.d/$svc" "$@"
+ # Slackware's BSD-style SysV init
+ elif [ -x "/etc/rc.d/rc.${1}" ]; then
+ svc="$1"
+ shift
+ "/etc/rc.d/rc.${1}" "$@"
else
log "${1}: unrecognized service"
return 1
diff -Nur pm-utils-1.2.2.1.orig/pm/functions.in pm-utils-1.2.2.1/pm/functions.in
--- pm-utils-1.2.2.1.orig/pm/functions.in 2008-10-05 20:49:09.000000000 -0500
+++ pm-utils-1.2.2.1/pm/functions.in 2008-10-07 14:33:26.081012472 -0500
@@ -124,15 +124,34 @@
done
}
-# Service management is sysv dependent.
-# TODO: modularize this to make it work with other init systems.
+# Some comments...
+#
+# I'm not sure the command_exists() function is broad enough to catch
+# all instances we want. While dbus isn't a good example for actual
+# suspend and such (as we don't want to stop/restart it at all), it *is*
+# a good example of something that command_exists() would miss, as (at
+# least in our case), the service is typically called "dbus," the daemon
+# is called "dbus-daemon," and the init script is named "rc.messagebus"
+# I don't know of a good/better way to handle it though, really.
+#
+# Also, we (Slackware) have some init scripts that don't have a "status"
+# directive in them, so maybe using that to check if something is running
+# won't always work. Is "pgrep $service" acceptable (although that will
+# still miss stuff due to the above paragraph's concerns)?
+
if ! command_exists service; then
service()
{
+ # Pure SysV init
if [ -x "/etc/init.d/$1" ]; then
svc="$1"
shift
"/etc/init.d/$svc" "$@"
+ # Slackware's BSD-style SysV init
+ elif [ -x "/etc/rc.d/rc.${1}" ]; then
+ svc="$1"
+ shift
+ "/etc/rc.d/rc.${1}" "$@"
else
log "${1}: unrecognized service"
return 1
_______________________________________________
Pm-utils mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/pm-utils