blob: e057c2500a7212e8f43bfeb5942489481a0a80ee (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
#!/bin/sh
# $Id: Uninstall.tool $
## #file
# VirtualBox Guest Additions uninstall script.
#
#
# Copyright (C) 2007-2023 Oracle and/or its affiliates.
#
# This file is part of VirtualBox base platform packages, as
# available from https://www.virtualbox.org.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation, in version 3 of the
# License.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <https://www.gnu.org/licenses>.
#
# SPDX-License-Identifier: GPL-3.0-only
#
# Override any funny stuff from the user.
export PATH="/bin:/usr/bin:/sbin:/usr/sbin:$PATH"
#
# Display a simple welcome message first.
#
echo ""
echo "Welcome to the VirtualBox Guest Additions uninstall script."
echo ""
# Check if user interraction is required to start uninstall process.
fUnattended=0
if test "$#" != "0"; then
if test "$#" != "1" -o "$1" != "--unattended"; then
echo "Error: Unknown argument(s): $*"
echo ""
echo "Usage: $0 [--unattended]"
echo ""
echo "If the '--unattended' option is not given, you will be prompted"
echo "for a Yes/No before doing the actual uninstallation."
echo ""
exit 4;
fi
fUnattended="Yes"
fi
if test "$fUnattended" != "Yes"; then
echo "Do you wish to continue none the less (Yes/No)?"
read fUnattended
if test "$fUnattended" != "Yes" -a "$fUnattended" != "YES" -a "$fUnattended" != "yes"; then
echo "Aborting uninstall. (answer: '$fUnattended')".
exit 2;
fi
echo ""
fi
# Stop services
echo "Checking running services..."
unload()
{
ITEM_ID=$1
ITEM_PATH=$2
FORCED_USER=$3
echo "Unloading $ITEM_ID"
loaded="NO"
test -n "$(sudo -u "$FORCED_USER" launchctl list | grep $ITEM_ID)" && loaded="YES"
if [ "$loaded" = "YES" ] ; then
sudo -p "Please enter $FORCED_USER's password (unloading $ITEM_ID):" sudo -u "$FORCED_USER" launchctl unload -F "$ITEM_PATH/$ITEM_ID.plist"
fi
}
unload "org.virtualbox.additions.vboxservice" "/Library/LaunchDaemons" "root"
unload "org.virtualbox.additions.vboxclient" "/Library/LaunchAgents" `whoami`
# Unload kernel extensions
echo "Checking running kernel extensions..."
items="VBoxGuest"
for item in $items; do
kext_item="org.virtualbox.kext.$item"
loaded=`kextstat | grep $kext_item`
if [ ! -z "$loaded" ] ; then
echo "Unloading $item kernel extension"
sudo -p "Please enter %u's password (unloading $item):" kextunload -b $kext_item
fi
done
# Remove files and directories
echo "Checking files and directories..."
sudo -p "Please enter %u's password (removing files and directories):" rm -rf "/Library/Application Support/VirtualBox Guest Additions"
sudo -p "Please enter %u's password (removing files and directories):" rm -rf "/Library/Extensions/VBoxGuest.kext"
sudo -p "Please enter %u's password (removing files and directories):" rm -rf "/Library/LaunchAgents/org.virtualbox.additions.vboxclient.plist"
sudo -p "Please enter %u's password (removing files and directories):" rm -rf "/Library/LaunchDaemons/org.virtualbox.additions.vboxservice.plist"
# Cleaning up pkgutil database
echo "Checking package database ..."
items="kexts tools-and-services"
for item in $items; do
pkg_item="org.virtualbox.pkg.additions.$item"
installed=`pkgutil --pkgs="$pkg_item"`
if [ ! -z "$installed" ] ; then
sudo -p "Please enter %u's password (removing $pkg_item):" pkgutil --forget "$pkg_item"
fi
done
# Remove our kexts from the cache.
echo "Updating kernel cache."
sudo -p "Please enter %u's password (refreshing kext cache):" touch "/System/Library/Extensions/"
sudo -p "Please enter %u's password (refreshing kext cache):" kextcache -update-volume /
echo "Done."
exit 0;
|