Magellan Linux

Annotation of /trunk/virtualbox/virtualbox-config.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 129 - (hide annotations) (download) (as text)
Sat Apr 14 14:10:48 2007 UTC (17 years, 1 month ago) by niro
File MIME type: application/x-sh
File size: 1686 byte(s)
- colored messages
- reload udev_configuration

1 niro 126 #!/bin/bash
2 niro 129 # $Header: /root/magellan-cvs/src/virtualbox/virtualbox-config.sh,v 1.3 2007-04-14 14:10:48 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     mecho "Running $(basename $0) for kernelversion $(uname -r) ..."
27    
28 niro 126 if [ ! -f /lib/modules/$(uname -r)/source/include/linux/version.h ]
29     then
30 niro 129 die "No kernel headers for $(uname -r) found! Aborting."
31 niro 126 fi
32    
33     if [[ -f /lib/modules/$(uname -r)/misc/${VBOXMODULE} ]]
34     then
35 niro 129 mecho "Removing old module ..."
36 niro 126 rm -f /lib/modules/$(uname -r)/misc/${VBOXMODULE}
37     fi
38    
39     # compile the module
40     cd ${INSTDIR}/src
41 niro 129 make -C /lib/modules/$(uname -r)/source SUBDIRS=$(pwd) SRCROOT=$(pwd) clean modules || die "mod-compile"
42 niro 126
43     # install the module
44     install -d /lib/modules/$(uname -r)/misc
45 niro 129 install -m0644 ${VBOXMODULE} /lib/modules/$(uname -r)/misc || die "mod-install"
46 niro 126
47     # calc module dependencies
48 niro 129 mecho "Calculating module dependencies ..."
49 niro 126 depmod -ae
50    
51 niro 129 # re-read udev rules to grant the right permissions
52     if [[ -x $(which udevcontrol) ]]
53     then
54     mecho "Reloading udev configuration ..."
55     $(which udevcontrol) reload_config
56     fi
57    
58 niro 126 # load the module
59 niro 129 mecho "Loading kernel-module ${VBOXMODULE} ..."
60 niro 126 modprobe $(basename ${VBOXMODULE} .ko)
61    
62     echo
63 niro 129 mecho "Virtualbox is now configured for your system."
64     mecho "Do not forget to add you users to the 'virtualbox' group."
65 niro 126 echo
66    
67     exit 0