# Define JID with cat in /etc/rc.conf



## minimike (Oct 5, 2010)

Hi

I have a little problem with my /etc/rc.conf. Commands like $(cat /var/foo) are currently completely ignored. Currently I will setup Jails with Vimage automatically using a bridge and epair devices. If I do it by hand it works very well. My biggest problem is if a Jail will be restarted, it becomes another JID. After start up the Jail I need the correct JID of the Jail to attach the epair device to the Jail. 

So my first idea was to write this in my /etc/rc.conf


```
gateway_enable="YES"
cloned_interfaces="bridge0"
ifconfig_bridge0="inet 10.0.0.1 netmask 255.255.255.0 up"
jail_enable="YES"
jail_v2_enable="YES"
jail_list="fbtomcat"
jail_fbtomcat_rootdir="/var/jails/fb-tomcat"
jail_fbtomcat_name="fbtomcat"
jail_fbtomcat_hostname="fbtomcat"
jail_fbtomcat_devfs_enable="YES"
jail_fbtomcat_devfs_ruleset="devfsrules_jail"
jail_fbtomcat_vnet_enable="YES"
jail_fbtomcat_exec_prestart0="ifconfig epair0 create"
jail_fbtomcat_exec_prestart1="ifconfig bridge0 addm epair0a"
jail_fbtomcat_exec_prestart2="ifconfig epair0a up"
jail_fbtomcat_exec_poststart0="ifconfig epair0b vnet $(cat /var/run/jail_fbtomcat.id)"
jail_fbtomcat_exec_poststart1="jexec $(cat /var/run/jail_fbtomcat.id) /etc/rc"
jaik_fbtomcat_exec_poststart2="jexec $(cat /var/run/jail_fbtomcat.id) /etc/rc.d/netif start"
jail_fbtomcat_exec_poststop0="ifconfig bridge0 deletem epair0a"
jail_fbtomcat_exec_poststop1="ifconfig epair0a destroy"
```

But it seems $(cat /var/run/jail_fbtomcat.id) will be ignored. So is there another working command instead for $(cat /var/run/jail_fbtomcat.id) and the /etc/rc.conf? Just to get the new JID from the Jail. Or can I define the JID per each Jail staticly?

best regards
Darko Hojnik


----------



## SirDice (Oct 6, 2010)

minimike said:
			
		

> But it seems $(cat /var/run/jail_fbtomcat.id) will be ignored.


I may be wrong but this looks like bashism to me. Try using backticks (`).


----------



## jalla (Oct 6, 2010)

I think your problem is that the command substitution is performed when /etc/rc is sourced, and before the jail is started. Perhaps you could escape the subst like this

```
jail_fbtomcat_exec_poststart1="jexec \$\(cat /var/run/jail_fbtomcat.id\) /etc/rc"
```


----------



## minimike (Oct 6, 2010)

hello guys no weed 

Only if I source out the ifcomfig command in a little scriptwrapper it will works. In the /etc/rc.conf I am calling the wrapper. That's very ugly
Any Ideas or suggestions?

best regards
Darko Hojnik


----------



## minimike (Oct 6, 2010)

I have found another solution. Now it seems to be working. But I will take a look a few day's about them before I will mark this thread as solved.

cheers Darko


----------

