diff options
Diffstat (limited to 'os-plugins/plugins/virtualbox/XX_virtualbox.sh')
-rw-r--r-- | os-plugins/plugins/virtualbox/XX_virtualbox.sh | 70 |
1 files changed, 54 insertions, 16 deletions
diff --git a/os-plugins/plugins/virtualbox/XX_virtualbox.sh b/os-plugins/plugins/virtualbox/XX_virtualbox.sh index 38dd80ec..b54b4bec 100644 --- a/os-plugins/plugins/virtualbox/XX_virtualbox.sh +++ b/os-plugins/plugins/virtualbox/XX_virtualbox.sh @@ -1,4 +1,5 @@ -# Copyright (c) 2009 - OpenSLX GmbH +# Copyright (c) 2009..2010 - RZ Uni Freiburg +# Copyright (c) 2009..2010 - OpenSLX GmbH # # This program/file is free software distributed under the GPL version 2. # See http://openslx.org/COPYING @@ -11,19 +12,28 @@ # script is included from init via the "." load function - thus it has all # variables and functions available +# include default directories +. /etc/openslx.conf + +CONFFILE=/initramfs/plugin-conf/virtualbox.conf +PLUGINCONFDIR=/mnt/${OPENSLX_DEFAULT_CONFDIR}/plugins/virtualbox +PLUGINDIR=/mnt/${OPENSLX_DEFAULT_DIR}/plugin-repo/virtualbox +VIRTDIR=/mnt/${OPENSLX_DEFAULT_VIRTDIR}/virtualbox + # check if the configuration file is available -if [ -e /initramfs/plugin-conf/virtualbox.conf ]; then +if [ -e ${CONFFILE} ]; then # load needed variables - . /initramfs/plugin-conf/virtualbox.conf + . ${CONFFILE} # Test if this plugin is activated... more or less useless with the # new plugin system - if [ $virtualbox_active -ne 0 ]; then + if [ $virtualbox_active -ne 0 2>/dev/null ]; then [ $DEBUGLEVEL -gt 0 ] && echo "executing the 'virtualbox' os-plugin ..."; + # load general configuration - . /initramfs/machine-setup + . /etc/initramfs-setup # get source of virtualbox image server (get type, server and path) if strinstr "/" "${virtualbox_imagesrc}" ; then @@ -33,28 +43,56 @@ if [ -e /initramfs/plugin-conf/virtualbox.conf ]; then fi if [ -n "${vbimgserv}" ] ; then # directory where qemu images are expected in - mnttarget=/mnt/var/lib/virt/virtualbox + mnttarget=${VIRTDIR} # mount the virtualbox image source readonly (ro) fsmount ${vbimgprot} ${vbimgserv} ${vbimgpath} ${mnttarget} ro else - [ $DEBUGLEVEL -gt 1 ] && error " * Incomplete information in variable \ -${virtualbox_imagesrc}." nonfatal + [ $DEBUGLEVEL -gt 1 ] && \ + error " * Incomplete information in variable ${virtualbox_imagesrc}." \ + nonfatal fi - # copy version depending files - the vmchooser expects for every virtua- - # lization plugin a file named after it (here run-virtualbox.include) - testmkd /mnt/etc/opt/openslx - cp /mnt/opt/openslx/plugin-repo/virtualbox/run-virt.include \ - /mnt/etc/opt/openslx/run-virtualbox.include + + # copy virtualization include files to config dir + testmkd ${PLUGINCONFDIR} + cp ${PLUGINDIR}/*.include ${PLUGINCONFDIR} + # copy ${CONFFILE} to ${PLUGINCONFDIR} just in case + cp ${CONFFILE} ${PLUGINCONFDIR} + +# # TODO: create rawdisk if requested +# # create raw disk +# for part in $(grep -qE " 44 | 45 " /etc/disk.partition); do +# case "${part}" in +# * 45 *) +# id4x=$(grep " 45 " /etc/disk.partition | grep -E " 44 | 45 " \ +# | awk '{print $1}' | cut -c -8) +# break +# ;; +# * 44 *) +# id4x=$(grep " 44 " /etc/disk.partition | grep -E " 44 | 45 " \ +# | awk '{print $1}' | cut -c -8) +# break +# ;; +# esac +# if [ -n "${id4x}" ]; then +# mount --bind /dev /mnt/dev +# chroot /mnt VBoxManage -q internalcommands createrawvmdk -filename \ +# ${OPENSLX_DEFAULT_CONFDIR}/plugins/virtualbox/raw.vmdk -rawdisk ${id4x} +# chmod 777 ${OPENSLX_DEFAULT_CONFDIR}/plugins/virtualbox/raw.vmdk +# umount -f /mnt/dev 2>/dev/null +# fi # copy and activate init file - cp /mnt/opt/openslx/plugin-repo/virtualbox/vbox-slx \ - /mnt/etc/init.d + cp ${PLUGINDIR}/vbox-slx /mnt/etc/init.d/ chmod 755 /mnt/etc/init.d/vbox-slx rllinker "vbox-slx" 20 2 mknod -m 0660 /dev/vboxdrv c 10 59 chown root:vboxusers /dev/vboxdrv + + # finished ... + [ $DEBUGLEVEL -gt 0 ] && echo "done with 'virtualbox' os-plugin ..." fi else - [ $DEBUGLEVEL -gt 0 ] && echo " * Configuration of virtualbox plugin failed" + [ $DEBUGLEVEL -gt 0 ] \ + && echo " * Configuration of 'virtualbox' plugin failed" fi |