On 10/08/2017 15:29, Alan Makoev via freebsd-ports wrote:
> Hello FreeBSD team!
> I installed haproxy and found that it's rc script ignores pidfile set in
> rc.d. I suppose this is because these lines:
> 
> : ${haproxy_enable:="NO"}
> : ${haproxy_config:="%%PREFIX%%/etc/${name}.conf"}
> pidfile=${haproxy_pidfile:-"/var/run/haproxy.pid"}
> 
> precede this one:
> 
> load_rc_config $name
> 
> As a result, haproxy_enable and haproxy_config are redefined when
> loading config, but pidfile keeps the default value.

No, this is a common shell idiom for providing a default value

  ${foo:-"default setting"}

will resolve to either the value of ${foo} or -- iff ${foo} is unset or
null -- then "default setting" will be used instead.

The form:

: ${foo:="default setting"}

is similar, but difference is that it /sets/ the value of ${foo} to
"default setting" if ${foo} is not already initialised.  The leading ':'
is a do-nothing command in /bin/sh -- otherwise the shell would attempt
to run whatever setting ${foo} ended up with as a command, which would
undoubtedly fail.

These are used without exception in every single rc.conf init file, so
we're pretty sure it works exactly as intended.

You need to put text like this

   haproxy_pidfile="/some/pidfile/location"

into your /etc/rc.conf  Note that, depending on the software concerned,
having a pidfile defined in the haproxy.conf file may or may not
override a setting given on the command line by the rc.conf script, so
make sure both of those are in agreement to avoid confusion.

        Cheers,

        Matthew


Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to