+ einfo "VirtualBox detected, trying to set up Shared Folders."
+ if ! modinfo vboxsf &>/dev/null ; then
+ ewarn "vboxsf driver not present, not setting up VirtualBox Shared Folders."
+ eend 0
+ elif ! [ -x /usr/sbin/VBoxService ] ; then
+ ewarn "virtualbox-guest-utils not installed, not setting up VirtualBox Shared Folders."
+ eend 0
+ else
+ eindent
+
+ einfo "Loading vboxsf driver."
+ lsmod | grep -q vboxsf || modprobe vboxsf
+ eend $?
+
+ einfo "Adjusting /dev/vboxguest."
+ chown root:vboxsf /dev/vboxguest
+ chmod 660 /dev/vboxguest
+ eend $?
+
+ config_userfstab
+
+ einfo "Adding user ${fstabuser:-grml} to group vboxsf."
+ adduser "${fstabuser:-grml}" vboxsf >>"${DEBUG}" 2>&1
+ eend $?
+
+ einfo "Starting VBoxService."
+ VBoxService >/dev/null
+ eend $?
+
+ local vbautomation='automation'
+ if checkbootparam 'vbautomation'; then
+ vbautomation="$(getbootparam 'vbautomation' 2>>$DEBUG)"
+ fi
+
+ if ! VBoxControl sharedfolder list | egrep -q "^[0-9]+ - ${vbautomation}(\s+|$)" ; then
+ ewarn "No automount shared folder '$vbautomation' available"
+ eend 0
+ else
+ einfo "Found automount shared folder '$vbautomation'"
+ eend 0
+
+ local distri="$(getbootparam 'distri' 2>>$DEBUG)"
+ [ -n "$distri" ] || distri='grml'
+
+ local vbox_auto_sf="/media/sf_${vbautomation}"
+
+ sleep 1 # ugly but necessary
+
+ counter=10
+ eindent
+ while ! [ -d "${vbox_auto_sf}" ] && [[ "$counter" != 0 ]]; do
+ einfo "Waiting another second to retry access to ${vbox_auto_sf}"
+ sleep 1
+ counter=$(( counter-1 ))
+ eend 0
+ done
+ eoutdent
+
+ if ! [ -d "${vbox_auto_sf}" ] ; then
+ eerror "Giving up trying to access folder ${vbox_auto_sf} which doesn't seem to exist"
+ eend 1
+ else
+ einfo "Found shared folders automation directory $vbox_auto_sf"
+ eend 0
+
+ eindent
+ if checkbootparam 'novbautomation' ; then
+ einfo "Bootoption novbautomation found. Disabling automation script execution."
+ eend 0
+ else
+ if ! [ -x "${vbox_auto_sf}/${distri}" ] ; then
+ ewarn "Couldn't find an automation script named ${vbox_auto_sf}/${distri}"
+ eend 1
+ else
+ einfo "Executing '${vbox_auto_sf}/${distri}' now:"
+ "${vbox_auto_sf}/${distri}"
+ eend $?
+ fi
+ fi
+ eoutdent
+ fi
+ fi
+
+ eoutdent
+ fi
+ fi
+}
+# }}}
+
+# {{{ VirtualBox application
+config_virtualbox_setup() {
+ if checkbootparam 'novbox' ; then
+ ewarn "Skipping VirtualBox setup as requested on boot commandline." ; eend 0
+ return
+ fi
+
+ if ! [ -x /usr/bin/VBox ] ; then
+ return
+ fi
+
+ if running_under_secureboot ; then
+ ewarn "VirtualBox service can not be started as running under enabled Secure Boot." ; eend 0
+ return
+ fi
+
+ einfo "VirtualBox service detected, trying to set up."
+ service_wrapper vboxdrv restart >>"${DEBUG}" 2>&1 ; eend $?
+
+ config_userfstab
+
+ einfo "Adding user ${fstabuser:-grml} to group vboxusers."
+ adduser "${fstabuser:-grml}" vboxusers >>"${DEBUG}" 2>&1
+ eend $?
+}
+# }}}
+
+# {{{ Support customization
+config_distri(){
+if checkbootparam 'distri'; then
+ DISTRI="$(getbootparam 'distri' 2>>$DEBUG)"
+ if [ -r "${LIVECD_PATH}"/desktop/"$DISTRI".jpg ] ; then
+ # make sure the desktop.jpg file is not a symlink, so copying does not file then
+ [ -L /usr/share/grml/desktop.jpg ] && rm /usr/share/grml/desktop.jpg
+ cp "${LIVECD_PATH}"/desktop/"$DISTRI".jpg /usr/share/grml/desktop.jpg