Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 Jul 2009 14:18:37 +0300
From:      Giorgos Keramidas <keramida@ceid.upatras.gr>
To:        Polytropon <freebsd@edvax.de>
Cc:        chris scott <kraduk@googlemail.com>, freebsd-questions@freebsd.org
Subject:   Re: backticks in rc.conf
Message-ID:  <87ljmi1dyq.fsf@kobe.laptop>
In-Reply-To: <20090721112920.c174849b.freebsd@edvax.de> (Polytropon's message of "Tue, 21 Jul 2009 11:29:20 %2B0200")
References:  <d36406630907210146m4e84c7dbpd55776168a50090c@mail.gmail.com> <20090721112920.c174849b.freebsd@edvax.de>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 21 Jul 2009 11:29:20 +0200, Polytropon <freebsd@edvax.de> wrote:
> On Tue, 21 Jul 2009 09:46:47 +0100, chris scott <kraduk@googlemail.com> wrote:
>> can i use backticks in rc.conf?
>
> Basically, yes. The /etc/rc.conf file is run through sh, it is
> a shell script that assigns values to variables, but can (ab)use
> it to execute programs.
>
>> rsyncd_flags="--config=/etc/rsyncd.conf --address="` ifconfig bce1 | grep
>> inet | awk '{print $2}'`
>>
>> it works fine from the shell, however on reboot the address section doesnt
>> expand, or rather it goes blank
>
> You should use the full pathnames leading to ifconfig, grep, and awk.
> Make sure they are accessible when rc.conf is "executed".

There's a catch here that may go unnoticed for a while...

rc.conf may be sourced by /etc/rc *long* before filesystems are
mounted.  As a result grep or awk may be not be available and stop
rc.conf from loading.

It's probably a good idea to:

  * Add a special rsyncd_bind_address variable that is handled in
    `/usr/local/etc/rc.d/rsyncd' itself

  * Permit "AUTO" as the value of ${rsyncd_bind_address} and do the
    smart thing there.

  * Edit `/usr/local/etc/rc.d/rsyncd' to add a dependency for the
    "NETWORKING" and "FILESYSTEMS" special names, so that `rc.d/rsyncd'
    runs only after networking is up and /usr or other late-mounted
    filesystems have finished loading.




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?87ljmi1dyq.fsf>