Magellan Linux

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

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

revision 129 by niro, Sat Apr 14 14:10:48 2007 UTC revision 520 by niro, Sat Mar 22 20:19:30 2008 UTC
# Line 1  Line 1 
1  #!/bin/bash  #!/bin/bash
2  # $Header: /root/magellan-cvs/src/virtualbox/virtualbox-config.sh,v 1.3 2007-04-14 14:10:48 niro Exp $  # $Header: /root/magellan-cvs/src/virtualbox/virtualbox-config.sh,v 1.8 2008-03-22 20:19:30 niro Exp $
3  # Configures virtualbox for Magellan-Linux  # Configures virtualbox for Magellan-Linux
4    
5  LIBDIR=/usr/lib  LIBDIR=/usr/lib
# Line 23  mecho() { echo -e "${COLGREEN}$@${COLDEF Line 23  mecho() { echo -e "${COLGREEN}$@${COLDEF
23  # must be root  # must be root
24  [[ $(id -u) != 0 ]] && die "You must be r00t!"  [[ $(id -u) != 0 ]] && die "You must be r00t!"
25    
26  mecho "Running $(basename $0) for kernelversion $(uname -r) ..."  # 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   die "No kernel headers for $(uname -r) found! Aborting."   die "No kernel sources for kernel ${KERNEL_VERSION} found! Aborting."
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   mecho "Removing old module ..."   mecho "Removing old module ..."
50   rm -f /lib/modules/$(uname -r)/misc/${VBOXMODULE}   # try to unload the module
51     if [[ -n $(grep "${VBOXMODULE} " /proc/modules 2> /dev/null) ]]
52     then
53     modprobe -r ${VBOXMODULE/.ko/}
54     fi
55     rm -f /lib/modules/${KERNEL_VERSION}/misc/${VBOXMODULE}
56  fi  fi
57    
58  # compile the module  # compile the module
59  cd ${INSTDIR}/src  cd ${INSTDIR}/src
60  make -C /lib/modules/$(uname -r)/source SUBDIRS=$(pwd) SRCROOT=$(pwd) clean modules || die "mod-compile"  make -C ${KERNEL_SOURCES} SUBDIRS=$(pwd) SRCROOT=$(pwd) clean modules || die "mod-compile"
61    
62  # install the module  # install the module
63  install -d /lib/modules/$(uname -r)/misc  install -d /lib/modules/${KERNEL_VERSION}/misc
64  install -m0644 ${VBOXMODULE} /lib/modules/$(uname -r)/misc || die "mod-install"  install -m0644 ${VBOXMODULE} /lib/modules/${KERNEL_VERSION}/misc || die "mod-install"
65    
66  # calc module dependencies  # calc module dependencies
67  mecho "Calculating module dependencies ..."  mecho "Calculating module dependencies ..."
68  depmod -ae  depmod -ae ${KERNEL_VERSION}
69    
70  # re-read udev rules to grant the right permissions  # re-read udev rules to grant the right permissions
71  if [[ -x $(which udevcontrol) ]]  if [[ -x $(which udevcontrol) ]]
72  then  then
73   mecho "Reloading udev configuration ..."   mecho "Reloading udev configuration ..."
74   $(which udevcontrol) reload_config   $(which udevcontrol) reload_rules
75  fi  fi
76    
77  # load the module  # load the module
78  mecho "Loading kernel-module ${VBOXMODULE} ..."  if [[ x$(uname -r) = x${KERNEL_VERSION} ]]
79  modprobe $(basename ${VBOXMODULE} .ko)  then
80     mecho "Loading kernel-module ${VBOXMODULE} ..."
81     modprobe $(basename ${VBOXMODULE} .ko)
82    else
83     echo -e ${COLRED}
84     echo "Your current running kernel does not match the the module target."
85     echo "You must boot into your target kernel and load the module manually,"
86     echo "before you can use virtual box."
87     echo -en ${COLDEFAULT}
88    fi
89    
90  echo  echo
91  mecho "Virtualbox is now configured for your system."  mecho "Virtualbox is now configured for your system."
92  mecho "Do not forget to add you users to the 'virtualbox' group."  mecho "Do not forget to add your users to the 'virtualbox' group."
93  echo  echo
94    
95  exit 0  exit 0

Legend:
Removed from v.129  
changed lines
  Added in v.520