On Thu, 28 May 2009, Dejan Muhamedagic wrote:
> On Thu, May 28, 2009 at 08:33:15PM +0200, Raoul Bhatia [IPAX] wrote:
>> [...]
>> please find my current version attached.
Just a couple more comments, relating to portability.
>> ____________________________________________________________________
>
>> #!/bin/sh
>> [...]
The script later contains some features that are specific to "bash".
So that header should instead read: "#!/bin/bash".
>> ##########################################################################
>>
>> # Initialization:
>>
>> . ${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs
>>
>> : ${OCF_RESKEY_binary="/usr/sbin/postfix"}
Some UN*X systems might have 'postfix' at other locations. So the
"/usr/sbin/postfix" should be a shell variable.
In general the technique is to use 'configure' to determine the pathname
and set it in a variable, then write lines such as the above using that
variable. Basically, whenever (as a linux-ha developers) we find
ourselves typing a pathname, we should use the configure method to feed it
through a shell variable.
(That fixed pathname and a couple of others are also used later in the
script; all such instances ought to use configure-derived variables.)
>> running() {
>> queue=$(postconf $OPTION_CONFIG_DIR -h queue_directory 2>/dev/null ||
>> echo /var/spool/postfix)
>> if [ -f ${queue}/pid/master.pid ]; then
>> pid=$(sed 's/ //g' ${queue}/pid/master.pid)
>> # what directory does the executable live in. stupid prelink
>> systems.
>> dir=$(ls -l /proc/$pid/exe 2>/dev/null | sed 's/.* -> //;
>> s/\/[^\/]*$//')
>> if [ "X$dir" = "X/usr/lib/postfix" ]; then
>> [...]
The above contains two non-Bourne features of 'bash' (e.g. "queue=$(...)")
hence my first comment about changing to "#!/bin/bash".
The "/proc/$pid/exe" is Linux-specific. (But if a script is known to be
Linux-sepcific (i.e. script itself will not be valid on (say) *BSD,
Darwin, Solaris, etc.) then such things are probably OK.)
The "/usr/lib/postfix" should come through configure-derived variables.
But don't let that discourage you! All the best.
--
: David Lee I.T. Service :
: Senior Systems Programmer Computer Centre :
: UNIX Team Leader Durham University :
: South Road :
: http://www.dur.ac.uk/t.d.lee/ Durham DH1 3LE :
: Phone: +44 191 334 2752 U.K. :
_______________________________________________________
Linux-HA-Dev: [email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/