VirtualBox

source: vbox/trunk/debian/postinst.in@ 29250

Last change on this file since 29250 was 26163, checked in by vboxsync, 15 years ago

PDM: s/pUsbReg/pReg/g (2nd try, backed out r57176)

File size: 6.4 KB
Line 
1#!/bin/sh
2#
3# Copyright (C) 2006-2007 Sun Microsystems, Inc.
4#
5# This file is part of VirtualBox Open Source Edition (OSE), as
6# available from http://www.virtualbox.org. This file is free software;
7# you can redistribute it and/or modify it under the terms of the GNU
8# General Public License as published by the Free Software Foundation,
9# in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
10# distribution. VirtualBox OSE is distributed in the hope that it will
11# be useful, but WITHOUT ANY WARRANTY of any kind.
12#
13
14# we can be called with the following arguments:
15# configure: (our version): installing/configuring new version
16# abort-upgrade: (old version): upgrading to a new version failed
17# abort-remove: (our version): removing this package failed
18# abort-deconfigure: (our version): error during resolving conflicts
19
20LOG="/var/log/vbox-install.log"
21
22if [ "$1" = "configure" ]; then
23
24 # for debconf
25 . /usr/share/debconf/confmodule
26 db_version 2.0
27
28 # remove old cruft
29 if [ -f /etc/init.d/vboxdrv.sh ]; then
30 echo "Found old version of /etc/init.d/vboxdrv.sh, removing."
31 rm /etc/init.d/vboxdrv.sh
32 update-rc.d vboxdrv.sh remove >/dev/null
33 fi
34 if [ -f /etc/vbox/vbox.cfg ]; then
35 echo "Found old version of /etc/vbox/vbox.cfg, removing."
36 rm /etc/vbox/vbox.cfg
37 fi
38
39 # install udev rule
40 if [ -d /etc/udev/rules.d ]; then
41 udev_call=""
42 udev_app=`which udevadm 2> /dev/null`
43 if [ $? -eq 0 ]; then
44 udev_call="${udev_app} version 2> /dev/null"
45 else
46 udev_app=`which udevinfo 2> /dev/null`
47 if [ $? -eq 0 ]; then
48 udev_call="${udev_app} -V 2> /dev/null"
49 fi
50 fi
51 udev_fix="="
52 if [ "${udev_call}" != "" ]; then
53 udev_out=`${udev_call}`
54 udev_ver=`expr "$udev_out" : '[^0-9]*\([0-9]*\)'`
55 if [ "$udev_ver" = "" -o "$udev_ver" -lt 55 ]; then
56 udev_fix=""
57 fi
58 fi
59 echo "KERNEL=${udev_fix}\"vboxdrv\", NAME=\"vboxdrv\", OWNER=\"root\", GROUP=\"root\", MODE=\"0600\"" \
60 > /etc/udev/rules.d/60-vboxdrv.rules
61 fi
62
63 # create users groups
64 db_input high virtualbox/group-vboxusers || true
65 db_go || true
66 addgroup --system vboxusers || true
67
68 if [ ! -f /lib/modules/`uname -r`/misc/vboxdrv.ko ]; then
69 db_get virtualbox/module-compilation-allowed
70 if [ "$RET" = "false" ]; then
71 cat << EOF
72Unable to find a precompiled module for the current kernel
73though module compilation denied by debconf setting.
74EOF
75 else
76 db_input critical virtualbox/module-compilation-allowed || true
77 db_go || true
78 db_get virtualbox/module-compilation-allowed
79 if [ "$RET" = "true" ]; then
80 # Compile module. Don't show a message box here if everything works well.
81 cat << EOF
82Messages emitted during module compilation will be logged to $LOG.
83EOF
84 rm -f /etc/vbox/module_not_compiled
85 echo "** Compiling vboxdrv" > /var/log/vbox-install.log
86 if ! /usr/share/virtualbox/src/vboxdrv/build_in_tmp \
87 --save-module-symvers /tmp/vboxdrv-Module.symvers \
88 --no-print-directory KBUILD_VERBOSE= \
89 install >> /var/log/vbox-install.log 2>&1; then
90 db_fset virtualbox/module-compilation-failed seen false
91 db_input critical virtualbox/module-compilation-failed || true
92 db_go || true
93 touch /etc/vbox/module_not_compiled
94 # don't abort the installation!
95 else
96 echo "** Compiling vboxnetflt" >> /var/log/vbox-install.log
97 if ! /usr/share/virtualbox/src/vboxnetflt/build_in_tmp \
98 --use-module-symvers /tmp/vboxdrv-Module.symvers \
99 --no-print-directory KBUILD_VERBOSE= \
100 install >> /var/log/vbox-install.log 2>&1; then
101 db_fset virtualbox/module-compilation-failed seen false
102 db_input critical virtualbox/module-compilation-failed || true
103 db_go || true
104 touch /etc/vbox/module_not_compiled
105 # don't abort the installation!
106 else
107 echo "** Compiling vboxnetadp" >> /var/log/vbox-install.log
108 if ! /usr/share/virtualbox/src/vboxnetadp/build_in_tmp \
109 --use-module-symvers /tmp/vboxdrv-Module.symvers \
110 --no-print-directory KBUILD_VERBOSE= \
111 install >> /var/log/vbox-install.log 2>&1; then
112 db_fset virtualbox/module-compilation-failed seen false
113 db_input critical virtualbox/module-compilation-failed || true
114 db_go || true
115 touch /etc/vbox/module_not_compiled
116 # don't abort the installation!
117 fi
118 fi
119 fi
120 # cleanup
121 rm -f /tmp/vboxdrv-Module.symvers
122 if [ ! -f /etc/vbox/module_not_compiled ]; then
123 # success
124 cat << EOF
125Success!
126EOF
127 REGISTER_DKMS=
128 fi
129 fi
130 fi
131 fi
132
133 # Register at DKMS. If the modules were built above, they are already registered
134 if [ -n "$REGISTER_DKMS" ]; then
135 DKMS=`which dkms 2>/dev/null`
136 if [ -n "$DKMS" ]; then
137 for m in vboxdrv vboxnetflt vboxnetadp; do
138 $DKMS status -m $m | while read line; do
139 if echo "$line" | grep -q added > /dev/null ||
140 echo "$line" | grep -q built > /dev/null ||
141 echo "$line" | grep -q installed > /dev/null; then
142 v=`echo "$line" | sed "s/$m,\([^,]*\)[,:].*/\1/;t;d"`
143 $DKMS remove -m $m -v $v --all > /dev/null 2>&1
144 fi
145 done
146 $DKMS add -m $m -v %VER% > /dev/null 2>&1
147 done
148 fi
149 fi
150
151 # There might be an old module active (e.g. manually loaded)
152 if lsmod | grep -q "vboxdrv[^_-]"; then
153 /etc/init.d/vboxdrv stop || true
154 fi
155
156 # The starters need to be Suid root. They drop the privileges before starting
157 # the real frontend.
158 if ! dpkg-statoverride --list /usr/lib/virtualbox/VirtualBox > /dev/null 2>&1; then
159 chmod 4511 /usr/lib/virtualbox/VirtualBox
160 fi
161 if ! dpkg-statoverride --list /usr/lib/virtualbox/VBoxHeadless > /dev/null 2>&1; then
162 chmod 4511 /usr/lib/virtualbox/VBoxHeadless
163 fi
164 if ! dpkg-statoverride --list /usr/lib/virtualbox/VBoxSDL > /dev/null 2>&1; then
165 chmod 4511 /usr/lib/virtualbox/VBoxSDL
166 fi
167 if ! dpkg-statoverride --list /usr/lib/virtualbox/VBoxNetDHCP > /dev/null 2>&1; then
168 chmod 4511 /usr/lib/virtualbox/VBoxNetDHCP
169 fi
170 if ! dpkg-statoverride --list /usr/lib/virtualbox/VBoxNetAdpCtl > /dev/null 2>&1; then
171 chmod 4511 /usr/lib/virtualbox/VBoxNetAdpCtl
172 fi
173
174fi # $1 = "configure"
175
176#DEBHELPER#
177
178exit 0
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette