From: Florian Kirstein <xenlist@ray.net>
To: Xen development list <xen-devel@lists.xensource.com>
Cc: Kurt Garloff <garloff@suse.de>
Subject: Re: xendomains init script
Date: Thu, 30 Mar 2006 05:57:53 +0200 [thread overview]
Message-ID: <20060330055753.B26981@web.ray.net> (raw)
In-Reply-To: <20051019094439.GQ8705@tpkurt.tagung.uni-hamburg.de>; from garloff@suse.de on Wed, Oct 19, 2005 at 11:44:39AM +0200
[-- Attachment #1: Type: text/plain, Size: 2028 bytes --]
Hi,
first: thanks for the nice script :)
I had a (more cosmetic) problem with it:
> The init script is somewhat SUSE-ish, but it should work on LSB
> compliant and on RH based distros as well.
Almost for the LSB-Part: LSB defines that the ini script functions
like "log_success_msg" can be defined as shell aliases:
http://www.linuxbase.org/spec/refspecs/LSB_3.0.0/LSB-Core-generic/LSB-Core-generic/iniscrptfunc.html
The problem with that: shell aliases are usually not enabled in scripts
(so I'll have to blame LSB for allowing this in init script functions)
and the real problem, they are never used (at least for bash) in
if/then/else blocks or functions, which is exactly what your script
does.
So, IF a distribution decides to implement log_success_msg LSB conforming
as alias, as current RedHat distributions (like RHEL4 and including
FC5) do, this will fail and give "log_success_msg: command not found".
I think this is a bad idea (see above), but can't blame RedHat for
following LSB by the word. And as you check for LSB first and then
for redhat, newer redhat distributions will take the LSB case.
I don't think there's a nice way to make this fully LSB compatible
as these funtions are usually called within functions, but I'd
highly suggest to use a "specific before generic" approach for the
"distribution specific emulations". Means: test for the redhat
specific part first and then use LSB. For the LSB part I'd add
an if-test to check if log_success_msg is an alias and use the
generic emulation in case it is (assuming log_error_msg would be an
alias too when log_success_msg is).
I attached a patch doing exactly this, resulting in a clean run on the
redhat based distributions and fixing it for possible others using an
alias in their LSB conformity scripts, leaving it unchanged for the
rest. Hopefully :)
@Kurt: as this is your init-script, would you like to review the patch
and in case you think it's OK submit it to the official source tree?
Or whoever is responsible for this :)
(:ul8er, r@y
[-- Attachment #2: init.d-xendomains.patch --]
[-- Type: text/plain, Size: 1327 bytes --]
diff -U 3 -r xen-unstable-orig/tools/examples/init.d/xendomains xen-unstable/tools/examples/init.d/xendomains
--- xen-unstable-orig/tools/examples/init.d/xendomains 2006-03-28 06:11:40.000000000 +0200
+++ xen-unstable/tools/examples/init.d/xendomains 2006-03-30 05:15:13.000000000 +0200
@@ -58,18 +58,7 @@
_SMSG=(done failed failed missed failed skipped unused failed failed)
_RC_UNUSED=6
fi
- if test -e /lib/lsb/init-functions; then
- # LSB
- . /lib/lsb/init-functions
- echo_rc()
- {
- if test ${_RC_RV} = 0; then
- log_success_msg " [${_SMSG[${_RC_RV}]}] "
- else
- log_failure_msg " [${_SMSG[${_RC_RV}]}] "
- fi
- }
- elif test -e /etc/init.d/functions; then
+ if test -e /etc/init.d/functions; then
# REDHAT
. /etc/init.d/functions
echo_rc()
@@ -81,6 +70,24 @@
failure " [${_SMSG[${_RC_RV}]}] "
fi
}
+ elif test -e /lib/lsb/init-functions; then
+ # LSB
+ . /lib/lsb/init-functions
+ if alias log_success_msg >/dev/null 2>/dev/null; then
+ echo_rc()
+ {
+ echo " [${_SMSG[${_RC_RV}]}] "
+ }
+ else
+ echo_rc()
+ {
+ if test ${_RC_RV} = 0; then
+ log_success_msg " [${_SMSG[${_RC_RV}]}] "
+ else
+ log_failure_msg " [${_SMSG[${_RC_RV}]}] "
+ fi
+ }
+ fi
else
# emulate it
echo_rc()
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
next prev parent reply other threads:[~2006-03-30 3:57 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-19 9:44 xendomains init script Kurt Garloff
2005-10-26 17:11 ` Ewan Mellor
2005-10-26 17:27 ` Kurt Garloff
2006-03-30 3:57 ` Florian Kirstein [this message]
2006-03-30 4:09 ` Florian Kirstein
2006-03-30 21:21 ` Daniel Veillard
2006-03-31 4:27 ` Florian Kirstein
2007-02-28 5:20 ` Florian Kirstein
2007-02-28 14:51 ` Keir Fraser
2007-02-28 17:26 ` Florian Kirstein
-- strict thread matches above, loose matches on Subject: below --
2005-10-26 19:05 Ian Pratt
2005-10-26 23:35 ` Chris Bainbridge
2005-10-27 14:15 Ian Pratt
2005-10-27 15:16 ` Chris Bainbridge
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060330055753.B26981@web.ray.net \
--to=xenlist@ray.net \
--cc=garloff@suse.de \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.