From 6992b6808072f97e3b7870dec51c5fc19e55aa91 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Mon, 24 Feb 2014 15:24:22 +0100 Subject: [PATCH] Support automatic execution of scripts on VirtualBox shared folders If an executable /media/sf_automation/$distri is present (where $distri defaults to "grml" if unset) it is automatically executed during bootup. The '/media/sf_automation' directory corresponds to a shared folder named "automation" inside VirtualBox (which has the auto-mount option set inside the VirtualBox configuration to be useful). The feature can be disabled via boot option 'novbautomation' and the path to the automation directory can be controlled via boot option 'vbautomation' (e.g. 'vbautomation='/media/sf_foobar', so don't forget the "/media/sf_"). This feature provides a nice way to automate things during bootup inside VirtualBox without having to adjust any boot options, while still being able to control the behaviour from the host system via setup of shared folders. --- autoconfig.functions | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/autoconfig.functions b/autoconfig.functions index f2e48ac..5580812 100755 --- a/autoconfig.functions +++ b/autoconfig.functions @@ -2265,9 +2265,38 @@ if $VIRTUALBOX ; then eend $? einfo "Starting VBoxService." - VBoxService >/dev/null & + VBoxService >/dev/null eend $? + local vbox_automation='/media/sf_automation' + if checkbootparam 'vbautomation'; then + vbox_automation="$(getbootparam 'vbautomation' 2>>$DEBUG)" + fi + + local distri="$(getbootparam 'distri' 2>>$DEBUG)" + [ -n "$distri" ] || distri='grml' + + if [ -d "${vbox_automation}" ] ; then + einfo "Found shared folders automation directory $vbox_automation" + eend 0 + + eindent + if checkbootparam 'novbautomation' ; then + einfo "Bootoption novbautomation found. Disabling automation script execution." + eend 0 + else + if ! [ -x "${vbox_automation}/${distri}" ] ; then + ewarn "Couldn't find an automation script named ${vbox_automation}/${distri}" + eend 1 + else + einfo "Executing '${vbox_automation}/${distri}' now:" + "${vbox_automation}/${distri}" + eend $? + fi + fi + eoutdent + fi + eoutdent fi fi -- 2.1.4