5 # REQUIRE: LOGIN NETWORKING
11 start_cmd
="vkernel_start"
12 stop_cmd
="vkernel_stop"
16 echo -n 'Starting virtual kernels:'
17 for _vkernel
in ${vkernel_list}
19 # Check if already running
20 eval pidfile
="/var/run/vkernel.${_vkernel}.pid"
21 if [ -f "${pidfile}" ]; then
22 eval pid
=`cat ${pidfile}`
23 if [ ! -z "${pid}" -a ! -z "`ps axwwp ${pid} | grep -wE "^[ ]*${pid}" | grep -v grep | awk '{print $1}'`" ]; then
25 warn
"Vkernel ${_vkernel} already running? (check ${pidfile})"
30 # Configure vkernel binary
31 eval _bin
=\"\
${vkernel_${_vkernel}_bin}\"
32 if [ -z "${_bin}" -o ! -x "${_bin}" ]; then
33 eval _bin
=\"\
${vkernel_bin}\"
34 if [ -z "${_bin}" -o ! -x "${_bin}" ]; then
36 warn
"Missing or undefined binary for vkernel '${_vkernel}'. Skipping."
42 # Configure vkernel memory
43 eval _memsize
=\"\
$vkernel_${_vkernel}_memsize
\"
44 if [ -z "${_memsize}" ]; then
46 warn
"No memsize has been defined for vkernel '${_vkernel}'. Skipping."
49 memsize
="-m ${_memsize}"
52 # Configure vkernel root image(s)
53 eval _rootimgs
=\"\
${vkernel_${_vkernel}_rootimg_list}\"
54 if [ -z "${_rootimgs}" ]; then
56 warn
"No root image has been defined for vkernel '${_vkernel}'."
58 for _rootimg
in ${_rootimgs}
60 eval rootimgs
=\"${rootimgs} -r ${_rootimg}\"
64 # Configure optional vkernel network interface(s)
65 eval _ifaces
=\"\
${vkernel_${_vkernel}_iface_list}\"
66 if [ -n "${_ifaces}" ]; then
67 for _iface
in ${_ifaces}
69 eval ifaces
=\"${ifaces} -I ${_iface}\"
73 # Configure optional console logfile
74 eval logfile
=\"\
${vkernel_${_vkernel}_logfile}\"
75 [ -z "${logfile}" ] && logfile
="/dev/null"
77 # Configure optional flags
78 eval flags
=\"\
${vkernel_${_vkernel}_flags}\"
80 eval "daemon ${bin} ${memsize} ${rootimgs} ${ifaces} ${flags} -p ${pidfile} >>${logfile} 2>&1 </dev/null"
81 echo -n " ${_vkernel}"
88 for _vkernel
in ${vkernel_list}
90 eval pidfile
="/var/run/vkernel.${_vkernel}.pid"
91 if [ -f "${pidfile}" ]; then
92 eval pid
=`cat ${pidfile}`
94 if [ -z "${pid}" ]; then
95 warn
"vkernel '${_vkernel}' not running?"
98 eval kill -TERM ${pid}
100 eval _kill_timeout
=\"\
${vkernel_${_vkernel}_kill_timeout}\"
101 if [ -z "${_kill_timeout}" ]; then
102 eval _kill_timeout
=\"\
${vkernel_kill_timeout}\"
103 if [ -z "${_kill_timeout}" ]; then
108 # Check that the vkernel ended properly
110 eval temp_pid
=`ps axwwp ${pid} | grep -wE "^[ ]*${pid}" | grep -v grep | awk '{print $1}'`
111 while [ ! -z "${temp_pid}" -a "${cnt}" -lt "${_kill_timeout}" ]; do
112 eval temp_pid
=`ps axwwp ${pid} | grep -wE "^[ ]*${pid}" | grep -v grep | awk '{print $1}'`
117 if [ ! -z "${temp_pid}" ]; then
118 eval kill -KILL ${pid}
119 warn
"'${_vkernel}' had to be forcefully killed."