VirtualBox

source: vbox/trunk/src/VBox/Installer/linux/debian/postinst.in@ 32251

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

Linux installer: vboxweb-service fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.6 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 echo "SUBSYSTEM=${udev_fix}\"usb_device\", GROUP=\"vboxusers\", MODE=\"0664\"" \
66 >> /etc/udev/rules.d/10-vboxdrv.rules
67 echo "SUBSYSTEM=${udev_fix}\"usb\", ENV{DEVTYPE}==\"usb_device\", GROUP=\"vboxusers\", MODE=\"0664\"" \
68 >> /etc/udev/rules.d/10-vboxdrv.rules
69 else
70 echo "SUBSYSTEM=${udev_fix}\"usb_device\", GROUP=\"root\", MODE=\"0664\"" \
71 >> /etc/udev/rules.d/10-vboxdrv.rules
72 echo "SUBSYSTEM=${udev_fix}\"usb\", ENV{DEVTYPE}==\"usb_device\", GROUP=\"root\", MODE=\"0664\"" \
73 >> /etc/udev/rules.d/10-vboxdrv.rules
74 fi
75 fi
76 # Remove old udev description file
77 if [ -f /etc/udev/rules.d/60-vboxdrv.rules ]; then
78 rm -f /etc/udev/rules.d/60-vboxdrv.rules 2> /dev/null
79 fi
80 # Push the permissions to the USB device nodes. One of these should match.
81 # Rather nasty to use udevadm trigger for this, but I don't know of any
82 # better way.
83 udevadm trigger --subsystem-match=usb > /dev/null 2>&1
84 udevtrigger --subsystem-match=usb > /dev/null 2>&1
85 udevtrigger --subsystem-match=usb_device > /dev/null 2>&1
86 udevplug -Busb > /dev/null 2>&1
87
88 # create users groups (disable with INSTALL_NO_GROUP=1 in /etc/default/virtualbox)
89 if [ "$INSTALL_NO_GROUP" != "1" ]; then
90 db_input low virtualbox/group-vboxusers || true
91 db_go || true
92 addgroup --system vboxusers || true
93 fi
94
95 # The starters need to be Suid root. They drop the privileges before starting
96 # the real frontend.
97 if ! dpkg-statoverride --list /usr/lib/virtualbox/VirtualBox > /dev/null 2>&1; then
98 chmod 4511 /usr/lib/virtualbox/VirtualBox
99 fi
100 if ! dpkg-statoverride --list /usr/lib/virtualbox/VBoxHeadless > /dev/null 2>&1; then
101 chmod 4511 /usr/lib/virtualbox/VBoxHeadless
102 fi
103 if ! dpkg-statoverride --list /usr/lib/virtualbox/VBoxSDL > /dev/null 2>&1; then
104 chmod 4511 /usr/lib/virtualbox/VBoxSDL
105 fi
106 if ! dpkg-statoverride --list /usr/lib/virtualbox/VBoxNetDHCP > /dev/null 2>&1; then
107 chmod 4511 /usr/lib/virtualbox/VBoxNetDHCP
108 fi
109 if ! dpkg-statoverride --list /usr/lib/virtualbox/VBoxNetAdpCtl > /dev/null 2>&1; then
110 chmod 4511 /usr/lib/virtualbox/VBoxNetAdpCtl
111 fi
112
113 # if INSTALL_NO_VBOXDRV is set to 1, remove all shipped modules
114 if [ "$INSTALL_NO_VBOXDRV" = "1" ]; then
115 rm -f /lib/modules/*/misc/vboxdrv.ko
116 rm -f /lib/modules/*/misc/vboxnetflt.ko
117 rm -f /lib/modules/*/misc/vboxnetadp.ko
118 fi
119
120fi # $1 = "configure"
121
122#DEBHELPER#
123
124if [ "$1" = "configure" ]; then
125 # Start vboxdrv/vboxweb-service manually as we use our own error handling in postrm
126 if [ -x "/etc/init.d/vboxdrv" ]; then
127 update-rc.d vboxdrv defaults >/dev/null
128
129 # There might be an old module active (e.g. manually loaded)
130 if lsmod | grep -q "vboxdrv[^_-]"; then
131 /etc/init.d/vboxdrv stop || true
132 fi
133
134 BUILD_MODULES=0
135 REGISTER_MODULES=1
136 # Disable module compilation with INSTALL_NO_VBOXDRV=1 in /etc/default/virtualbox
137 if [ ! -f /lib/modules/`uname -r`/misc/vboxdrv.ko ]; then
138 REGISTER_MODULES=0
139 if [ "$INSTALL_NO_VBOXDRV" != "1" ]; then
140 db_get virtualbox/module-compilation-allowed
141 if [ "$RET" = "false" ]; then
142 cat << EOF
143Unable to find a precompiled module for the current kernel
144though module compilation denied by debconf setting.
145EOF
146 else
147 db_input low virtualbox/module-compilation-allowed || true
148 db_go || true
149 db_get virtualbox/module-compilation-allowed
150 if [ "$RET" = "true" ]; then
151 BUILD_MODULES=1
152 fi
153 fi
154 fi
155 fi
156
157 if [ $BUILD_MODULES -eq 1 ]; then
158 if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
159 invoke-rc.d vboxdrv setup || true
160 else
161 /etc/init.d/vboxdrv setup || true
162 fi
163 else
164 # shipped modules found, register sources at DKMS anyway
165 if [ $REGISTER_MODULES -eq 1 ]; then
166 DKMS=`which dkms 2>/dev/null`
167 if [ -n "$DKMS" ]; then
168 $DKMS add -m vboxhost -v %VER% > /dev/null 2>&1 || true
169 fi
170 fi
171 if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
172 invoke-rc.d vboxdrv start || exit $?
173 else
174 /etc/init.d/vboxdrv start || exit $?
175 fi
176 fi
177 fi
178 if [ -x "/etc/init.d/vboxweb-service" ]; then
179 update-rc.d vboxweb-service defaults >/dev/null
180 if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
181 invoke-rc.d vboxweb-service start || exit $?
182 else
183 /etc/init.d/vboxweb-service start || exit $?
184 fi
185 fi
186
187fi # $1 = "configure"
188
189exit 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