Magellan Linux

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

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

revision 988 by niro, Sun Feb 21 20:06:45 2010 UTC revision 1672 by niro, Sat Mar 3 02:48:55 2012 UTC
# Line 1  Line 1 
1  #!/bin/bash  #!/bin/bash
2  # $Header: /root/magellan-cvs/src/virtualbox/virtualbox-config.sh,v 1.12 2010-02-21 20:06:45 niro Exp $  # $Id$
3  # Configures virtualbox for Magellan-Linux  # Configures virtualbox for Magellan-Linux
4    
5  LIBDIR=/usr/lib  # get INSTALL_DIR location
6  INSTDIR=${LIBDIR}/virtualbox  source /etc/vbox/vbox.cfg
7  VBOXMODULE=vboxdrv.ko  
8  VBOXNETMODULE=vboxnetflt.ko  VBOXVERSION="$(< ${INSTALL_DIR}/version)"
9  VBOXNETADPMODULE=vboxnetadp.ko  VBOXMODEXT=ko
10    VBOXMODULE=vboxdrv
11    VBOXNETMODULE=vboxnetflt
12    VBOXNETADPMODULE=vboxnetadp
13    VBOXPCIMODULE=vboxpci
14    KERNELMODULES="${VBOXMODULE} ${VBOXNETMODULE} ${VBOXNETADPMODULE} ${VBOXPCIMODULE}"
15    
16  COLRED="\033[1;6m\033[31m"  COLRED="\033[1;6m\033[31m"
17  COLGREEN="\033[1;6m\033[32m"  COLGREEN="\033[1;6m\033[32m"
# Line 41  done Line 46  done
46    
47  mecho "Running $(basename $0) for kernelversion ${KERNEL_VERSION} ..."  mecho "Running $(basename $0) for kernelversion ${KERNEL_VERSION} ..."
48    
49  if [ ! -f ${KERNEL_SOURCES}/include/linux/version.h ]  # check module version and recompile if it doesen't fit else break here
50  then  compile="yes"
51   die "No kernel sources for kernel ${KERNEL_VERSION} found! Aborting."  for module in ${KERNELMODULES}
52  fi  do
53     if [[ -f /lib/modules/${KERNEL_VERSION}/misc/${module}.${VBOXMODEXT} ]]
54     then
55     myver=$(modinfo -k ${KERNEL_VERSION} -F version ${module} | sed "s:\(.*\)_.*:\1:")
56     if [[ ${VBOXVERSION} = ${myver} ]]
57     then
58     compile="no"
59     fi
60    done
61    
62  for module in ${VBOXMODULE} ${VBOXNETMODULE} ${VBOXNETADPMODULE}  for module in ${KERNELMODULES}
63  do  do
64   if [[ -f /lib/modules/${KERNEL_VERSION}/misc/${module} ]]   if [[ -f /lib/modules/${KERNEL_VERSION}/misc/${module}.${VBOXMODEXT} ]]
65   then   then
  mecho "Removing old ${module} module ..."  
66   # try to unload the modules   # try to unload the modules
67   if [[ -n $(grep "${module} " /proc/modules 2> /dev/null) ]]   if [[ -n $(grep "${module} " /proc/modules 2> /dev/null) ]]
68   then   then
69   modprobe -r ${module/.ko/}   mecho "Unloading ${module} module ..."
70     modprobe -r ${module}
71   fi   fi
  rm -f /lib/modules/${KERNEL_VERSION}/misc/${module}  
72   fi   fi
73  done  done
74    
75  for module in ${VBOXMODULE} ${VBOXNETMODULE} ${VBOXNETADPMODULE}  if [[ ${compile} = yes ]]
76  do  then
77   # compile the module   if [ ! -f ${KERNEL_SOURCES}/include/linux/version.h ]
  cd ${INSTDIR}/src/${module/.ko/}  
   
  make -C ${KERNEL_SOURCES} SUBDIRS=$(pwd) SRCROOT=$(pwd) clean || die "mod-compile ${module}"  
   
  # need some symver from vboxmodule (must be run after clean!)  
  if [[ ${module} = ${VBOXNETMODULE} ]] || [[ ${module} = ${VBOXNETADPMODULE} ]]  
78   then   then
79   [[ -f ../${VBOXMODULE/.ko/}/Module.symvers ]] && cp ../${VBOXMODULE/.ko/}/Module.symvers .   die "No kernel sources for kernel ${KERNEL_VERSION} found! Aborting."
80   fi   fi
81    
82   make -C ${KERNEL_SOURCES} SUBDIRS=$(pwd) SRCROOT=$(pwd) modules || die "mod-compile ${module}"   for module in ${KERNELMODULES}
83     do
84     if [[ -f /lib/modules/${KERNEL_VERSION}/misc/${module}.${VBOXMODEXT} ]]
85     then
86     mecho "Removing old ${module} module ..."
87     rm -f /lib/modules/${KERNEL_VERSION}/misc/${module}.${VBOXMODEXT}
88     fi
89     done
90    
91   # install the modules   # compile the modules
92   install -d /lib/modules/${KERNEL_VERSION}/misc   pushd ${INSTALL_DIR}/src
93   install -m0644 ${module} /lib/modules/${KERNEL_VERSION}/misc || die "mod-install ${module}"   for module in ${KERNELMODULES}
94  done   do
95     make -C ${module} KBUILD_VERBOSE=1 clean || die "mod-compile ${module}"
96    
97  # calc module dependencies   # need some symver from vboxmodule (must be run after clean!)
98  mecho "Calculating module dependencies ..."   if [[ ${module} = ${VBOXNETMODULE} ]] ||
99  depmod -a ${KERNEL_VERSION}   [[ ${module} = ${VBOXNETADPMODULE} ]] ||
100     [[ ${module} = ${VBOXPCIMODULE} ]]
101     then
102     [[ -f ${VBOXMODULE}/Module.symvers ]] && cp ${VBOXMODULE}/Module.symvers ${module}
103     fi
104    
105  # re-read udev rules to grant the right permissions   make -C ${module} KBUILD_VERBOSE=1 || die "mod-compile ${module}"
106  if [[ -x $(which udevadm) ]]  
107  then   # install the modules
108   mecho "Reloading udev configuration ..."   install -d /lib/modules/${KERNEL_VERSION}/misc
109   $(which udevadm) control --reload-rules   install -m0644 ${module}/${module}.${VBOXMODEXT} /lib/modules/${KERNEL_VERSION}/misc || die "mod-install ${module}"
110    
111     # clean up
112     make -C ${module} KBUILD_VERBOSE=1 clean || die "mod-compile ${module}"
113     done
114     popd
115    
116     # calc module dependencies
117     mecho "Calculating module dependencies ..."
118     depmod -a ${KERNEL_VERSION}
119    
120     # re-read udev rules to grant the right permissions
121     if [[ -x $(which udevadm) ]]
122     then
123     mecho "Reloading udev configuration ..."
124     udevadm control --reload-rules
125     fi
126  fi  fi
127    
128  # load the module  # load the module
129  if [[ x$(uname -r) = x${KERNEL_VERSION} ]]  if [[ x$(uname -r) = x${KERNEL_VERSION} ]]
130  then  then
131   for module in ${VBOXMODULE} ${VBOXNETMODULE} ${VBOXNETADPMODULE}   for module in ${KERNELMODULES}
132   do   do
133   mecho "Loading kernel-module ${module} ..."   mecho "Loading kernel-module ${module} ..."
134   modprobe $(basename ${module} .ko)   modprobe ${module}
135   done   done
136    
137   if [ $(echo ${KERNEL_VERSION%%-*} | sed 's:\.::g') -ge 2631 ]   if [ $(echo ${KERNEL_VERSION%%-*} | sed 's:\.::g') -ge 2639 ]
138     then
139     # fixes NMI warnings with kernels >=2.6.31:
140     # vboxdrv: Warning: 2.6.31+ kernel detected. Most likely the hardware performance
141     # vboxdrv: counter framework which can generate NMIs is active.
142     mecho "Disabled hardware performance counter NMIs ..."
143     echo 2 > /proc/sys/kernel/perf_event_paranoid
144    
145     elif [ $(echo ${KERNEL_VERSION%%-*} | sed 's:\.::g') -ge 2631 ]
146   then   then
147   # fixes NMI warnings with kernels >=2.6.31:   # fixes NMI warnings with kernels >=2.6.31:
148   # vboxdrv: Warning: 2.6.31+ kernel detected. Most likely the hardware performance   # vboxdrv: Warning: 2.6.31+ kernel detected. Most likely the hardware performance
# Line 118  fi Line 160  fi
160    
161  echo  echo
162  mecho "Virtualbox is now configured for your system."  mecho "Virtualbox is now configured for your system."
163  mecho "Do not forget to add your users to the 'virtualbox' group."  mecho "Do not forget to add your users to the 'vboxusers' group."
164  echo  echo
165    
166  exit 0  exit 0

Legend:
Removed from v.988  
changed lines
  Added in v.1672