zirias@
Developer
Dumping a little helper for sysutils/vm-bhyve I created today, adding a possibility for a "post-startup" script in a horribly hacky way ? ... placed in /var/vm/poststartup.sh
To use it, just add
Bash:
#!/bin/sh
vm_script=/var/vm/${1}/poststartup.sh
vm_logfile=/var/vm/${1}/vm-bhyve.log
vm_log()
{
if [ -w ${vm_logfile} ]; then
LANG=C echo "`date '+%b %d %H:%M:%S:'` $@" >>${vm_logfile}
fi
}
if [ -r ${vm_script} ]; then (
sleep 1;
for i in 1 2 3 4 5 6 7 8; do
vm_status=`vm list | grep "^${1} .* Running ("`
if [ -n "${vm_status}" ]; then
vm_pid=`echo "${vm_status}" | sed -e 's:.*Running (\([0-9]*\).*:\1:'`
vm_log poststartup.sh: Running ${vm_script}.
. ${vm_script}
exit
else
sleep 1
fi
done
vm_log poststartup.sh: Giving up, vm is not running!
) </dev/null >/dev/null 2>&1 &
else
vm_log poststartup.sh: ${vm_script} is missing!
fi
To use it, just add
prestart="/var/vm/poststartup.sh"
to your vm config and place an individual poststartup.sh in its directory. E.g. I have the following for my router/firewall vm, so that routing is never ever slowed down or killed by OOM:
Code:
protect -p ${vm_pid}
rtprio 15 -${vm_pid}