updated on Thu Jan 12 04:00:44 UTC 2012
[aur-mirror.git] / virtualbox_bin-3 / vboxdrv
blob5e526a79fa8fbd7943d738046a4fb4384f2eff37
1 #!/bin/bash
3 . /etc/rc.conf
4 . /etc/rc.d/functions
5 . /etc/vbox/vbox.cfg
7 MODLIST=()
8 LOG="/var/log/vbox-install.log"
10 if [ -n "$INSTALL_DIR" ]; then
11 VBOXMANAGE="$INSTALL_DIR/VBoxManage"
12 BUILDVBOXDRV="$INSTALL_DIR/src/vboxhost/vboxdrv/build_in_tmp"
13 BUILDVBOXNETFLT="$INSTALL_DIR/src/vboxhost/vboxnetflt/build_in_tmp"
14 BUILDVBOXNETADP="$INSTALL_DIR/src/vboxhost/vboxnetadp/build_in_tmp"
15 else
16 echo "missing vbox.cfg"
17 exit 0
20 case "$1" in
21 setup)
22 stat_busy "Unloading VirtualBox kernel modules"
23 for module in vbox{netflt,netadp,drv}; do
24 if grep -q "^${module}" /proc/modules; then
25 MODLIST+=($module)
26 modprobe -r $module
28 done
29 stat_done
30 for p in /lib/modules/*; do
31 if [ ! -d "$p/kernel" ]; then
32 if [ -e "$p/misc/vboxdrv.ko" ]; then
33 stat_busy "Removing old VirtualBox kernel modules from $p"
34 rm -f "$p/misc/vbox"{drv,netadp,netflt}.ko 2>/dev/null
35 rmdir -p --ignore-fail-on-non-empty "$p/misc/" 2>/dev/null
36 stat_done
39 done
40 if find /lib/modules/`uname -r` -name "vboxnetadp\.*" 2>/dev/null|grep -q vboxnetadp; then
41 stat_busy "Removing old VirtualBox netadp kernel module"
42 find /lib/modules/`uname -r` -name "vboxnetadp\.*" 2>/dev/null|xargs rm -f 2>/dev/null
43 stat_done
45 if find /lib/modules/`uname -r` -name "vboxnetflt\.*" 2>/dev/null|grep -q vboxnetflt; then
46 stat_busy "Removing old VirtualBox netflt kernel module"
47 find /lib/modules/`uname -r` -name "vboxnetflt\.*" 2>/dev/null|xargs rm -f 2>/dev/null
48 stat_done
50 if find /lib/modules/`uname -r` -name "vboxdrv\.*" 2>/dev/null|grep -q vboxdrv; then
51 stat_busy "Removing old VirtualBox kernel module"
52 find /lib/modules/`uname -r` -name "vboxdrv\.*" 2>/dev/null|xargs rm -f 2>/dev/null
53 stat_done
55 stat_busy "Recompiling VirtualBox kernel modules"
56 if ! $BUILDVBOXDRV \
57 --save-module-symvers /tmp/vboxdrv-Module.symvers \
58 --no-print-directory install > $LOG 2>&1; then
59 echo "Look at $LOG to find out what went wrong"
61 if ! $BUILDVBOXNETFLT \
62 --use-module-symvers /tmp/vboxdrv-Module.symvers \
63 --no-print-directory install >> $LOG 2>&1; then
64 echo "Look at $LOG to find out what went wrong"
66 if ! $BUILDVBOXNETADP \
67 --use-module-symvers /tmp/vboxdrv-Module.symvers \
68 --no-print-directory install >> $LOG 2>&1; then
69 echo "Look at $LOG to find out what went wrong"
71 stat_done
72 stat_busy "Reloading VirtualBox kernel modules"
73 for module in "${MODLIST[@]}"; do
74 modprobe $module
75 done
76 stat_done
79 echo "usage: $0 {setup}"
80 esac