From owner-freebsd-questions@FreeBSD.ORG Tue Jul 21 11:24:10 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 C3728106566B for ; Tue, 21 Jul 2009 11:24:10 +0000 (UTC) (envelope-from kraduk@googlemail.com) Received: from mail-fx0-f214.google.com (mail-fx0-f214.google.com [209.85.220.214]) by mx1.freebsd.org (Postfix) with ESMTP id 4877B8FC12 for ; Tue, 21 Jul 2009 11:24:09 +0000 (UTC) (envelope-from kraduk@googlemail.com) Received: by fxm10 with SMTP id 10so12648fxm.43 for ; Tue, 21 Jul 2009 04:24:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=jvnH+9zZjfJayiTN7q1lmsV4ZuUg8qn9jDAY+83dlLs=; b=RM3TeZYSFs9B5jbmLYHKfxyggv6XhcvV0iWH35FRfIuegGH0vFU6gvREVajFaZTkCT 2fFrNh93GwZhQXder2lIAAVQSiQ+JHXaomeIPpwoJ5mmovYwNDXVEl1QUOg3iveOsUlK 2IB3f1d3lgCw85GEyIJBIV4sFFpkAPmOpAMt8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=AAJPL3HgUj5wBJrLkbtdiJBA+owMURE5ziv8zNgD/p/XaS9kX8w8Tbvg1jO39iokMB lVkDMMIwhO++O4s7qNimusjAcHwtqWCebmE0zw2lsea3eUz3pK79PZ8eT65XReB5M8Dp b3vb01mQPxxkupyEzJ7cnAApfSP70dubTm0ww= MIME-Version: 1.0 Received: by 10.103.223.1 with SMTP id a1mr1901109mur.56.1248175449120; Tue, 21 Jul 2009 04:24:09 -0700 (PDT) In-Reply-To: <87ljmi1dyq.fsf@kobe.laptop> References: <20090721112920.c174849b.freebsd@edvax.de> <87ljmi1dyq.fsf@kobe.laptop> Date: Tue, 21 Jul 2009 12:24:09 +0100 Message-ID: From: chris scott To: Giorgos Keramidas Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: Polytropon , 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:24:11 -0000 2009/7/21 Giorgos Keramidas > 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. > > thanks for the advice but I've found a solution (see below). My systems dont generally have a /usr slice as i like to keep all the os in one place, having a slice for /usr/local. /var, /home, and /tmp so the late fs isnt an issue for me. My latest test builds are pure zfs so wont be an issue there either 8) a=`echo $ifconfig_bge0 | /usr/bin/awk '{ for ( i=1 ; i <= NF; i++) { if ( $i ~ /[iI][nN][eE][tT]/ ) { sub(/\/.*/,"", $(i+1)); print $(i+1) } } }'` rsyncd_flags="--config=/etc/rsyncd.conf --address=$a"