Get iocage jail info inside pre-start/stop hooks
Hello,
I want to add span interface into iocage jail via post-start hook. Before jail starts I want to create epair interfaces on host machine and add one of them into the jail using ifconfig epairXb vnet <jail_id> in post-start hook.sh. It will be nice if iocage initialize environment variables for hook.sh so I am able to get jail_id from there.
Versions of OS and iocage:
uname -a
FreeBSD my_host 12.0-RELEASE FreeBSD 12.0-RELEASE r341666 GENERIC amd64
iocage --version
Version 1.2
Commands used, along with any steps to recreate it:
- Create hook.sh
cat /tmp/hook.sh
#!/bin/sh
echo args: $0 $@ >> /tmp/hook.out # print arguments passed into hook.sh
echo env: `env` >> /tmp/hook.out # print env variables
-
Set hook.sh as post-start hook for my_jail:
iocage set exec_poststart=/tmp/hook.sh my_jail -
Start my_jail:
iocage start my_jail -
Hook is executed, so I am able to look at its output:
cat /tmp/hook.out
args: /tmp/hook.sh
env: LANG=XXX PATH=YYY HOME=ZZZ ... # no info about my_jail
On step 4 I expect to see variables related to jail:
env: LANG=XXX PATH=YYY HOME=ZZZ IOCAGE_JAIL_ID=888 IOCAGE_JAIL_UID=...
I am using the newest version of iocage so issue has not already been fixed on master if using
a stable release.