--- trunk/virtualbox/virtualbox-config.sh 2007/04/14 14:54:32 131 +++ trunk/virtualbox/virtualbox-config.sh 2007/06/28 16:48:21 229 @@ -1,5 +1,5 @@ #!/bin/bash -# $Header: /root/magellan-cvs/src/virtualbox/virtualbox-config.sh,v 1.4 2007-04-14 14:54:32 niro Exp $ +# $Header: /root/magellan-cvs/src/virtualbox/virtualbox-config.sh,v 1.5 2007-06-28 16:48:21 niro Exp $ # Configures virtualbox for Magellan-Linux LIBDIR=/usr/lib @@ -23,30 +23,44 @@ # must be root [[ $(id -u) != 0 ]] && die "You must be r00t!" -mecho "Running $(basename $0) for kernelversion $(uname -r) ..." +# check for given argvs +for i in $* +do + case $1 in + --kernel-version) shift; KERNEL_VERSION="$1" ;; + --kernel-sources) shift; KERNEL_SOURCES="$1" ;; + esac + shift +done + +# some sane defaults +[[ -z ${KERNEL_VERSION} ]] && KERNEL_VERSION="$(uname -r)" +[[ -z ${KERNEL_SOURCES} ]] && KERNEL_SOURCES="/lib/modules/${KERNEL_VERSION}/source" -if [ ! -f /lib/modules/$(uname -r)/source/include/linux/version.h ] +mecho "Running $(basename $0) for kernelversion ${KERNEL_VERSION} ..." + +if [ ! -f ${KERNEL_SOURCES}/include/linux/version.h ] then - die "No kernel headers for $(uname -r) found! Aborting." + die "No kernel sources for kernel ${KERNEL_VERSION} found! Aborting." fi -if [[ -f /lib/modules/$(uname -r)/misc/${VBOXMODULE} ]] +if [[ -f /lib/modules/${KERNEL_VERSION}/misc/${VBOXMODULE} ]] then mecho "Removing old module ..." - rm -f /lib/modules/$(uname -r)/misc/${VBOXMODULE} + rm -f /lib/modules/${KERNEL_VERSION}/misc/${VBOXMODULE} fi # compile the module cd ${INSTDIR}/src -make -C /lib/modules/$(uname -r)/source SUBDIRS=$(pwd) SRCROOT=$(pwd) clean modules || die "mod-compile" +make -C ${KERNEL_SOURCES} SUBDIRS=$(pwd) SRCROOT=$(pwd) clean modules || die "mod-compile" # install the module -install -d /lib/modules/$(uname -r)/misc -install -m0644 ${VBOXMODULE} /lib/modules/$(uname -r)/misc || die "mod-install" +install -d /lib/modules/${KERNEL_VERSION}/misc +install -m0644 ${VBOXMODULE} /lib/modules/${KERNEL_VERSION}/misc || die "mod-install" # calc module dependencies mecho "Calculating module dependencies ..." -depmod -ae +depmod -ae ${KERNEL_VERSION} # re-read udev rules to grant the right permissions if [[ -x $(which udevcontrol) ]] @@ -56,8 +70,17 @@ fi # load the module -mecho "Loading kernel-module ${VBOXMODULE} ..." -modprobe $(basename ${VBOXMODULE} .ko) +if [[ xx$(uname -r) = x${KERNEL_VERSION} ]] +then + mecho "Loading kernel-module ${VBOXMODULE} ..." + modprobe $(basename ${VBOXMODULE} .ko) +else + echo -e ${COLRED} + echo "Your current running kernel does not match the the module target." + echo "You must boot into your target kernel and load the module manually," + echo "before you can use virtual box." + echo -en ${COLDEFAULT} +fi echo mecho "Virtualbox is now configured for your system."