[Pm-utils] RFC - PATCH to functions.in to support Slackware init
Victor Lowther
victor.lowther at gmail.com
Wed Oct 29 13:49:39 PDT 2008
On Tue, 2008-10-07 at 14:40 -0500, Robby Workman wrote:
> 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
I rewrote your patch a little:
diff --git a/pm/functions.in b/pm/functions.in
index 110282e..b1b3157 100644
--- a/pm/functions.in
+++ b/pm/functions.in
@@ -129,14 +129,12 @@ modreload()
if ! command_exists service; then
service()
{
- if [ -x "/etc/init.d/$1" ]; then
- svc="$1"
- shift
- "/etc/init.d/$svc" "$@"
- else
- log "${1}: unrecognized service"
- return 1
- fi
+ for svc in "/etc/init.d/$1" "/etc/rc.d/rc.$1" #lsb, then slack
+ [ -x "$svc" ] && { shift; "$svc" "$@"; return $?; }
+ done
+ # this only happens if we did not find the service
+ log "${1}: unrecognized service"
+ return 1
}
fi
A better way to do it might be to add a distro.d directory
to /usr/lib/pm-utils that can have the following content:
pm-functions: Sourced at the end of /usr/lib/pm-utils/pm-functions if
present.
functions: Sourced at the end in /usr/lib/pm-utils/functions if
present.
These files will allow distros to override and add new functionality to
pm-utils without having to patch the pm-utils package to do so.
power.d, sleep.d, config.d, and modules.d:
These directories would have the same purpose as the ones
in /usr/lib/pm-utils and /etc/pm. Their contents would override the
ones in /usr/lib/pm-utils, and would be overridden by the ones
in /etc/pm.
Thoughts? Stefan, flames?
> _______________________________________________
> Pm-utils mailing list
> Pm-utils at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/pm-utils
--
Victor Lowther
RHCE# 805008539634727
LPIC-2# LPI000140019
More information about the Pm-utils
mailing list