1 | #!/bin/sh
|
---|
2 | ## @file
|
---|
3 | #
|
---|
4 | # VirtualBox postinstall script for FreeBSD.
|
---|
5 | #
|
---|
6 |
|
---|
7 | #
|
---|
8 | # Copyright (C) 2007-2024 Oracle and/or its affiliates.
|
---|
9 | #
|
---|
10 | # This file is part of VirtualBox base platform packages, as
|
---|
11 | # available from https://www.virtualbox.org.
|
---|
12 | #
|
---|
13 | # This program is free software; you can redistribute it and/or
|
---|
14 | # modify it under the terms of the GNU General Public License
|
---|
15 | # as published by the Free Software Foundation, in version 3 of the
|
---|
16 | # License.
|
---|
17 | #
|
---|
18 | # This program is distributed in the hope that it will be useful, but
|
---|
19 | # WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
21 | # General Public License for more details.
|
---|
22 | #
|
---|
23 | # You should have received a copy of the GNU General Public License
|
---|
24 | # along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
25 | #
|
---|
26 | # SPDX-License-Identifier: GPL-3.0-only
|
---|
27 | #
|
---|
28 |
|
---|
29 | PATH_TMP="/tmp"
|
---|
30 | PATH_TMP_MODS="$PATH_TMP/vbox_mods"
|
---|
31 | PATH_INST="/usr/local/lib/virtualbox"
|
---|
32 | PATH_KERN_SRC="/usr/src/sys"
|
---|
33 | FILE_VBOXDRV="$PATH_INST/vboxdrv.tar.gz"
|
---|
34 |
|
---|
35 |
|
---|
36 | if [ ! -f $PATH_KERN_SRC/Makefile ]; then
|
---|
37 | echo "Kernel sources are not installed. Please install them and reinstall VirtualBox"
|
---|
38 | exit 1
|
---|
39 | fi
|
---|
40 |
|
---|
41 | echo "Compiling kernel modules, please wait..."
|
---|
42 |
|
---|
43 | # Create temporary directory
|
---|
44 | mkdir -p $PATH_TMP_MODS
|
---|
45 |
|
---|
46 | # Unpack archive
|
---|
47 | tar -C $PATH_TMP_MODS -xf $FILE_VBOXDRV
|
---|
48 |
|
---|
49 | # Compile
|
---|
50 | cd $PATH_TMP_MODS
|
---|
51 | make
|
---|
52 |
|
---|
53 | # Check if we succeeded
|
---|
54 | if [ $? != 0 ]; then
|
---|
55 | echo "Compiling kernel modules failed."
|
---|
56 | cd ..
|
---|
57 | rm -rf $PATH_TMP_MODS
|
---|
58 | exit 1
|
---|
59 | fi
|
---|
60 |
|
---|
61 | # Copy the modules to /boot/kernel
|
---|
62 | echo "Installing kernel modules to /boot/kernel, please wait..."
|
---|
63 | cp $PATH_TMP_MODS/vboxdrv.ko /boot/kernel
|
---|
64 | cp $PATH_TMP_MODS/vboxnetflt.ko /boot/kernel
|
---|
65 | cp $PATH_TMP_MODS/vboxnetadp.ko /boot/kernel
|
---|
66 | kldxref -R /boot
|
---|
67 |
|
---|
68 | # Load them now, unloading old modules
|
---|
69 | make load
|
---|
70 |
|
---|
71 | if [ $? != 0 ]; then
|
---|
72 | echo "Loading kernel modules failed"
|
---|
73 | cd ..
|
---|
74 | rm -rf $PATH_TMP_MODS
|
---|
75 | exit 1
|
---|
76 | fi
|
---|
77 |
|
---|
78 | echo "Kernel modules successfully installed."
|
---|
79 | echo "To load them on every boot put them into /boot/loader.conf"
|
---|
80 |
|
---|
81 | # Cleanup
|
---|
82 | cd ..
|
---|
83 | rm -rf $PATH_TMP_MODS
|
---|
84 |
|
---|
85 | exit 0
|
---|
86 |
|
---|