VirtualBox

source: vbox/trunk/src/VBox/Additions/darwin/Installer/VBoxGuestAdditionsKEXTs/postflight@ 107044

Last change on this file since 107044 was 106061, checked in by vboxsync, 2 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.2 KB
Line 
1#!/bin/sh
2# $Id: postflight 106061 2024-09-16 14:03:52Z vboxsync $
3## @file
4# Post flight installer script for the VirtualBox OS X kernel extensions.
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
29set -e
30
31# Setup environment.
32export PATH="/bin:/usr/bin:/sbin:/usr/sbin:$PATH"
33
34unload_service()
35{
36 ITEM_ID=$1
37 ITEM_PATH=$2
38 FORCED_USER=$3
39
40 loaded="NO"
41 test -n "$(sudo -u "$FORCED_USER" launchctl list | grep $ITEM_ID)" && loaded="YES"
42 if [ "$loaded" = "YES" ] ; then
43 echo "Unloading previously installed service: $ITEM_ID"
44 sudo -u "$FORCED_USER" launchctl unload -F "$ITEM_PATH/$ITEM_ID.plist"
45 fi
46}
47
48load_service()
49{
50 ITEM_ID=$1
51 ITEM_PATH=$2
52 FORCED_USER=$3
53
54 echo "Loading newly installed service: $ITEM_ID"
55 sudo -u "$FORCED_USER" launchctl load -F "$ITEM_PATH/$ITEM_ID.plist"
56}
57
58unload_service "org.virtualbox.additions.vboxservice" "/Library/LaunchDaemons" "root"
59
60# Remove the old service for all users
61for user in $(dscl . -list /Users | grep -v -e'^_' -e'root'); do
62 system_user="YES"
63 test -n "$(dscl . -read /Users/$user NFSHomeDirectory | grep '/Users')" && system_user="NO"
64 if [ "$system_user" = "NO" ]; then
65 unload_service "org.virtualbox.additions.vboxclient" "/Library/LaunchAgents" "$user"
66 fi
67done
68
69items="VBoxGuest"
70for item in $items; do
71 kext_item="org.virtualbox.kext.$item"
72
73 loaded="NO"
74 test -n "$(kextstat | grep $kext_item)" && loaded="YES"
75 if [ "$loaded" = "YES" ] ; then
76 echo "Unloading $item kernel extension..."
77 kextunload -b $kext_item
78 fi
79done
80
81MACOS_VERS=$(sw_vers -productVersion)
82
83echo "Updating kernel cache (should trigger loading of new modules)."
84# /System/Library/Extensions is readonly in Catalina and later,
85# so touch returns always false on these systems
86if [[ ${MACOS_VERS} != 11.* ]] && [[ ${MACOS_VERS} != 10.15.* ]]; then
87 touch "/System/Library/Extensions/"
88fi
89kextcache -update-volume / || true
90
91load_service "org.virtualbox.additions.vboxservice" "/Library/LaunchDaemons" "root"
92# Add VBoxClient for all currently defined users
93for user in $(dscl . -list /Users | grep -v -e'^_' -e'root'); do
94 system_user="YES"
95 test -n "$(dscl . -read /Users/$user NFSHomeDirectory | grep '/Users')" && system_user="NO"
96 if [ "$system_user" = "NO" ]; then
97 load_service "org.virtualbox.additions.vboxclient" "/Library/LaunchAgents" "$user"
98 fi
99done
100
101echo "Warning: If VBoxService adjusts the time backwards (because of --biossystemtimeoffset), the installer may hang."
102echo "Done."
103
104exit 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