jails Is it possible to define variable inside jail.conf using a return value of a script?

I would need semethig like this inside jail.conf

$ip="192.168.0.145/24";
$ip_no_mask="`echo -n '${ip}'|cut -d \"/\" -f 1|tr -d '\n'`";

Is it possible at all? I I need to calculate something, how can I use it on more then one place?
 
My conclusion is that it is not possible. But still could be useful. Now it is hard to share value between prestart and start and other section scripts. For example new interface name.
Possible workarounds for my case: Define ip and mask separately using two variables and create third variable using those two variables. Another is to put all exec.prestart into one script. The variable can shared inside the script. That is what I have done.
The advantage of the script may be that it is easier to debug then many exec.prestart += lines in /etc/jail.conf
My jailPrestart.sh is testing that the ip address of jail is not used otherwise refuses to start:

sh:
#! /bin/sh
ip="$1"
name="$2" # jailname
path="$3"
shift;shift;shift
# end the rest
note="$@"

ip_no_mask=`echo -n ${ip}|cut -d/ -f 1|tr -d '\n'`

#echo $ip_no_mask

if ping -c 1 -W 1 $ip_no_mask >/dev/null 2>&1; then
    echo "[$name] IP $ip_no_mask already in use, skipping start.";
    exit 1;
else
    echo "[$name] IP $ip_no_mask does not reply we can start";
fi;

/root/bin/jailCreateEpair.sh $name
mkdir -p ${path}/etc/ovps_shared

echo -n "# $note
ext_if=\"B$name\"
ext_ip=\"$ip_no_mask\"">$path/etc/pf_local_definitions.conf

mount_nullfs -o ro /etc/ovps_shared ${path}/etc/ovps_shared

And ma jail.conf contains

exec.prestart="/root/bin/jailPrestart.sh $ip $name $path $note";
 
Back
Top