From owner-freebsd-questions@freebsd.org Wed Mar 30 14:55:54 2016 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 76EA6AE2884 for ; Wed, 30 Mar 2016 14:55:54 +0000 (UTC) (envelope-from stdin@niklaas.eu) Received: from box.niklaas.eu (box.niklaas.eu [46.165.253.68]) by mx1.freebsd.org (Postfix) with ESMTP id 3CE23127A for ; Wed, 30 Mar 2016 14:55:54 +0000 (UTC) (envelope-from stdin@niklaas.eu) Received: by box.niklaas.eu (Postfix, from userid 1001) id 53C0F61FAA; Wed, 30 Mar 2016 16:55:47 +0200 (CEST) Date: Wed, 30 Mar 2016 16:55:47 +0200 From: Niklaas Baudet von Gersdorff To: freebsd-questions@freebsd.org Subject: Re: Variables substitution in jail.conf Message-ID: <20160330145547.GC1256@box.niklaas.eu> Mail-Followup-To: freebsd-questions@freebsd.org References: <7fbd35d23c23fb734bc10643a06f2d78@gritton.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7fbd35d23c23fb734bc10643a06f2d78@gritton.org> User-Agent: Mutt/1.5.24 (2015-08-30) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Mar 2016 14:55:54 -0000 James Gritton [2016-03-30 07:47 -0600] : > Niklaas Baudet von Gersdorff wrote: > > > host.hostname = "$name.box-fra-01.klaas"; > > path = "/usr/local/jails/$name"; > > ip4.addr = "lo1|10.15.$network.$id"; > > ip6.addr = "vtnet0|2a00:XXX:XXXX:XXXX:X::$network:$id"; > > mount = "/usr/local/jails/templates/base-10.2-RELEASE > > /usr/local/jails/$name/ nullfs ro 0 0"; > > mount += "/usr/local/jails/thinjails/$name > > /usr/local/jails/$name/jail nullfs rw 0 0"; > > mount.devfs; > > > > exec.start = "/bin/sh /etc/rc"; > > exec.stop = "/bin/sh /etc/rc.shutdown"; > > > > exec.clean; > > > > www { > > $id = 1; > > $network = 1; > > exec.poststart = "pfctl -t www -T add ${ip4.addr} {$ip6.addr}"; > > exec.poststop = "pfctl -t www -T delete {$ip4.addr} {$ip6.addr}"; > > } > The problem is pretty simple - just a case of moving some brackets. In > the definition of exec.poststart, you did ip4.addr right - ${ip4.addr}. > But for ip6.addr, you moved the dollar sign inside the braces - > {$ip6.addr}. That makes it look like the braces and the ".addr" are > just part of the string, and only $ip6 is the variable to be > substituted. > > So all you need is: > > exec.poststart = "pfctl -t www -T add ${ip4.addr} ${ip6.addr}"; > exec.poststop = "pfctl -t www -T delete ${ip4.addr} > ${ip6.addr}"; Indeed, that was it. Thanks. Four eyes see more than two. Anyway, that leaves me with the problem that the variables expand to lo1|something and vtnet0|something. I tried to set custom variables but that's not possible, is it?