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 1406 by niro, Mon Jul 4 16:53:05 2011 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 $  # $Header: /root/magellan-cvs/src/virtualbox/virtualbox-config.sh,v 1.13 2010-06-09 22:29:52 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  VBOXVERSION="$(< ${INSTDIR}/version)"
8  VBOXNETMODULE=vboxnetflt.ko  VBOXMODEXT=ko
9  VBOXNETADPMODULE=vboxnetadp.ko  VBOXMODULE=vboxdrv
10    VBOXNETMODULE=vboxnetflt
11    VBOXNETADPMODULE=vboxnetadp
12    
13  COLRED="\033[1;6m\033[31m"  COLRED="\033[1;6m\033[31m"
14  COLGREEN="\033[1;6m\033[32m"  COLGREEN="\033[1;6m\033[32m"
# Line 41  done Line 43  done
43    
44  mecho "Running $(basename $0) for kernelversion ${KERNEL_VERSION} ..."  mecho "Running $(basename $0) for kernelversion ${KERNEL_VERSION} ..."
45    
46  if [ ! -f ${KERNEL_SOURCES}/include/linux/version.h ]  # check module version an recompile if it doesen't fit else break here
47  then  compile="no"
  die "No kernel sources for kernel ${KERNEL_VERSION} found! Aborting."  
 fi  
   
48  for module in ${VBOXMODULE} ${VBOXNETMODULE} ${VBOXNETADPMODULE}  for module in ${VBOXMODULE} ${VBOXNETMODULE} ${VBOXNETADPMODULE}
49  do  do
50   if [[ -f /lib/modules/${KERNEL_VERSION}/misc/${module} ]]   myver=$(modinfo -k ${KERNEL_VERSION} -F version ${module} | sed "s:\(.*\)_.*:\1:")
51     if [[ ${VBOXVERSION} != ${myver} ]]
52     then
53     compile="yes"
54     fi
55    done
56    
57    for module in ${VBOXNETADPMODULE} ${VBOXNETMODULE} ${VBOXMODULE}
58    do
59     if [[ -f /lib/modules/${KERNEL_VERSION}/misc/${module}.${VBOXMODEXT} ]]
60   then   then
  mecho "Removing old ${module} module ..."  
61   # try to unload the modules   # try to unload the modules
62   if [[ -n $(grep "${module} " /proc/modules 2> /dev/null) ]]   if [[ -n $(grep "${module} " /proc/modules 2> /dev/null) ]]
63   then   then
64   modprobe -r ${module/.ko/}   mecho "Unloading ${module} module ..."
65     modprobe -r ${module}
66   fi   fi
  rm -f /lib/modules/${KERNEL_VERSION}/misc/${module}  
67   fi   fi
68  done  done
69    
70  for module in ${VBOXMODULE} ${VBOXNETMODULE} ${VBOXNETADPMODULE}  if [[ ${compile} = yes ]]
71  do  then
72   # 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} ]]  
73   then   then
74   [[ -f ../${VBOXMODULE/.ko/}/Module.symvers ]] && cp ../${VBOXMODULE/.ko/}/Module.symvers .   die "No kernel sources for kernel ${KERNEL_VERSION} found! Aborting."
75   fi   fi
76    
77   make -C ${KERNEL_SOURCES} SUBDIRS=$(pwd) SRCROOT=$(pwd) modules || die "mod-compile ${module}"   for module in ${VBOXMODULE} ${VBOXNETMODULE} ${VBOXNETADPMODULE}
78     do
79     if [[ -f /lib/modules/${KERNEL_VERSION}/misc/${module}.${VBOXMODEXT} ]]
80     then
81     mecho "Removing old ${module} module ..."
82     rm -f /lib/modules/${KERNEL_VERSION}/misc/${module}.${VBOXMODEXT}
83     fi
84     done
85    
86     for module in ${VBOXMODULE} ${VBOXNETMODULE} ${VBOXNETADPMODULE}
87     do
88     # compile the module
89     cd ${INSTDIR}/src/${module}
90    
91     make -C ${KERNEL_SOURCES} SUBDIRS=$(pwd) SRCROOT=$(pwd) clean || die "mod-compile ${module}"
92    
93   # install the modules   # need some symver from vboxmodule (must be run after clean!)
94   install -d /lib/modules/${KERNEL_VERSION}/misc   if [[ ${module} = ${VBOXNETMODULE} ]] || [[ ${module} = ${VBOXNETADPMODULE} ]]
95   install -m0644 ${module} /lib/modules/${KERNEL_VERSION}/misc || die "mod-install ${module}"   then
96  done   [[ -f ../${VBOXMODULE}/Module.symvers ]] && cp ../${VBOXMODULE}/Module.symvers .
97     fi
98    
99  # calc module dependencies   make -C ${KERNEL_SOURCES} SUBDIRS=$(pwd) SRCROOT=$(pwd) modules || die "mod-compile ${module}"
 mecho "Calculating module dependencies ..."  
 depmod -a ${KERNEL_VERSION}  
100    
101  # re-read udev rules to grant the right permissions   # install the modules
102  if [[ -x $(which udevadm) ]]   install -d /lib/modules/${KERNEL_VERSION}/misc
103  then   install -m0644 ${module}.${VBOXMODEXT} /lib/modules/${KERNEL_VERSION}/misc || die "mod-install ${module}"
104   mecho "Reloading udev configuration ..."   done
105   $(which udevadm) control --reload-rules  
106     # calc module dependencies
107     mecho "Calculating module dependencies ..."
108     depmod -a ${KERNEL_VERSION}
109    
110     # re-read udev rules to grant the right permissions
111     if [[ -x $(which udevadm) ]]
112     then
113     mecho "Reloading udev configuration ..."
114     $(which udevadm) control --reload-rules
115     fi
116  fi  fi
117    
118  # load the module  # load the module
# Line 97  then Line 121  then
121   for module in ${VBOXMODULE} ${VBOXNETMODULE} ${VBOXNETADPMODULE}   for module in ${VBOXMODULE} ${VBOXNETMODULE} ${VBOXNETADPMODULE}
122   do   do
123   mecho "Loading kernel-module ${module} ..."   mecho "Loading kernel-module ${module} ..."
124   modprobe $(basename ${module} .ko)   modprobe ${module}
125   done   done
126    
127   if [ $(echo ${KERNEL_VERSION%%-*} | sed 's:\.::g') -ge 2631 ]   if [ $(echo ${KERNEL_VERSION%%-*} | sed 's:\.::g') -ge 2639 ]
128     then
129     # fixes NMI warnings with kernels >=2.6.31:
130     # vboxdrv: Warning: 2.6.31+ kernel detected. Most likely the hardware performance
131     # vboxdrv: counter framework which can generate NMIs is active.
132     mecho "Disabled hardware performance counter NMIs ..."
133     echo 2 > /proc/sys/kernel/perf_event_paranoid
134    
135     elif [ $(echo ${KERNEL_VERSION%%-*} | sed 's:\.::g') -ge 2631 ]
136   then   then
137   # fixes NMI warnings with kernels >=2.6.31:   # fixes NMI warnings with kernels >=2.6.31:
138   # 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 150  fi
150    
151  echo  echo
152  mecho "Virtualbox is now configured for your system."  mecho "Virtualbox is now configured for your system."
153  mecho "Do not forget to add your users to the 'virtualbox' group."  mecho "Do not forget to add your users to the 'vboxusers' group."
154  echo  echo
155    
156  exit 0  exit 0

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