VirtualBox

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

Last change on this file since 93115 was 93115, checked in by vboxsync, 3 years ago

scm --update-copyright-year

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.9 KB
Line 
1#!/bin/sh
2# $Id: postflight 93115 2022-01-01 11:31:46Z vboxsync $
3## @file
4# Post flight installer script for the VirtualBox OS X kernel extensions.
5#
6
7#
8# Copyright (C) 2007-2022 Oracle Corporation
9#
10# This file is part of VirtualBox Open Source Edition (OSE), as
11# available from http://www.virtualbox.org. This file is free software;
12# you can redistribute it and/or modify it under the terms of the GNU
13# General Public License (GPL) as published by the Free Software
14# Foundation, in version 2 as it comes in the "COPYING" file of the
15# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17#
18
19set -e
20
21# Setup environment.
22export PATH="/bin:/usr/bin:/sbin:/usr/sbin:$PATH"
23
24unload_service()
25{
26 ITEM_ID=$1
27 ITEM_PATH=$2
28 FORCED_USER=$3
29
30 loaded="NO"
31 test -n "$(sudo -u "$FORCED_USER" launchctl list | grep $ITEM_ID)" && loaded="YES"
32 if [ "$loaded" = "YES" ] ; then
33 echo "Unloading previously installed service: $ITEM_ID"
34 sudo -u "$FORCED_USER" launchctl unload -F "$ITEM_PATH/$ITEM_ID.plist"
35 fi
36}
37
38load_service()
39{
40 ITEM_ID=$1
41 ITEM_PATH=$2
42 FORCED_USER=$3
43
44 echo "Loading newly installed service: $ITEM_ID"
45 sudo -u "$FORCED_USER" launchctl load -F "$ITEM_PATH/$ITEM_ID.plist"
46}
47
48unload_service "org.virtualbox.additions.vboxservice" "/Library/LaunchDaemons" "root"
49
50# Remove the old service for all users
51for user in $(dscl . -list /Users | grep -v -e'^_' -e'root'); do
52 system_user="YES"
53 test -n "$(dscl . -read /Users/$user NFSHomeDirectory | grep '/Users')" && system_user="NO"
54 if [ "$system_user" = "NO" ]; then
55 unload_service "org.virtualbox.additions.vboxclient" "/Library/LaunchAgents" "$user"
56 fi
57done
58
59items="VBoxGuest"
60for item in $items; do
61 kext_item="org.virtualbox.kext.$item"
62
63 loaded="NO"
64 test -n "$(kextstat | grep $kext_item)" && loaded="YES"
65 if [ "$loaded" = "YES" ] ; then
66 echo "Unloading $item kernel extension..."
67 kextunload -b $kext_item
68 fi
69done
70
71MACOS_VERS=$(sw_vers -productVersion)
72
73echo "Updating kernel cache (should trigger loading of new modules)."
74# /System/Library/Extensions is readonly in Catalina and later,
75# so touch returns always false on these systems
76if [[ ${MACOS_VERS} != 11.* ]] && [[ ${MACOS_VERS} != 10.15.* ]]; then
77 touch "/System/Library/Extensions/"
78fi
79kextcache -update-volume / || true
80
81load_service "org.virtualbox.additions.vboxservice" "/Library/LaunchDaemons" "root"
82# Add VBoxClient for all currently defined users
83for user in $(dscl . -list /Users | grep -v -e'^_' -e'root'); do
84 system_user="YES"
85 test -n "$(dscl . -read /Users/$user NFSHomeDirectory | grep '/Users')" && system_user="NO"
86 if [ "$system_user" = "NO" ]; then
87 load_service "org.virtualbox.additions.vboxclient" "/Library/LaunchAgents" "$user"
88 fi
89done
90
91echo "Warning: If VBoxService adjusts the time backwards (because of --biossystemtimeoffset), the installer may hang."
92echo "Done."
93
94exit 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