From owner-freebsd-questions@FreeBSD.ORG Tue Jul 21 11:18:56 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DCE6C1065673 for ; Tue, 21 Jul 2009 11:18:56 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from igloo.linux.gr (igloo.linux.gr [62.1.205.36]) by mx1.freebsd.org (Postfix) with ESMTP id 527128FC14 for ; Tue, 21 Jul 2009 11:18:55 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from kobe.laptop (adsl126-163.kln.forthnet.gr [77.49.245.163]) (authenticated bits=128) by igloo.linux.gr (8.14.3/8.14.3/Debian-9) with ESMTP id n6LBIepq013958 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 21 Jul 2009 14:18:47 +0300 Received: from kobe.laptop (kobe.laptop [127.0.0.1]) by kobe.laptop (8.14.3/8.14.3) with ESMTP id n6LBIdZD063177 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 21 Jul 2009 14:18:40 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost) by kobe.laptop (8.14.3/8.14.3/Submit) id n6LBIcCN063174; Tue, 21 Jul 2009 14:18:38 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) From: Giorgos Keramidas To: Polytropon References: <20090721112920.c174849b.freebsd@edvax.de> Date: Tue, 21 Jul 2009 14:18:37 +0300 In-Reply-To: <20090721112920.c174849b.freebsd@edvax.de> (Polytropon's message of "Tue, 21 Jul 2009 11:29:20 +0200") Message-ID: <87ljmi1dyq.fsf@kobe.laptop> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Hellug-MailScanner-ID: n6LBIepq013958 X-Hellug-MailScanner: Found to be clean X-Hellug-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-3.842, required 5, autolearn=not spam, ALL_TRUSTED -1.80, AWL 0.56, BAYES_00 -2.60) X-Hellug-MailScanner-From: keramida@ceid.upatras.gr X-Spam-Status: No Cc: chris scott , freebsd-questions@freebsd.org Subject: Re: backticks in rc.conf X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Jul 2009 11:18:57 -0000 On Tue, 21 Jul 2009 11:29:20 +0200, Polytropon wrote: > On Tue, 21 Jul 2009 09:46:47 +0100, chris scott 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.