Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 127 by niro, Fri Apr 13 22:51:43 2007 UTC revision 313 by niro, Sun Aug 19 03:05:05 2007 UTC
# Line 1  Line 1 
1  #!/bin/bash  #!/bin/bash
2  # $Header: /root/magellan-cvs/src/virtualbox/virtualbox-config.sh,v 1.2 2007-04-13 22:51:43 niro Exp $  # $Header: /root/magellan-cvs/src/virtualbox/virtualbox-config.sh,v 1.7 2007-08-19 03:05:05 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    
9  if [[ $(id -u) != 0 ]]  COLRED="\033[1;6m\033[31m"
10    COLGREEN="\033[1;6m\033[32m"
11    COLDEFAULT="\033[0m"
12    
13    if [[ ${NOCOLORS} = true ]]
14  then  then
15   echo "You must be r00t!"   COLRED=""
16   exit 1   COLGREEN=""
17     COLDEFAULT=""
18  fi  fi
19    
20  echo "Running $(basename $0) for kernelversion $(uname -r) ..."  die() { echo -e "${COLRED}$@${COLDEFAULT}"; exit 1; }
21    mecho() { echo -e "${COLGREEN}$@${COLDEFAULT}"; }
22    
23    # must be root
24    [[ $(id -u) != 0 ]] && die "You must be r00t!"
25    
26    # 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    
36    # some sane defaults
37    [[ -z ${KERNEL_VERSION} ]] && KERNEL_VERSION="$(uname -r)"
38    [[ -z ${KERNEL_SOURCES} ]] && KERNEL_SOURCES="/lib/modules/${KERNEL_VERSION}/source"
39    
40  if [ ! -f /lib/modules/$(uname -r)/source/include/linux/version.h ]  mecho "Running $(basename $0) for kernelversion ${KERNEL_VERSION} ..."
41    
42    if [ ! -f ${KERNEL_SOURCES}/include/linux/version.h ]
43  then  then
44   echo "No includes for $(uname -r) found! Aborting."   die "No kernel sources for kernel ${KERNEL_VERSION} found! Aborting."
  exit 1  
45  fi  fi
46    
47  if [[ -f /lib/modules/$(uname -r)/misc/${VBOXMODULE} ]]  if [[ -f /lib/modules/${KERNEL_VERSION}/misc/${VBOXMODULE} ]]
48  then  then
49   echo "Removing old module ..."   mecho "Removing old module ..."
50   rm -f /lib/modules/$(uname -r)/misc/${VBOXMODULE}   rm -f /lib/modules/${KERNEL_VERSION}/misc/${VBOXMODULE}
51  fi  fi
52    
53  # compile the module  # compile the module
54  cd ${INSTDIR}/src  cd ${INSTDIR}/src
55  make -C /lib/modules/$(uname -r)/source SUBDIRS=$(pwd) SRCROOT=$(pwd) clean modules  make -C ${KERNEL_SOURCES} SUBDIRS=$(pwd) SRCROOT=$(pwd) clean modules || die "mod-compile"
56    
57  # install the module  # install the module
58  install -d /lib/modules/$(uname -r)/misc  install -d /lib/modules/${KERNEL_VERSION}/misc
59  install -m0644 ${VBOXMODULE} /lib/modules/$(uname -r)/misc  install -m0644 ${VBOXMODULE} /lib/modules/${KERNEL_VERSION}/misc || die "mod-install"
60    
61  # calc module dependencies  # calc module dependencies
62  depmod -ae  mecho "Calculating module dependencies ..."
63    depmod -ae ${KERNEL_VERSION}
64    
65    # re-read udev rules to grant the right permissions
66    if [[ -x $(which udevcontrol) ]]
67    then
68     mecho "Reloading udev configuration ..."
69     $(which udevcontrol) reload_rules
70    fi
71    
72  # load the module  # load the module
73  echo "Loading module ${VBOXMODULE} ..."  if [[ x$(uname -r) = x${KERNEL_VERSION} ]]
74  modprobe $(basename ${VBOXMODULE} .ko)  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    
85  echo  echo
86  echo "Virtualbox is now configured for your system."  mecho "Virtualbox is now configured for your system."
87  echo "Do not forget to add you users to the 'virtualbox' group."  mecho "Do not forget to add your users to the 'virtualbox' group."
88  echo  echo
89    
90  exit 0  exit 0

Legend:
Removed from v.127  
changed lines
  Added in v.313