1 | #!/bin/sh
|
---|
2 | # $Id: postinst-common.sh 76553 2019-01-01 01:45:53Z vboxsync $
|
---|
3 | ## @file
|
---|
4 | # Oracle VM VirtualBox
|
---|
5 | # VirtualBox Linux post-installer common portions
|
---|
6 | #
|
---|
7 |
|
---|
8 | #
|
---|
9 | # Copyright (C) 2015-2019 Oracle Corporation
|
---|
10 | #
|
---|
11 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
12 | # available from http://www.virtualbox.org. This file is free software;
|
---|
13 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
14 | # General Public License (GPL) as published by the Free Software
|
---|
15 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
16 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
17 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
18 | #
|
---|
19 |
|
---|
20 | # Put bits of the post-installation here which should work the same for all of
|
---|
21 | # the Linux installers. We do not use special helpers (e.g. dh_* on Debian),
|
---|
22 | # but that should not matter, as we know what those helpers actually do, and we
|
---|
23 | # have to work on those systems anyway when installed using the all
|
---|
24 | # distributions installer.
|
---|
25 | #
|
---|
26 | # We assume that all required files are in the same folder as this script
|
---|
27 | # (e.g. /opt/VirtualBox, /usr/lib/VirtualBox, the build output directory).
|
---|
28 |
|
---|
29 | # The below is GNU-specific. See VBox.sh for the longer Solaris/OS X version.
|
---|
30 | TARGET=`readlink -e -- "${0}"` || exit 1
|
---|
31 | MY_PATH="${TARGET%/[!/]*}"
|
---|
32 | cd "${MY_PATH}"
|
---|
33 | . "./routines.sh"
|
---|
34 |
|
---|
35 | START=true
|
---|
36 | while test -n "${1}"; do
|
---|
37 | case "${1}" in
|
---|
38 | --nostart)
|
---|
39 | START=
|
---|
40 | ;;
|
---|
41 | *)
|
---|
42 | echo "Bad argument ${1}" >&2
|
---|
43 | exit 1
|
---|
44 | ;;
|
---|
45 | esac
|
---|
46 | shift
|
---|
47 | done
|
---|
48 |
|
---|
49 | # Remove any traces of DKMS from previous installations.
|
---|
50 | for i in vboxhost vboxdrv vboxnetflt vboxnetadp; do
|
---|
51 | rm -rf "/var/lib/dkms/${i}"*
|
---|
52 | done
|
---|
53 |
|
---|
54 | # Install runlevel scripts and systemd unit files
|
---|
55 | install_init_script "${MY_PATH}/vboxdrv.sh" vboxdrv
|
---|
56 | install_init_script "${MY_PATH}/vboxballoonctrl-service.sh" vboxballoonctrl-service
|
---|
57 | install_init_script "${MY_PATH}/vboxautostart-service.sh" vboxautostart-service
|
---|
58 | install_init_script "${MY_PATH}/vboxweb-service.sh" vboxweb-service
|
---|
59 | finish_init_script_install
|
---|
60 |
|
---|
61 | delrunlevel vboxdrv
|
---|
62 | addrunlevel vboxdrv
|
---|
63 | delrunlevel vboxballoonctrl-service
|
---|
64 | addrunlevel vboxballoonctrl-service
|
---|
65 | delrunlevel vboxautostart-service
|
---|
66 | addrunlevel vboxautostart-service
|
---|
67 | delrunlevel vboxweb-service
|
---|
68 | addrunlevel vboxweb-service
|
---|
69 |
|
---|
70 | ln -sf "${MY_PATH}/postinst-common.sh" /sbin/vboxconfig
|
---|
71 |
|
---|
72 | # Set SELinux permissions
|
---|
73 | # XXX SELinux: allow text relocation entries
|
---|
74 | if [ -x /usr/bin/chcon ]; then
|
---|
75 | chcon -t texrel_shlib_t "${MY_PATH}"/*VBox* > /dev/null 2>&1
|
---|
76 | chcon -t texrel_shlib_t "${MY_PATH}"/VBoxAuth.so \
|
---|
77 | > /dev/null 2>&1
|
---|
78 | chcon -t texrel_shlib_t "${MY_PATH}"/VirtualBox.so \
|
---|
79 | > /dev/null 2>&1
|
---|
80 | chcon -t texrel_shlib_t "${MY_PATH}"/components/VBox*.so \
|
---|
81 | > /dev/null 2>&1
|
---|
82 | chcon -t java_exec_t "${MY_PATH}"/VirtualBox > /dev/null 2>&1
|
---|
83 | chcon -t java_exec_t "${MY_PATH}"/VBoxSDL > /dev/null 2>&1
|
---|
84 | chcon -t java_exec_t "${MY_PATH}"/VBoxHeadless \
|
---|
85 | > /dev/null 2>&1
|
---|
86 | chcon -t java_exec_t "${MY_PATH}"/VBoxNetDHCP \
|
---|
87 | > /dev/null 2>&1
|
---|
88 | chcon -t java_exec_t "${MY_PATH}"/VBoxNetNAT \
|
---|
89 | > /dev/null 2>&1
|
---|
90 | chcon -t java_exec_t "${MY_PATH}"/VBoxExtPackHelperApp \
|
---|
91 | > /dev/null 2>&1
|
---|
92 | chcon -t java_exec_t "${MY_PATH}"/vboxwebsrv > /dev/null 2>&1
|
---|
93 | chcon -t bin_t "${MY_PATH}"/src/vboxhost/build_in_tmp \
|
---|
94 | > /dev/null 2>&1
|
---|
95 | chcon -t bin_t /usr/share/virtualbox/src/vboxhost/build_in_tmp \
|
---|
96 | > /dev/null 2>&1
|
---|
97 | fi
|
---|
98 |
|
---|
99 | test -n "${START}" &&
|
---|
100 | {
|
---|
101 | if ! "${MY_PATH}/vboxdrv.sh" setup; then
|
---|
102 | "${MY_PATH}/check_module_dependencies.sh" >&2
|
---|
103 | echo >&2
|
---|
104 | echo "There were problems setting up VirtualBox. To re-start the set-up process, run" >&2
|
---|
105 | echo " /sbin/vboxconfig" >&2
|
---|
106 | echo "as root." >&2
|
---|
107 | else
|
---|
108 | start_init_script vboxdrv
|
---|
109 | start_init_script vboxballoonctrl-service
|
---|
110 | start_init_script vboxautostart-service
|
---|
111 | start_init_script vboxweb-service
|
---|
112 | fi
|
---|
113 | }
|
---|