vkernel: rc improvements
authorRumko <rumcic@gmail.com>
Sun, 10 Oct 2010 15:20:40 +0000 (17:20 +0200)
committerAntonio Huete Jimenez <tuxillo@quantumachine.net>
Tue, 12 Oct 2010 21:03:35 +0000 (23:03 +0200)
Add a vkernel_bin var that contains the default path to the binary,
for all the vkernels without a vkernel specific entry.
Also the root image is no longer required (diskless vkernels have no
use for a root image).
And when stopping a vkernel a pidfile is required so we don't kill
innocent bystanders.

etc/defaults/rc.conf
etc/rc.d/vkernel

index 79b2dcd..683c4c6 100644 (file)
@@ -457,6 +457,7 @@ jail_sysvipc_allow="NO"     # Allow SystemV IPC use from within a jail
 
 vkernel_enable="NO"    # Set to YES to enable starting of vkernels
 vkernel_list=""                # Space separated list of names of vkernels
+#vkernel_bin="/boot/kernel.VKERNEL"    # Default path to the vkernel binary
 
 #
 # Create an entry for each vkernel specified in vkernel_list
index ef28133..35c8a43 100644 (file)
@@ -27,12 +27,14 @@ vkernel_start()
                # Configure vkernel binary
                eval _bin=\"\${vkernel_${_vkernel}_bin}\"
                if [ -z "${_bin}" -o ! -x "${_bin}" ]; then
-                       echo
-                       warn "Missing or undefined binary for vkernel '${_vkernel}'. Skipping."
-                       continue
-               else
-                       bin=${_bin}
+                       eval _bin=\"\${vkernel_bin}\"
+                       if [ -z "${_bin}" -o ! -x "${_bin}" ]; then
+                               echo
+                               warn "Missing or undefined binary for vkernel '${_vkernel}'. Skipping."
+                               continue
+                       fi
                fi
+               bin=${_bin}
 
                # Configure vkernel memory
                eval _memsize=\"\$vkernel_${_vkernel}_memsize\"
@@ -48,8 +50,7 @@ vkernel_start()
                eval _rootimgs=\"\${vkernel_${_vkernel}_rootimg_list}\"
                if [ -z "${_rootimgs}" ]; then
                        echo
-                       warn "No root image has been defined for vkernel '${_vkernel}'. Skipping."
-                       continue
+                       warn "No root image has been defined for vkernel '${_vkernel}'."
                else
                        for _rootimg in ${_rootimgs}
                        do
@@ -86,11 +87,6 @@ vkernel_stop()
                eval pidfile="/var/run/vkernel.${_vkernel}.pid"
                if [ -f "${pidfile}" ]; then
                        eval pid=`cat ${pidfile}`
-               else
-                       eval _bin=\"\${vkernel_${_vkernel}_bin}\"
-                       if [ -n "$_bin" ]; then
-                               eval pid=`ps auxwww | grep ${_bin} | grep -v grep | awk '{print $2}'`
-                       fi
                fi
                if [ -z "${pid}" ]; then
                        warn "vkernel '${_vkernel}' not running?"