VirtualBox

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

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