VirtualBox

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

Last change on this file since 35020 was 34679, checked in by vboxsync, 14 years ago

Linux installer: properly handle VBoxExtPackHelperApp

File size: 7.1 KB
Line 
1#!/bin/sh
2#
3# Copyright (C) 2006-2010 Oracle Corporation
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 (6.5 of Debian policy):
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
22# defaults
23[ -r /etc/default/virtualbox ] && . /etc/default/virtualbox
24
25if [ "$1" = "configure" ]; then
26
27 # for debconf
28 . /usr/share/debconf/confmodule
29 db_version 2.0
30
31 # remove old cruft
32 if [ -f /etc/init.d/vboxdrv.sh ]; then
33 echo "Found old version of /etc/init.d/vboxdrv.sh, removing."
34 rm /etc/init.d/vboxdrv.sh
35 update-rc.d vboxdrv.sh remove >/dev/null
36 fi
37 if [ -f /etc/vbox/vbox.cfg ]; then
38 echo "Found old version of /etc/vbox/vbox.cfg, removing."
39 rm /etc/vbox/vbox.cfg
40 fi
41
42 # install udev rule (disable with INSTALL_NO_UDEV=1 in /etc/default/virtualbox)
43 if [ -d /etc/udev/rules.d -a "$INSTALL_NO_UDEV" != "1" ]; then
44 udev_call=""
45 udev_app=`which udevadm 2> /dev/null`
46 if [ $? -eq 0 ]; then
47 udev_call="${udev_app} version 2> /dev/null"
48 else
49 udev_app=`which udevinfo 2> /dev/null`
50 if [ $? -eq 0 ]; then
51 udev_call="${udev_app} -V 2> /dev/null"
52 fi
53 fi
54 udev_fix="="
55 if [ "${udev_call}" != "" ]; then
56 udev_out=`${udev_call}`
57 udev_ver=`expr "$udev_out" : '[^0-9]*\([0-9]*\)'`
58 if [ "$udev_ver" = "" -o "$udev_ver" -lt 55 ]; then
59 udev_fix=""
60 fi
61 fi
62 echo "KERNEL=${udev_fix}\"vboxdrv\", NAME=\"vboxdrv\", OWNER=\"root\", GROUP=\"root\", MODE=\"0600\"" \
63 > /etc/udev/rules.d/10-vboxdrv.rules
64 if [ "$INSTALL_NO_GROUP" != "1" ]; then
65 usb_group=vboxusers
66 else
67 usb_group=root
68 fi
69 usb_createnode="/usr/share/virtualbox/VBoxCreateUSBNode.sh"
70 echo "SUBSYSTEM=${udev_fix}\"usb_device\", ACTION=${udev_fix}\"add\", RUN=${usb_createnode} \$major \$minor \$attr{bDeviceClass}\"" ${usb_group} \
71 >> /etc/udev/rules.d/10-vboxdrv.rules
72 echo "SUBSYSTEM=${udev_fix}\"usb\", ACTION=${udev_fix}\"add\", ENV{DEVTYPE}==\"usb_device\", RUN=${usb_createnode} \$major \$minor \$attr{bDeviceClass}\"" ${usb_group} \
73 >> /etc/udev/rules.d/10-vboxdrv.rules
74 echo "SUBSYSTEM=${udev_fix}\"usb_device\", ACTION=${udev_fix}\"remove\", RUN=${usb_createnode} --remove \$major \$minor\"" \
75 >> /etc/udev/rules.d/10-vboxdrv.rules
76 echo "SUBSYSTEM=${udev_fix}\"usb\", ACTION=${udev_fix}\"remove\", ENV{DEVTYPE}==\"usb_device\", RUN=${usb_createnode} --remove \$major \$minor\"" \
77 >> /etc/udev/rules.d/10-vboxdrv.rules
78 fi
79 # Remove old udev description file
80 if [ -f /etc/udev/rules.d/60-vboxdrv.rules ]; then
81 rm -f /etc/udev/rules.d/60-vboxdrv.rules 2> /dev/null
82 fi
83 # Build our device tree
84 for i in /sys/bus/usb/devices/*; do
85 if test -r "$i/dev"; then
86 dev="`cat "$i/dev" 2> /dev/null`"
87 major="`expr "$dev" : '\(.*\):' 2> /dev/null`"
88 minor="`expr "$dev" : '.*:\(.*\)' 2> /dev/null`"
89 class="`cat $i/bDeviceClass 2> /dev/null`"
90 sh ${usb_createnode} "$major" "$minor" "$class" ${usb_group} 2>/dev/null
91 fi
92 done
93
94 # create users groups (disable with INSTALL_NO_GROUP=1 in /etc/default/virtualbox)
95 if [ "$INSTALL_NO_GROUP" != "1" ]; then
96 db_input low virtualbox/group-vboxusers || true
97 db_go || true
98 addgroup --system vboxusers || true
99 fi
100
101 # The starters need to be Suid root. They drop the privileges before starting
102 # the real frontend.
103 if ! dpkg-statoverride --list /usr/lib/virtualbox/VirtualBox > /dev/null 2>&1; then
104 chmod 4511 /usr/lib/virtualbox/VirtualBox
105 fi
106 if ! dpkg-statoverride --list /usr/lib/virtualbox/VBoxHeadless > /dev/null 2>&1; then
107 chmod 4511 /usr/lib/virtualbox/VBoxHeadless
108 fi
109 if ! dpkg-statoverride --list /usr/lib/virtualbox/VBoxSDL > /dev/null 2>&1; then
110 chmod 4511 /usr/lib/virtualbox/VBoxSDL
111 fi
112 if ! dpkg-statoverride --list /usr/lib/virtualbox/VBoxNetDHCP > /dev/null 2>&1; then
113 chmod 4511 /usr/lib/virtualbox/VBoxNetDHCP
114 fi
115 if ! dpkg-statoverride --list /usr/lib/virtualbox/VBoxNetAdpCtl > /dev/null 2>&1; then
116 chmod 4511 /usr/lib/virtualbox/VBoxNetAdpCtl
117 fi
118 if ! dpkg-statoverride --list /usr/lib/virtualbox/VBoxExtPackHelperApp > /dev/null 2>&1; then
119 chmod 4511 /usr/lib/virtualbox/VBoxExtPackHelperApp
120 fi
121
122 # if INSTALL_NO_VBOXDRV is set to 1, remove all shipped modules
123 if [ "$INSTALL_NO_VBOXDRV" = "1" ]; then
124 rm -f /lib/modules/*/misc/vboxdrv.ko
125 rm -f /lib/modules/*/misc/vboxnetflt.ko
126 rm -f /lib/modules/*/misc/vboxnetadp.ko
127 fi
128
129fi # $1 = "configure"
130
131#DEBHELPER#
132
133if [ "$1" = "configure" ]; then
134 # Start vboxdrv/vboxweb-service manually as we use our own error handling in postrm
135 if [ -x "/etc/init.d/vboxdrv" ]; then
136 update-rc.d vboxdrv defaults >/dev/null
137
138 BUILD_MODULES=0
139 REGISTER_MODULES=1
140 # Disable module compilation with INSTALL_NO_VBOXDRV=1 in /etc/default/virtualbox
141 if [ ! -f /lib/modules/`uname -r`/misc/vboxdrv.ko ]; then
142 REGISTER_MODULES=0
143 if [ "$INSTALL_NO_VBOXDRV" != "1" ]; then
144 db_get virtualbox/module-compilation-allowed
145 if [ "$RET" = "false" ]; then
146 cat << EOF
147Unable to find a precompiled module for the current kernel
148though module compilation denied by debconf setting.
149EOF
150 else
151 db_input low virtualbox/module-compilation-allowed || true
152 db_go || true
153 db_get virtualbox/module-compilation-allowed
154 if [ "$RET" = "true" ]; then
155 BUILD_MODULES=1
156 fi
157 fi
158 fi
159 fi
160
161 if [ $BUILD_MODULES -eq 1 ]; then
162 if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
163 invoke-rc.d vboxdrv setup || true
164 else
165 /etc/init.d/vboxdrv setup || true
166 fi
167 else
168 # shipped modules found, register sources at DKMS anyway
169 if lsmod | grep -q "vboxdrv[^_-]"; then
170 /etc/init.d/vboxdrv stop || true
171 fi
172 if [ $REGISTER_MODULES -eq 1 ]; then
173 DKMS=`which dkms 2>/dev/null`
174 if [ -n "$DKMS" ]; then
175 $DKMS add -m vboxhost -v %VER% > /dev/null 2>&1 || true
176 fi
177 fi
178 if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
179 invoke-rc.d vboxdrv start || exit $?
180 else
181 /etc/init.d/vboxdrv start || exit $?
182 fi
183 fi
184 fi
185 if [ -x "/etc/init.d/vboxweb-service" ]; then
186 update-rc.d vboxweb-service defaults >/dev/null
187 if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
188 invoke-rc.d vboxweb-service start || exit $?
189 else
190 /etc/init.d/vboxweb-service start || exit $?
191 fi
192 fi
193
194fi # $1 = "configure"
195
196exit 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