1 | #!/bin/sh
|
---|
2 | #
|
---|
3 | # Copyright (C) 2006-2012 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 (GPL) as published by the Free Software
|
---|
9 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
10 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
11 | # hope that it will 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 |
|
---|
20 | #include installer-common.sh
|
---|
21 |
|
---|
22 | LOG="/var/log/vbox-install.log"
|
---|
23 |
|
---|
24 | # defaults
|
---|
25 | [ -r /etc/default/virtualbox ] && . /etc/default/virtualbox
|
---|
26 |
|
---|
27 | if [ "$1" = "configure" ]; then
|
---|
28 |
|
---|
29 | # for debconf
|
---|
30 | . /usr/share/debconf/confmodule
|
---|
31 | db_version 2.0
|
---|
32 |
|
---|
33 | # remove old cruft
|
---|
34 | if [ -f /etc/init.d/vboxdrv.sh ]; then
|
---|
35 | echo "Found old version of /etc/init.d/vboxdrv.sh, removing."
|
---|
36 | rm /etc/init.d/vboxdrv.sh
|
---|
37 | update-rc.d vboxdrv.sh remove >/dev/null
|
---|
38 | fi
|
---|
39 | if [ -f /etc/vbox/vbox.cfg ]; then
|
---|
40 | echo "Found old version of /etc/vbox/vbox.cfg, removing."
|
---|
41 | rm /etc/vbox/vbox.cfg
|
---|
42 | fi
|
---|
43 |
|
---|
44 | # create users groups (disable with INSTALL_NO_GROUP=1 in /etc/default/virtualbox)
|
---|
45 | if [ "$INSTALL_NO_GROUP" != "1" ]; then
|
---|
46 | db_input low virtualbox/group-vboxusers || true
|
---|
47 | db_go || true
|
---|
48 | addgroup --system vboxusers || true
|
---|
49 | fi
|
---|
50 |
|
---|
51 | # install udev rule (disable with INSTALL_NO_UDEV=1 in
|
---|
52 | # /etc/default/virtualbox) and /dev/vboxdrv and /dev/vboxusb/*/* device nodes
|
---|
53 | install_device_node_setup root 0600 /usr/share/virtualbox "${usb_group}"
|
---|
54 |
|
---|
55 | # The starters need to be Suid root. They drop the privileges before starting
|
---|
56 | # the real frontend.
|
---|
57 | if ! dpkg-statoverride --list /usr/lib/virtualbox/VirtualBox > /dev/null 2>&1; then
|
---|
58 | chmod 4511 /usr/lib/virtualbox/VirtualBox
|
---|
59 | fi
|
---|
60 | if ! dpkg-statoverride --list /usr/lib/virtualbox/VBoxHeadless > /dev/null 2>&1; then
|
---|
61 | chmod 4511 /usr/lib/virtualbox/VBoxHeadless
|
---|
62 | fi
|
---|
63 | if ! dpkg-statoverride --list /usr/lib/virtualbox/VBoxSDL > /dev/null 2>&1; then
|
---|
64 | chmod 4511 /usr/lib/virtualbox/VBoxSDL
|
---|
65 | fi
|
---|
66 | if ! dpkg-statoverride --list /usr/lib/virtualbox/VBoxNetDHCP > /dev/null 2>&1; then
|
---|
67 | chmod 4511 /usr/lib/virtualbox/VBoxNetDHCP
|
---|
68 | fi
|
---|
69 | if ! dpkg-statoverride --list /usr/lib/virtualbox/VBoxNetAdpCtl > /dev/null 2>&1; then
|
---|
70 | chmod 4511 /usr/lib/virtualbox/VBoxNetAdpCtl
|
---|
71 | fi
|
---|
72 | if ! dpkg-statoverride --list /usr/lib/virtualbox/VBoxVolInfo > /dev/null 2>&1; then
|
---|
73 | chmod 4511 /usr/lib/virtualbox/VBoxVolInfo
|
---|
74 | fi
|
---|
75 |
|
---|
76 | # if INSTALL_NO_VBOXDRV is set to 1, remove all shipped modules
|
---|
77 | if [ "$INSTALL_NO_VBOXDRV" = "1" ]; then
|
---|
78 | rm -f /lib/modules/*/misc/vboxdrv.ko
|
---|
79 | rm -f /lib/modules/*/misc/vboxnetflt.ko
|
---|
80 | rm -f /lib/modules/*/misc/vboxnetadp.ko
|
---|
81 | fi
|
---|
82 |
|
---|
83 | fi # $1 = "configure"
|
---|
84 |
|
---|
85 | #DEBHELPER#
|
---|
86 |
|
---|
87 | if [ "$1" = "configure" ]; then
|
---|
88 | # Start vboxdrv/vboxballoonctrl/vboxweb-service manually as we use our own error handling in postrm
|
---|
89 | if [ -x "/etc/init.d/vboxdrv" ]; then
|
---|
90 | update-rc.d vboxdrv defaults >/dev/null
|
---|
91 |
|
---|
92 | BUILD_MODULES=0
|
---|
93 | REGISTER_MODULES=1
|
---|
94 | # Disable module compilation with INSTALL_NO_VBOXDRV=1 in /etc/default/virtualbox
|
---|
95 | if [ ! -f /lib/modules/`uname -r`/misc/vboxdrv.ko ]; then
|
---|
96 | REGISTER_MODULES=0
|
---|
97 | if [ "$INSTALL_NO_VBOXDRV" != "1" ]; then
|
---|
98 | db_get virtualbox/module-compilation-allowed
|
---|
99 | if [ "$RET" = "false" ]; then
|
---|
100 | cat << EOF
|
---|
101 | Unable to find a precompiled module for the current kernel
|
---|
102 | though module compilation denied by debconf setting.
|
---|
103 | EOF
|
---|
104 | else
|
---|
105 | db_input low virtualbox/module-compilation-allowed || true
|
---|
106 | db_go || true
|
---|
107 | db_get virtualbox/module-compilation-allowed
|
---|
108 | if [ "$RET" = "true" ]; then
|
---|
109 | BUILD_MODULES=1
|
---|
110 | fi
|
---|
111 | fi
|
---|
112 | fi
|
---|
113 | fi
|
---|
114 |
|
---|
115 | if [ $BUILD_MODULES -eq 1 ]; then
|
---|
116 | if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
|
---|
117 | invoke-rc.d vboxdrv setup || true
|
---|
118 | else
|
---|
119 | /etc/init.d/vboxdrv setup || true
|
---|
120 | fi
|
---|
121 | else
|
---|
122 | # shipped modules found, register sources at DKMS anyway
|
---|
123 | if lsmod | grep -q "vboxdrv[^_-]"; then
|
---|
124 | /etc/init.d/vboxdrv stop || true
|
---|
125 | fi
|
---|
126 | if [ $REGISTER_MODULES -eq 1 ]; then
|
---|
127 | DKMS=`which dkms 2>/dev/null`
|
---|
128 | if [ -n "$DKMS" ]; then
|
---|
129 | $DKMS add -m vboxhost -v %VER% > /dev/null 2>&1 || true
|
---|
130 | fi
|
---|
131 | fi
|
---|
132 | if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
|
---|
133 | invoke-rc.d vboxdrv start || exit $?
|
---|
134 | else
|
---|
135 | /etc/init.d/vboxdrv start || exit $?
|
---|
136 | fi
|
---|
137 | fi
|
---|
138 | fi
|
---|
139 | if [ -x "/etc/init.d/vboxballoonctrl-service" ]; then
|
---|
140 | update-rc.d vboxballoonctrl-service defaults >/dev/null
|
---|
141 | if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
|
---|
142 | invoke-rc.d vboxballoonctrl-service start || exit $?
|
---|
143 | else
|
---|
144 | /etc/init.d/vboxballoonctrl-service start || exit $?
|
---|
145 | fi
|
---|
146 | fi
|
---|
147 | if [ -x "/etc/init.d/vboxautostart-service" ]; then
|
---|
148 | update-rc.d vboxautostart-service defaults >/dev/null
|
---|
149 | if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
|
---|
150 | invoke-rc.d vboxautostart-service start || exit $?
|
---|
151 | else
|
---|
152 | /etc/init.d/vboxautostart-service start || exit $?
|
---|
153 | fi
|
---|
154 | fi
|
---|
155 | if [ -x "/etc/init.d/vboxweb-service" ]; then
|
---|
156 | update-rc.d vboxweb-service defaults >/dev/null
|
---|
157 | if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
|
---|
158 | invoke-rc.d vboxweb-service start || exit $?
|
---|
159 | else
|
---|
160 | /etc/init.d/vboxweb-service start || exit $?
|
---|
161 | fi
|
---|
162 | fi
|
---|
163 |
|
---|
164 | fi # $1 = "configure"
|
---|
165 |
|
---|
166 | exit 0
|
---|