VirtualBox

source: vbox/trunk/src/VBox/Additions/darwin/Installer/DiskImage/Uninstall.tool@ 98148

Last change on this file since 98148 was 98103, checked in by vboxsync, 2 years 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: 4.1 KB
Line 
1#!/bin/sh
2# $Id: Uninstall.tool 98103 2023-01-17 14:15:46Z vboxsync $
3## #file
4# VirtualBox Guest Additions uninstall script.
5#
6
7#
8# Copyright (C) 2007-2023 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# Override any funny stuff from the user.
30export PATH="/bin:/usr/bin:/sbin:/usr/sbin:$PATH"
31
32#
33# Display a simple welcome message first.
34#
35echo ""
36echo "Welcome to the VirtualBox Guest Additions uninstall script."
37echo ""
38
39# Check if user interraction is required to start uninstall process.
40fUnattended=0
41if test "$#" != "0"; then
42 if test "$#" != "1" -o "$1" != "--unattended"; then
43 echo "Error: Unknown argument(s): $*"
44 echo ""
45 echo "Usage: $0 [--unattended]"
46 echo ""
47 echo "If the '--unattended' option is not given, you will be prompted"
48 echo "for a Yes/No before doing the actual uninstallation."
49 echo ""
50 exit 4;
51 fi
52 fUnattended="Yes"
53fi
54
55if test "$fUnattended" != "Yes"; then
56 echo "Do you wish to continue none the less (Yes/No)?"
57 read fUnattended
58 if test "$fUnattended" != "Yes" -a "$fUnattended" != "YES" -a "$fUnattended" != "yes"; then
59 echo "Aborting uninstall. (answer: '$fUnattended')".
60 exit 2;
61 fi
62 echo ""
63fi
64
65# Stop services
66echo "Checking running services..."
67unload()
68{
69 ITEM_ID=$1
70 ITEM_PATH=$2
71 FORCED_USER=$3
72
73 echo "Unloading $ITEM_ID"
74
75
76 loaded="NO"
77 test -n "$(sudo -u "$FORCED_USER" launchctl list | grep $ITEM_ID)" && loaded="YES"
78 if [ "$loaded" = "YES" ] ; then
79 sudo -p "Please enter $FORCED_USER's password (unloading $ITEM_ID):" sudo -u "$FORCED_USER" launchctl unload -F "$ITEM_PATH/$ITEM_ID.plist"
80 fi
81
82}
83
84unload "org.virtualbox.additions.vboxservice" "/Library/LaunchDaemons" "root"
85unload "org.virtualbox.additions.vboxclient" "/Library/LaunchAgents" `whoami`
86
87# Unload kernel extensions
88echo "Checking running kernel extensions..."
89items="VBoxGuest"
90for item in $items; do
91 kext_item="org.virtualbox.kext.$item"
92 loaded=`kextstat | grep $kext_item`
93 if [ ! -z "$loaded" ] ; then
94 echo "Unloading $item kernel extension"
95 sudo -p "Please enter %u's password (unloading $item):" kextunload -b $kext_item
96 fi
97done
98
99# Remove files and directories
100echo "Checking files and directories..."
101sudo -p "Please enter %u's password (removing files and directories):" rm -rf "/Library/Application Support/VirtualBox Guest Additions"
102sudo -p "Please enter %u's password (removing files and directories):" rm -rf "/Library/Extensions/VBoxGuest.kext"
103sudo -p "Please enter %u's password (removing files and directories):" rm -rf "/Library/LaunchAgents/org.virtualbox.additions.vboxclient.plist"
104sudo -p "Please enter %u's password (removing files and directories):" rm -rf "/Library/LaunchDaemons/org.virtualbox.additions.vboxservice.plist"
105
106# Cleaning up pkgutil database
107echo "Checking package database ..."
108items="kexts tools-and-services"
109for item in $items; do
110 pkg_item="org.virtualbox.pkg.additions.$item"
111 installed=`pkgutil --pkgs="$pkg_item"`
112 if [ ! -z "$installed" ] ; then
113 sudo -p "Please enter %u's password (removing $pkg_item):" pkgutil --forget "$pkg_item"
114 fi
115done
116
117# Remove our kexts from the cache.
118echo "Updating kernel cache."
119sudo -p "Please enter %u's password (refreshing kext cache):" touch "/System/Library/Extensions/"
120sudo -p "Please enter %u's password (refreshing kext cache):" kextcache -update-volume /
121
122echo "Done."
123exit 0;
124
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