<div style="font-family: Arial; font-size: 13;">Sure, infact I can change all shebang to point to /bin/bash and it&#39;s ok.<br>The question is about current shebang /bin/sh which may go into trouble (as if one would point to a generic python but uses many specific features of a version of python).<br>Also, the question is about bash being a good option for RAs, being much more heavy.<br><br>Gabriele<br><br><div id="wt-mailcard"><div style="font-family: Arial;">----------------------------------------------------------------------------------------<br></div><div style="font-family: Arial;"><b>Sonicle S.r.l. </b>: <a href="http://www.sonicle.com/" target="_new">http://www.sonicle.com</a></div><div style="font-family: Arial;"><b>Music: </b><a href="http://www.gabrielebulfon.com/" target="_new">http://www.gabrielebulfon.com</a></div><div style="font-family: Arial;"><b>Quantum Mechanics : </b><a href="http://www.cdbaby.com/cd/gabrielebulfon" target="_new">http://www.cdbaby.com/cd/gabrielebulfon</a></div></div><tt><br><br><br>----------------------------------------------------------------------------------<br><br>Da: Dejan Muhamedagic &lt;dejanmm@fastmail.fm&gt;<br>A: kgaillot@redhat.com Cluster Labs - All topics related to open-source clustering welcomed &lt;users@clusterlabs.org&gt; <br>Data: 29 agosto 2016 16.43.52 CEST<br>Oggetto: Re: [ClusterLabs] ocf scripts shell and local variables<br><br></tt><blockquote style="BORDER-LEFT: #000080 2px solid; MARGIN-LEFT: 5px; PADDING-LEFT: 5px"><tt>Hi,<br><br>On Mon, Aug 29, 2016 at 08:47:43AM -0500, Ken Gaillot wrote:<br>&gt; On 08/29/2016 04:17 AM, Gabriele Bulfon wrote:<br>&gt; &gt; Hi Ken,<br>&gt; &gt; <br>&gt; &gt; I have been talking with the illumos guys about the shell problem.<br>&gt; &gt; They all agreed that ksh (and specially the ksh93 used in illumos) is<br>&gt; &gt; absolutely Bourne-compatible, and that the &quot;local&quot; variables used in the<br>&gt; &gt; ocf shells is not a Bourne syntax, but probably a bash specific.<br>&gt; &gt; This means that pointing the scripts to &quot;#!/bin/sh&quot; is portable as long<br>&gt; &gt; as the scripts are really Bourne-shell only syntax, as any Unix variant<br>&gt; &gt; may link whatever Bourne-shell they like.<br>&gt; &gt; In this case, it should point to &quot;#!/bin/bash&quot; or whatever shell the<br>&gt; &gt; script was written for.<br>&gt; &gt; Also, in this case, the starting point is not the ocf-* script, but the<br>&gt; &gt; original RA (IPaddr, but almost all of them).<br>&gt; &gt; <br>&gt; &gt; What about making the code base of RA and ocf-* portable?<br>&gt; &gt; It may be just by changing them to point to bash, or with some kind of<br>&gt; &gt; configure modifier to be able to specify the shell to use.<br>&gt; &gt; <br>&gt; &gt; Meanwhile, changing the scripts by hands into #!/bin/bash worked like a<br>&gt; &gt; charm, and I will start patching.<br>&gt; &gt; <br>&gt; &gt; Gabriele<br>&gt; <br>&gt; Interesting, I thought local was posix, but it&#39;s not. It seems everyone<br>&gt; but solaris implemented it:<br>&gt; <br>&gt; http://stackoverflow.com/questions/18597697/posix-compliant-way-to-scope-variables-to-a-function-in-a-shell-script<br>&gt; <br>&gt; Please open an issue at:<br>&gt; <br>&gt; https://github.com/ClusterLabs/resource-agents/issues<br>&gt; <br>&gt; The simplest solution would be to require #!/bin/bash for all RAs that<br>&gt; use local,<br><br>This issue was raised many times, but note that /bin/bash is a<br>shell not famous for being lean: it&#39;s great for interactive use,<br>but not so great if you need to run a number of scripts. The<br>complexity in bash, which is superfluous for our use case,<br>doesn&#39;t go well with the basic principles of HA clusters.<br><br>&gt; but I&#39;m not sure that&#39;s fair to the distros that support<br>&gt; local in a non-bash default shell. Another possibility would be to<br>&gt; modify all RAs to avoid local entirely, by using unique variable<br>&gt; prefixes per function.<br><br>I doubt that we could do a moderately complex shell scripts<br>without capability of limiting the variables&#39; scope and retaining<br>sanity at the same time.<br><br>&gt; Or, it may be possible to guard every instance of<br>&gt; local with a check for ksh, which would use typeset instead. Raising the<br>&gt; issue will allow some discussion of the possibilities.<br><br>Just to mention that this is the first time someone reported<br>running a shell which doesn&#39;t support local. Perhaps there&#39;s an<br>option that they install a shell which does.<br><br>Thanks,<br><br>Dejan<br><br>&gt; &gt; <br>&gt; &gt; ----------------------------------------------------------------------------------------<br>&gt; &gt; *Sonicle S.r.l. *: http://www.sonicle.com &lt;http://www.sonicle.com/&gt;<br>&gt; &gt; *Music: *http://www.gabrielebulfon.com &lt;http://www.gabrielebulfon.com/&gt;<br>&gt; &gt; *Quantum Mechanics : *http://www.cdbaby.com/cd/gabrielebulfon<br>&gt; &gt; <br>&gt; &gt; <br>&gt; &gt; <br>&gt; &gt; ----------------------------------------------------------------------------------<br>&gt; &gt; <br>&gt; &gt; Da: Ken Gaillot &lt;kgaillot@redhat.com&gt;<br>&gt; &gt; A: gbulfon@sonicle.com Cluster Labs - All topics related to open-source<br>&gt; &gt; clustering welcomed &lt;users@clusterlabs.org&gt;<br>&gt; &gt; Data: 26 agosto 2016 15.56.02 CEST<br>&gt; &gt; Oggetto: Re: ocf scripts shell and local variables<br>&gt; &gt; <br>&gt; &gt;     On 08/26/2016 08:11 AM, Gabriele Bulfon wrote:<br>&gt; &gt;     &gt; I tried adding some debug in ocf-shellfuncs, showing env and ps<br>&gt; &gt;     -ef into<br>&gt; &gt;     &gt; the corosync.log<br>&gt; &gt;     &gt; I suspect it&#39;s always using ksh, because in the env output I<br>&gt; &gt;     produced I<br>&gt; &gt;     &gt; find this: KSH_VERSION=.sh.version<br>&gt; &gt;     &gt; This is normally not present in the environment, unless ksh is running<br>&gt; &gt;     &gt; the shell.<br>&gt; &gt; <br>&gt; &gt;     The RAs typically start with #!/bin/sh, so whatever that points to on<br>&gt; &gt;     your system is what will be used.<br>&gt; &gt; <br>&gt; &gt;     &gt; I also tried modifiying all ocf shells with &quot;#!/usr/bin/bash&quot; at the<br>&gt; &gt;     &gt; beginning, no way, same output.<br>&gt; &gt; <br>&gt; &gt;     You&#39;d have to change the RA that includes them.<br>&gt; &gt; <br>&gt; &gt;     &gt; Any idea how can I change the used shell to support &quot;local&quot; variables?<br>&gt; &gt; <br>&gt; &gt;     You can either edit the #!/bin/sh line at the top of each RA, or figure<br>&gt; &gt;     out how to point /bin/sh to a Bourne-compatible shell. ksh isn&#39;t<br>&gt; &gt;     Bourne-compatible, so I&#39;d expect lots of #!/bin/sh scripts to fail with<br>&gt; &gt;     it as the default shell.<br>&gt; &gt; <br>&gt; &gt;     &gt; Gabriele<br>&gt; &gt;     &gt;<br>&gt; &gt;     &gt;<br>&gt; &gt;     ----------------------------------------------------------------------------------------<br>&gt; &gt;     &gt; *Sonicle S.r.l. *: http://www.sonicle.com &lt;http://www.sonicle.com/&gt;<br>&gt; &gt;     &gt; *Music: *http://www.gabrielebulfon.com<br>&gt; &gt;     &lt;http://www.gabrielebulfon.com/&gt;<br>&gt; &gt;     &gt; *Quantum Mechanics : *http://www.cdbaby.com/cd/gabrielebulfon<br>&gt; &gt;     &gt;<br>&gt; &gt;     &gt;<br>&gt; &gt;     ------------------------------------------------------------------------<br>&gt; &gt;     &gt;<br>&gt; &gt;     &gt;<br>&gt; &gt;     &gt; *Da:* Gabriele Bulfon &lt;gbulfon@sonicle.com&gt;<br>&gt; &gt;     &gt; *A:* kgaillot@redhat.com Cluster Labs - All topics related to<br>&gt; &gt;     &gt; open-source clustering welcomed &lt;users@clusterlabs.org&gt;<br>&gt; &gt;     &gt; *Data:* 26 agosto 2016 10.12.13 CEST<br>&gt; &gt;     &gt; *Oggetto:* Re: [ClusterLabs] ocf::heartbeat:IPaddr<br>&gt; &gt;     &gt;<br>&gt; &gt;     &gt;<br>&gt; &gt;     &gt; I looked around what you suggested, inside ocf-binaris and<br>&gt; &gt;     &gt; ocf-shellfuncs etc.<br>&gt; &gt;     &gt; So I found also these logs in corosync.log :<br>&gt; &gt;     &gt;<br>&gt; &gt;     &gt; Aug 25 17:50:33 [2250] crmd: notice: process_lrm_event:<br>&gt; &gt;     &gt; xstorage1-xstorage2_wan2_IP_start_0:22 [<br>&gt; &gt;     &gt; /usr/lib/ocf/resource.d/heartbeat/IPaddr[71]: local: not found [No<br>&gt; &gt;     &gt; such file or<br>&gt; &gt;     &gt; directory]\n/usr/lib/ocf/resource.d/heartbeat/IPaddr[354]: local:<br>&gt; &gt;     &gt; not found [No such file or<br>&gt; &gt;     &gt; directory]\n/usr/lib/ocf/resource.d/heartbeat/IPaddr[355]: local:<br>&gt; &gt;     &gt; not found [No such file or<br>&gt; &gt;     &gt; directory]\n/usr/lib/ocf/resource.d/heartbeat/IPaddr[356]: local:<br>&gt; &gt;     &gt; not found [No such file or directory]\nocf-exit-reason:Setup<br>&gt; &gt;     &gt; problem: coul<br>&gt; &gt;     &gt;<br>&gt; &gt;     &gt; Aug 25 17:50:33 [2246] lrmd: notice: operation_finished:<br>&gt; &gt;     &gt; xstorage2_wan2_IP_start_0:3613:stderr [<br>&gt; &gt;     &gt; /usr/lib/ocf/resource.d/heartbeat/IPaddr[71]: local: not found [No<br>&gt; &gt;     &gt; such file or directory] ]<br>&gt; &gt;     &gt;<br>&gt; &gt;     &gt; Looks like the shell is not happy with the &quot;local&quot; variable<br>&gt; &gt;     definition.<br>&gt; &gt;     &gt; I tried running ocf-shellfuncs manually with sh and bash and they<br>&gt; &gt;     &gt; all run without errors.<br>&gt; &gt;     &gt; How can I see what shell is running these scripts?<br>&gt; &gt;     &gt;<br>&gt; &gt;     &gt;<br>&gt; &gt;     ----------------------------------------------------------------------------------------<br>&gt; &gt;     &gt; *Sonicle S.r.l. *: http://www.sonicle.com &lt;http://www.sonicle.com/&gt;<br>&gt; &gt;     &gt; *Music: *http://www.gabrielebulfon.com<br>&gt; &gt;     &lt;http://www.gabrielebulfon.com/&gt;<br>&gt; &gt;     &gt; *Quantum Mechanics : *http://www.cdbaby.com/cd/gabrielebulfon<br>&gt; &gt;     &gt;<br>&gt; &gt;     &gt;<br>&gt; &gt;     &gt;<br>&gt; &gt;     &gt;<br>&gt; &gt;     ----------------------------------------------------------------------------------<br>&gt; &gt;     &gt;<br>&gt; &gt;     &gt; Da: Ken Gaillot &lt;kgaillot@redhat.com&gt;<br>&gt; &gt;     &gt; A: users@clusterlabs.org<br>&gt; &gt;     &gt; Data: 25 agosto 2016 18.07.42 CEST<br>&gt; &gt;     &gt; Oggetto: Re: [ClusterLabs] ocf::heartbeat:IPaddr<br>&gt; &gt;     &gt;<br>&gt; &gt;     &gt; On 08/25/2016 10:51 AM, Gabriele Bulfon wrote:<br>&gt; &gt;     &gt; &gt; Hi,<br>&gt; &gt;     &gt; &gt;<br>&gt; &gt;     &gt; &gt; I&#39;m advancing with this monster cluster on XStreamOS/illumos ;)<br>&gt; &gt;     &gt; &gt;<br>&gt; &gt;     &gt; &gt; In the previous older tests I used heartbeat, and I had these<br>&gt; &gt;     &gt; lines to<br>&gt; &gt;     &gt; &gt; take care of the swapping public IP addresses:<br>&gt; &gt;     &gt; &gt;<br>&gt; &gt;     &gt; &gt; primitive xstorage1_wan1_IP ocf:heartbeat:IPaddr params<br>&gt; &gt;     &gt; ip=&quot;1.2.3.4&quot;<br>&gt; &gt;     &gt; &gt; cidr_netmask=&quot;255.255.255.0&quot; nic=&quot;e1000g1&quot;<br>&gt; &gt;     &gt; &gt; primitive xstorage2_wan2_IP ocf:heartbeat:IPaddr params<br>&gt; &gt;     &gt; ip=&quot;1.2.3.5&quot;<br>&gt; &gt;     &gt; &gt; cidr_netmask=&quot;255.255.255.0&quot; nic=&quot;e1000g1&quot;<br>&gt; &gt;     &gt; &gt;<br>&gt; &gt;     &gt; &gt; location xstorage1_wan1_IP_pref xstorage1_wan1_IP 100: xstorage1<br>&gt; &gt;     &gt; &gt; location xstorage2_wan2_IP_pref xstorage2_wan2_IP 100: xstorage2<br>&gt; &gt;     &gt; &gt;<br>&gt; &gt;     &gt; &gt; They get configured, but then I get this in crm status:<br>&gt; &gt;     &gt; &gt;<br>&gt; &gt;     &gt; &gt; xstorage1_wan1_IP (ocf::heartbeat:IPaddr): Stopped<br>&gt; &gt;     &gt; &gt; xstorage2_wan2_IP (ocf::heartbeat:IPaddr): Stopped<br>&gt; &gt;     &gt; &gt;<br>&gt; &gt;     &gt; &gt; Failed Actions:<br>&gt; &gt;     &gt; &gt; * xstorage1_wan1_IP_start_0 on xstorage1 &#39;not installed&#39; (5):<br>&gt; &gt;     &gt; call=20,<br>&gt; &gt;     &gt; &gt; status=complete, exitreason=&#39;Setup problem: couldn&#39;t find command:<br>&gt; &gt;     &gt; &gt; /usr/bin/gawk&#39;,<br>&gt; &gt;     &gt; &gt; last-rc-change=&#39;Thu Aug 25 17:50:32 2016&#39;, queued=1ms, exec=158ms<br>&gt; &gt;     &gt; &gt; * xstorage2_wan2_IP_start_0 on xstorage1 &#39;not installed&#39; (5):<br>&gt; &gt;     &gt; call=22,<br>&gt; &gt;     &gt; &gt; status=complete, exitreason=&#39;Setup problem: couldn&#39;t find command:<br>&gt; &gt;     &gt; &gt; /usr/bin/gawk&#39;,<br>&gt; &gt;     &gt; &gt; last-rc-change=&#39;Thu Aug 25 17:50:33 2016&#39;, queued=1ms, exec=29ms<br>&gt; &gt;     &gt; &gt; * xstorage1_wan1_IP_start_0 on xstorage2 &#39;not installed&#39; (5):<br>&gt; &gt;     &gt; call=22,<br>&gt; &gt;     &gt; &gt; status=complete, exitreason=&#39;Setup problem: couldn&#39;t find command:<br>&gt; &gt;     &gt; &gt; /usr/bin/gawk&#39;,<br>&gt; &gt;     &gt; &gt; last-rc-change=&#39;Thu Aug 25 17:50:30 2016&#39;, queued=1ms, exec=36ms<br>&gt; &gt;     &gt; &gt; * xstorage2_wan2_IP_start_0 on xstorage2 &#39;not installed&#39; (5):<br>&gt; &gt;     &gt; call=20,<br>&gt; &gt;     &gt; &gt; status=complete, exitreason=&#39;Setup problem: couldn&#39;t find command:<br>&gt; &gt;     &gt; &gt; /usr/bin/gawk&#39;,<br>&gt; &gt;     &gt; &gt; last-rc-change=&#39;Thu Aug 25 17:50:29 2016&#39;, queued=0ms, exec=150ms<br>&gt; &gt;     &gt; &gt;<br>&gt; &gt;     &gt; &gt;<br>&gt; &gt;     &gt; &gt; The crm configure process already checked of the presence of the<br>&gt; &gt;     &gt; &gt; required IPaddr shell, and it was ok.<br>&gt; &gt;     &gt; &gt; Now looks like it&#39;s looking for &quot;/usr/bin/gawk&quot;, and that is<br>&gt; &gt;     &gt; actually there!<br>&gt; &gt;     &gt; &gt; Is there any known incompatibility with the mixed heartbeat<br>&gt; &gt;     &gt; ocf ? Should<br>&gt; &gt;     &gt; &gt; I use corosync specific ocf files or something else?<br>&gt; &gt;     &gt;<br>&gt; &gt;     &gt; &quot;heartbeat&quot; in this case is just an OCF provider name, and has<br>&gt; &gt;     &gt; nothing<br>&gt; &gt;     &gt; to do with the heartbeat messaging layer, other than having its<br>&gt; &gt;     &gt; origin<br>&gt; &gt;     &gt; in the same project. There actually has been a recent proposal<br>&gt; &gt;     &gt; to rename<br>&gt; &gt;     &gt; the provider to &quot;clusterlabs&quot; to better reflect the current reality.<br>&gt; &gt;     &gt;<br>&gt; &gt;     &gt; The &quot;couldn&#39;t find command&quot; message comes from the ocf-binaries<br>&gt; &gt;     &gt; shell<br>&gt; &gt;     &gt; functions. If you look at have_binary() there, it uses sed and<br>&gt; &gt;     &gt; which,<br>&gt; &gt;     &gt; and I&#39;m guessing that fails on your OS somehow. You may need to<br>&gt; &gt;     &gt; patch it.<br>&gt; &gt;     &gt;<br>&gt; &gt;     &gt; &gt; Thanks again!<br>&gt; &gt;     &gt; &gt;<br>&gt; &gt;     &gt; &gt; Gabriele<br>&gt; &gt;     &gt; &gt;<br>&gt; &gt;     &gt; &gt;<br>&gt; &gt;     &gt;<br>&gt; &gt;     ----------------------------------------------------------------------------------------<br>&gt; &gt;     &gt; &gt; *Sonicle S.r.l. *: http://www.sonicle.com<br>&gt; &gt;     &gt; &lt;http://www.sonicle.com/&gt;<br>&gt; &gt;     &gt; &gt; *Music: *http://www.gabrielebulfon.com<br>&gt; &gt;     &gt; &lt;http://www.gabrielebulfon.com/&gt;<br>&gt; &gt;     &gt; &gt; *Quantum Mechanics : *http://www.cdbaby.com/cd/gabrielebulfon<br>&gt; <br>&gt; _______________________________________________<br>&gt; Users mailing list: Users@clusterlabs.org<br>&gt; http://clusterlabs.org/mailman/listinfo/users<br>&gt; <br>&gt; Project Home: http://www.clusterlabs.org<br>&gt; Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf<br>&gt; Bugs: http://bugs.clusterlabs.org<br><br>_______________________________________________<br>Users mailing list: Users@clusterlabs.org<br>http://clusterlabs.org/mailman/listinfo/users<br><br>Project Home: http://www.clusterlabs.org<br>Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf<br>Bugs: http://bugs.clusterlabs.org<br><br><br></tt></blockquote></div>