Annotation of /trunk/virtualbox/virtualbox-config.sh
Parent Directory | Revision Log
Revision 313 -
(hide annotations)
(download)
(as text)
Sun Aug 19 03:05:05 2007 UTC (17 years, 2 months ago) by niro
File MIME type: application/x-sh
File size: 2347 byte(s)
Sun Aug 19 03:05:05 2007 UTC (17 years, 2 months ago) by niro
File MIME type: application/x-sh
File size: 2347 byte(s)
-fixed a spelling typo
1 | niro | 126 | #!/bin/bash |
2 | niro | 313 | # $Header: /root/magellan-cvs/src/virtualbox/virtualbox-config.sh,v 1.7 2007-08-19 03:05:05 niro Exp $ |
3 | niro | 126 | # Configures virtualbox for Magellan-Linux |
4 | |||
5 | LIBDIR=/usr/lib | ||
6 | INSTDIR=${LIBDIR}/virtualbox | ||
7 | VBOXMODULE=vboxdrv.ko | ||
8 | |||
9 | niro | 129 | COLRED="\033[1;6m\033[31m" |
10 | COLGREEN="\033[1;6m\033[32m" | ||
11 | COLDEFAULT="\033[0m" | ||
12 | |||
13 | if [[ ${NOCOLORS} = true ]] | ||
14 | niro | 127 | then |
15 | niro | 129 | COLRED="" |
16 | COLGREEN="" | ||
17 | COLDEFAULT="" | ||
18 | niro | 127 | fi |
19 | |||
20 | niro | 129 | die() { echo -e "${COLRED}$@${COLDEFAULT}"; exit 1; } |
21 | mecho() { echo -e "${COLGREEN}$@${COLDEFAULT}"; } | ||
22 | niro | 126 | |
23 | niro | 129 | # must be root |
24 | [[ $(id -u) != 0 ]] && die "You must be r00t!" | ||
25 | |||
26 | niro | 229 | # check for given argvs |
27 | for i in $* | ||
28 | do | ||
29 | case $1 in | ||
30 | --kernel-version) shift; KERNEL_VERSION="$1" ;; | ||
31 | --kernel-sources) shift; KERNEL_SOURCES="$1" ;; | ||
32 | esac | ||
33 | shift | ||
34 | done | ||
35 | niro | 129 | |
36 | niro | 229 | # some sane defaults |
37 | [[ -z ${KERNEL_VERSION} ]] && KERNEL_VERSION="$(uname -r)" | ||
38 | [[ -z ${KERNEL_SOURCES} ]] && KERNEL_SOURCES="/lib/modules/${KERNEL_VERSION}/source" | ||
39 | |||
40 | mecho "Running $(basename $0) for kernelversion ${KERNEL_VERSION} ..." | ||
41 | |||
42 | if [ ! -f ${KERNEL_SOURCES}/include/linux/version.h ] | ||
43 | niro | 126 | then |
44 | niro | 229 | die "No kernel sources for kernel ${KERNEL_VERSION} found! Aborting." |
45 | niro | 126 | fi |
46 | |||
47 | niro | 229 | if [[ -f /lib/modules/${KERNEL_VERSION}/misc/${VBOXMODULE} ]] |
48 | niro | 126 | then |
49 | niro | 129 | mecho "Removing old module ..." |
50 | niro | 229 | rm -f /lib/modules/${KERNEL_VERSION}/misc/${VBOXMODULE} |
51 | niro | 126 | fi |
52 | |||
53 | # compile the module | ||
54 | cd ${INSTDIR}/src | ||
55 | niro | 229 | make -C ${KERNEL_SOURCES} SUBDIRS=$(pwd) SRCROOT=$(pwd) clean modules || die "mod-compile" |
56 | niro | 126 | |
57 | # install the module | ||
58 | niro | 229 | install -d /lib/modules/${KERNEL_VERSION}/misc |
59 | install -m0644 ${VBOXMODULE} /lib/modules/${KERNEL_VERSION}/misc || die "mod-install" | ||
60 | niro | 126 | |
61 | # calc module dependencies | ||
62 | niro | 129 | mecho "Calculating module dependencies ..." |
63 | niro | 229 | depmod -ae ${KERNEL_VERSION} |
64 | niro | 126 | |
65 | niro | 129 | # re-read udev rules to grant the right permissions |
66 | if [[ -x $(which udevcontrol) ]] | ||
67 | then | ||
68 | mecho "Reloading udev configuration ..." | ||
69 | niro | 131 | $(which udevcontrol) reload_rules |
70 | niro | 129 | fi |
71 | |||
72 | niro | 126 | # load the module |
73 | niro | 230 | if [[ x$(uname -r) = x${KERNEL_VERSION} ]] |
74 | niro | 229 | then |
75 | mecho "Loading kernel-module ${VBOXMODULE} ..." | ||
76 | modprobe $(basename ${VBOXMODULE} .ko) | ||
77 | else | ||
78 | echo -e ${COLRED} | ||
79 | echo "Your current running kernel does not match the the module target." | ||
80 | echo "You must boot into your target kernel and load the module manually," | ||
81 | echo "before you can use virtual box." | ||
82 | echo -en ${COLDEFAULT} | ||
83 | fi | ||
84 | niro | 126 | |
85 | echo | ||
86 | niro | 129 | mecho "Virtualbox is now configured for your system." |
87 | niro | 313 | mecho "Do not forget to add your users to the 'virtualbox' group." |
88 | niro | 126 | echo |
89 | |||
90 | exit 0 |