Annotation of /trunk/virtualbox/virtualbox-config.sh
Parent Directory | Revision Log
Revision 861 -
(hide annotations)
(download)
(as text)
Wed Jul 1 20:19:00 2009 UTC (15 years, 4 months ago) by niro
File MIME type: application/x-sh
File size: 3101 byte(s)
Wed Jul 1 20:19:00 2009 UTC (15 years, 4 months ago) by niro
File MIME type: application/x-sh
File size: 3101 byte(s)
-vitualbox versions (>3.0.0) has a new module vboxnetadp
1 | niro | 126 | #!/bin/bash |
2 | niro | 861 | # $Header: /root/magellan-cvs/src/virtualbox/virtualbox-config.sh,v 1.10 2009-07-01 20:19:00 niro Exp $ |
3 | niro | 126 | # Configures virtualbox for Magellan-Linux |
4 | |||
5 | LIBDIR=/usr/lib | ||
6 | INSTDIR=${LIBDIR}/virtualbox | ||
7 | VBOXMODULE=vboxdrv.ko | ||
8 | niro | 860 | VBOXNETMODULE=vboxnetflt.ko |
9 | niro | 861 | VBOXNETADPMODULE=vboxnetadp.ko |
10 | niro | 126 | |
11 | niro | 129 | COLRED="\033[1;6m\033[31m" |
12 | COLGREEN="\033[1;6m\033[32m" | ||
13 | COLDEFAULT="\033[0m" | ||
14 | |||
15 | if [[ ${NOCOLORS} = true ]] | ||
16 | niro | 127 | then |
17 | niro | 129 | COLRED="" |
18 | COLGREEN="" | ||
19 | COLDEFAULT="" | ||
20 | niro | 127 | fi |
21 | |||
22 | niro | 129 | die() { echo -e "${COLRED}$@${COLDEFAULT}"; exit 1; } |
23 | mecho() { echo -e "${COLGREEN}$@${COLDEFAULT}"; } | ||
24 | niro | 126 | |
25 | niro | 129 | # must be root |
26 | [[ $(id -u) != 0 ]] && die "You must be r00t!" | ||
27 | |||
28 | niro | 229 | # check for given argvs |
29 | for i in $* | ||
30 | do | ||
31 | case $1 in | ||
32 | --kernel-version) shift; KERNEL_VERSION="$1" ;; | ||
33 | --kernel-sources) shift; KERNEL_SOURCES="$1" ;; | ||
34 | esac | ||
35 | shift | ||
36 | done | ||
37 | niro | 129 | |
38 | niro | 229 | # some sane defaults |
39 | [[ -z ${KERNEL_VERSION} ]] && KERNEL_VERSION="$(uname -r)" | ||
40 | [[ -z ${KERNEL_SOURCES} ]] && KERNEL_SOURCES="/lib/modules/${KERNEL_VERSION}/source" | ||
41 | |||
42 | mecho "Running $(basename $0) for kernelversion ${KERNEL_VERSION} ..." | ||
43 | |||
44 | if [ ! -f ${KERNEL_SOURCES}/include/linux/version.h ] | ||
45 | niro | 126 | then |
46 | niro | 229 | die "No kernel sources for kernel ${KERNEL_VERSION} found! Aborting." |
47 | niro | 126 | fi |
48 | |||
49 | niro | 861 | for module in ${VBOXMODULE} ${VBOXNETMODULE} ${VBOXNETADPMODULE} |
50 | niro | 860 | do |
51 | if [[ -f /lib/modules/${KERNEL_VERSION}/misc/${module} ]] | ||
52 | niro | 520 | then |
53 | niro | 860 | mecho "Removing old ${module} module ..." |
54 | # try to unload the modules | ||
55 | if [[ -n $(grep "${module} " /proc/modules 2> /dev/null) ]] | ||
56 | then | ||
57 | modprobe -r ${module/.ko/} | ||
58 | fi | ||
59 | rm -f /lib/modules/${KERNEL_VERSION}/misc/${module} | ||
60 | niro | 520 | fi |
61 | niro | 860 | done |
62 | niro | 126 | |
63 | niro | 861 | for module in ${VBOXMODULE} ${VBOXNETMODULE} ${VBOXNETADPMODULE} |
64 | niro | 860 | do |
65 | # compile the module | ||
66 | cd ${INSTDIR}/src/${module/.ko/} | ||
67 | niro | 126 | |
68 | niro | 860 | make -C ${KERNEL_SOURCES} SUBDIRS=$(pwd) SRCROOT=$(pwd) clean || die "mod-compile ${module}" |
69 | niro | 126 | |
70 | niro | 860 | # need some symver from vboxmodule (must be run after clean!) |
71 | if [[ ${module} = ${VBOXNETMODULE} ]] && [[ -f ../${VBOXMODULE/.ko/}/Module.symvers ]] | ||
72 | then | ||
73 | cp ../${VBOXMODULE/.ko/}/Module.symvers . | ||
74 | fi | ||
75 | |||
76 | make -C ${KERNEL_SOURCES} SUBDIRS=$(pwd) SRCROOT=$(pwd) modules || die "mod-compile ${module}" | ||
77 | |||
78 | # install the modules | ||
79 | install -d /lib/modules/${KERNEL_VERSION}/misc | ||
80 | install -m0644 ${module} /lib/modules/${KERNEL_VERSION}/misc || die "mod-install ${module}" | ||
81 | done | ||
82 | |||
83 | niro | 126 | # calc module dependencies |
84 | niro | 129 | mecho "Calculating module dependencies ..." |
85 | niro | 229 | depmod -ae ${KERNEL_VERSION} |
86 | niro | 126 | |
87 | niro | 129 | # re-read udev rules to grant the right permissions |
88 | niro | 860 | if [[ -x $(which udevadm) ]] |
89 | niro | 129 | then |
90 | mecho "Reloading udev configuration ..." | ||
91 | niro | 860 | $(which udevadm) control --reload-rules |
92 | niro | 129 | fi |
93 | |||
94 | niro | 126 | # load the module |
95 | niro | 230 | if [[ x$(uname -r) = x${KERNEL_VERSION} ]] |
96 | niro | 229 | then |
97 | niro | 861 | for module in ${VBOXMODULE} ${VBOXNETMODULE} ${VBOXNETADPMODULE} |
98 | niro | 860 | do |
99 | mecho "Loading kernel-module ${module} ..." | ||
100 | modprobe $(basename ${module} .ko) | ||
101 | done | ||
102 | niro | 229 | else |
103 | echo -e ${COLRED} | ||
104 | echo "Your current running kernel does not match the the module target." | ||
105 | niro | 860 | echo "You must boot into your target kernel and load the modules manually," |
106 | niro | 229 | echo "before you can use virtual box." |
107 | echo -en ${COLDEFAULT} | ||
108 | fi | ||
109 | niro | 126 | |
110 | echo | ||
111 | niro | 129 | mecho "Virtualbox is now configured for your system." |
112 | niro | 313 | mecho "Do not forget to add your users to the 'virtualbox' group." |
113 | niro | 126 | echo |
114 | |||
115 | exit 0 |