1 |
#!/bin/bash |
#!/bin/bash |
2 |
# $Header: /root/magellan-cvs/src/virtualbox/virtualbox-config.sh,v 1.8 2008-03-22 20:19:30 niro Exp $ |
# $Header: /root/magellan-cvs/src/virtualbox/virtualbox-config.sh,v 1.9 2009-07-01 18:02:28 niro Exp $ |
3 |
# Configures virtualbox for Magellan-Linux |
# Configures virtualbox for Magellan-Linux |
4 |
|
|
5 |
LIBDIR=/usr/lib |
LIBDIR=/usr/lib |
6 |
INSTDIR=${LIBDIR}/virtualbox |
INSTDIR=${LIBDIR}/virtualbox |
7 |
VBOXMODULE=vboxdrv.ko |
VBOXMODULE=vboxdrv.ko |
8 |
|
VBOXNETMODULE=vboxnetflt.ko |
9 |
|
|
10 |
COLRED="\033[1;6m\033[31m" |
COLRED="\033[1;6m\033[31m" |
11 |
COLGREEN="\033[1;6m\033[32m" |
COLGREEN="\033[1;6m\033[32m" |
45 |
die "No kernel sources for kernel ${KERNEL_VERSION} found! Aborting." |
die "No kernel sources for kernel ${KERNEL_VERSION} found! Aborting." |
46 |
fi |
fi |
47 |
|
|
48 |
if [[ -f /lib/modules/${KERNEL_VERSION}/misc/${VBOXMODULE} ]] |
for module in ${VBOXMODULE} ${VBOXNETMODULE} |
49 |
then |
do |
50 |
mecho "Removing old module ..." |
if [[ -f /lib/modules/${KERNEL_VERSION}/misc/${module} ]] |
|
# try to unload the module |
|
|
if [[ -n $(grep "${VBOXMODULE} " /proc/modules 2> /dev/null) ]] |
|
51 |
then |
then |
52 |
modprobe -r ${VBOXMODULE/.ko/} |
mecho "Removing old ${module} module ..." |
53 |
|
# try to unload the modules |
54 |
|
if [[ -n $(grep "${module} " /proc/modules 2> /dev/null) ]] |
55 |
|
then |
56 |
|
modprobe -r ${module/.ko/} |
57 |
|
fi |
58 |
|
rm -f /lib/modules/${KERNEL_VERSION}/misc/${module} |
59 |
fi |
fi |
60 |
rm -f /lib/modules/${KERNEL_VERSION}/misc/${VBOXMODULE} |
done |
61 |
fi |
|
62 |
|
for module in ${VBOXMODULE} ${VBOXNETMODULE} |
63 |
|
do |
64 |
|
# compile the module |
65 |
|
cd ${INSTDIR}/src/${module/.ko/} |
66 |
|
|
67 |
# compile the module |
make -C ${KERNEL_SOURCES} SUBDIRS=$(pwd) SRCROOT=$(pwd) clean || die "mod-compile ${module}" |
68 |
cd ${INSTDIR}/src |
|
69 |
make -C ${KERNEL_SOURCES} SUBDIRS=$(pwd) SRCROOT=$(pwd) clean modules || die "mod-compile" |
# need some symver from vboxmodule (must be run after clean!) |
70 |
|
if [[ ${module} = ${VBOXNETMODULE} ]] && [[ -f ../${VBOXMODULE/.ko/}/Module.symvers ]] |
71 |
# install the module |
then |
72 |
install -d /lib/modules/${KERNEL_VERSION}/misc |
cp ../${VBOXMODULE/.ko/}/Module.symvers . |
73 |
install -m0644 ${VBOXMODULE} /lib/modules/${KERNEL_VERSION}/misc || die "mod-install" |
fi |
74 |
|
|
75 |
|
make -C ${KERNEL_SOURCES} SUBDIRS=$(pwd) SRCROOT=$(pwd) modules || die "mod-compile ${module}" |
76 |
|
|
77 |
|
# install the modules |
78 |
|
install -d /lib/modules/${KERNEL_VERSION}/misc |
79 |
|
install -m0644 ${module} /lib/modules/${KERNEL_VERSION}/misc || die "mod-install ${module}" |
80 |
|
done |
81 |
|
|
82 |
# calc module dependencies |
# calc module dependencies |
83 |
mecho "Calculating module dependencies ..." |
mecho "Calculating module dependencies ..." |
84 |
depmod -ae ${KERNEL_VERSION} |
depmod -ae ${KERNEL_VERSION} |
85 |
|
|
86 |
# re-read udev rules to grant the right permissions |
# re-read udev rules to grant the right permissions |
87 |
if [[ -x $(which udevcontrol) ]] |
if [[ -x $(which udevadm) ]] |
88 |
then |
then |
89 |
mecho "Reloading udev configuration ..." |
mecho "Reloading udev configuration ..." |
90 |
$(which udevcontrol) reload_rules |
$(which udevadm) control --reload-rules |
91 |
fi |
fi |
92 |
|
|
93 |
# load the module |
# load the module |
94 |
if [[ x$(uname -r) = x${KERNEL_VERSION} ]] |
if [[ x$(uname -r) = x${KERNEL_VERSION} ]] |
95 |
then |
then |
96 |
mecho "Loading kernel-module ${VBOXMODULE} ..." |
for module in ${VBOXMODULE} ${VBOXNETMODULE} |
97 |
modprobe $(basename ${VBOXMODULE} .ko) |
do |
98 |
|
mecho "Loading kernel-module ${module} ..." |
99 |
|
modprobe $(basename ${module} .ko) |
100 |
|
done |
101 |
else |
else |
102 |
echo -e ${COLRED} |
echo -e ${COLRED} |
103 |
echo "Your current running kernel does not match the the module target." |
echo "Your current running kernel does not match the the module target." |
104 |
echo "You must boot into your target kernel and load the module manually," |
echo "You must boot into your target kernel and load the modules manually," |
105 |
echo "before you can use virtual box." |
echo "before you can use virtual box." |
106 |
echo -en ${COLDEFAULT} |
echo -en ${COLDEFAULT} |
107 |
fi |
fi |