Hi Michael,

On Sunday 18 November 2007 23:13:19 Michael Meskes wrote:
> On Sun, Nov 18, 2007 at 10:22:14PM +1000, Kel Modderman wrote:
> > If I put the software on a live debian cd, I can boot the same set of
> > software on real hardware or in a VM. The software should do the correct
> > thing in both the real and virtual worlds.
>
> Absolutely right. That's why the init script will check whether it is
> inside the VM before starting anything.

Try 2, cleaned up output when not in a VM.

---
Index: debian/control
===================================================================
--- debian/control      (revision 120)
+++ debian/control      (working copy)
@@ -66,7 +66,7 @@
 
 Package: virtualbox-ose-guest-utils
 Architecture: amd64 i386
-Depends: ${shlibs:Depends}, ${misc:Depends}
+Depends: ${shlibs:Depends}, ${misc:Depends}, pciutils
 Recommends: virtualbox-ose-guest-modules, virtualbox-ose-guest-source
 Description: PC virtualization solution - guest utils
  VirtualBox is a free PC virtualization solution allowing you to run a wide
Index: debian/virtualbox-ose-guest-utils.init
===================================================================
--- debian/virtualbox-ose-guest-utils.init      (revision 120)
+++ debian/virtualbox-ose-guest-utils.init      (working copy)
@@ -14,23 +14,38 @@
 
 . /lib/lsb/init-functions
 
-set -e
+in_virtual_machine()
+{
+       if [ -z "$(lspci -d 80ee:beef)" ]; then
+               log_warning_msg 'VirtualBox Additions Disabled, not in a 
Virtual Machine';
+               return 1
+       fi
 
-(lspci|grep -q 80ee:beef) || exit 0 # not inside a vm
+       return 0
+}
 
 case "$1" in
   start)
+       in_virtual_machine || exit 0
        log_action_begin_msg 'Starting VirtualBox Additions';
-       # udev should have already handled thismodule
-       # modprobe vboxadd
+       # udev should have already handled this module
+       # double check kernel support is present or die
+       modprobe --quiet vboxadd
+       if [ "$?" -ne 0 ]; then
+               # vboxadd not installed, or has a problem
+               log_failure_msg 'cannot modprobe vboxadd kernel module';
+               log_end_msg 1
+               exit 1
+       fi
 
        
start-stop-daemon --start --quiet --exec /usr/sbin/vboxadd-timesync -- 
--daemonize
-       log_end_msg 0
+       log_end_msg $?
        ;;
   stop)
+       in_virtual_machine || exit 0
        log_action_begin_msg 'Stopping VirtualBox Additions';
        start-stop-daemon --stop --quiet --oknodo --exec 
/usr/sbin/vboxadd-timesync
-       log_end_msg 0
+       log_end_msg $?
        ;;
   restart|force-reload)
        #



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to