VirtualBox

source: vbox/trunk/src/VBox/Installer/darwin/DiskImage/VirtualBox_Uninstall.tool@ 31672

最後變更 在這個檔案從31672是 31672,由 vboxsync 提交於 15 年 前

Installer-OSX: make it build in OSE

  • 屬性 svn:eol-style 設為 LF
  • 屬性 svn:executable 設為 *
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 8.3 KB
 
1#!/bin/sh
2#
3# VirtualBox Uninstaller Script.
4#
5# Copyright (C) 2007-2010 Oracle Corporation
6#
7# Use only with permission.
8#
9
10# Override any funny stuff from the user.
11export PATH="/bin:/usr/bin:/sbin:/usr/sbin:$PATH"
12
13#
14# Display a simple welcome message first.
15#
16echo ""
17echo "Welcome to the VirtualBox uninstaller script."
18echo ""
19
20#
21# Check for arguments and display
22#
23my_default_prompt=0
24if test "$#" != "0"; then
25 if test "$#" != "1" -o "$1" != "--unattended"; then
26 echo "Error: Unknown argument(s): $*"
27 echo ""
28 echo "Usage: uninstall.sh [--unattended]"
29 echo ""
30 echo "If the '--unattended' option is not given, you will be prompted"
31 echo "for a Yes/No before doing the actual uninstallation."
32 echo ""
33 exit 4;
34 fi
35 my_default_prompt="Yes"
36fi
37
38#
39# Collect directories and files to remove.
40# Note: Do NOT attempt adding directories or filenames with spaces!
41#
42my_directories=""
43my_files=""
44
45test -d /Library/StartupItems/VirtualBox/ && my_directories="$my_directories /Library/StartupItems/VirtualBox/"
46test -d /Library/Receipts/VBoxStartupItems.pkg/ && my_directories="$my_directories /Library/Receipts/VBoxStartupItems.pkg/"
47
48test -d /Library/Extensions/VBoxDrv.kext/ && my_directories="$my_directories /Library/Extensions/VBoxDrv.kext/"
49test -d /Library/Extensions/VBoxUSB.kext/ && my_directories="$my_directories /Library/Extensions/VBoxUSB.kext/"
50test -d /Library/Extensions/VBoxNetFlt.kext/ && my_directories="$my_directories /Library/Extensions/VBoxNetFlt.kext/"
51test -d /Library/Extensions/VBoxNetAdp.kext/ && my_directories="$my_directories /Library/Extensions/VBoxNetAdp.kext/"
52# Tiger support is obsolete, but we leave it here for a clean removing of older
53# VirtualBox versions
54test -d /Library/Extensions/VBoxDrvTiger.kext/ && my_directories="$my_directories /Library/Extensions/VBoxDrvTiger.kext/"
55test -d /Library/Extensions/VBoxUSBTiger.kext/ && my_directories="$my_directories /Library/Extensions/VBoxUSBTiger.kext/"
56test -d /Library/Receipts/VBoxKEXTs.pkg/ && my_directories="$my_directories /Library/Receipts/VBoxKEXTs.pkg/"
57
58test -f /usr/bin/VirtualBox && my_files="$my_files /usr/bin/VirtualBox"
59test -f /usr/bin/VBoxManage && my_files="$my_files /usr/bin/VBoxManage"
60test -f /usr/bin/VBoxVRDP && my_files="$my_files /usr/bin/VBoxVRDP"
61test -f /usr/bin/VBoxHeadless && my_files="$my_files /usr/bin/VBoxHeadless"
62test -f /usr/bin/vboxwebsrv && my_files="$my_files /usr/bin/vboxwebsrv"
63test -d /Library/Receipts/VirtualBoxCLI.pkg/ && my_directories="$my_directories /Library/Receipts/VirtualBoxCLI.pkg/"
64
65test -d /Applications/VirtualBox.app/ && my_directories="$my_directories /Applications/VirtualBox.app/"
66test -d /Library/Receipts/VirtualBox.pkg/ && my_directories="$my_directories /Library/Receipts/VirtualBox.pkg/"
67
68# legacy
69test -d /Library/Receipts/VBoxDrv.pkg/ && my_directories="$my_directories /Library/Receipts/VBoxDrv.pkg/"
70test -d /Library/Receipts/VBoxUSB.pkg/ && my_directories="$my_directories /Library/Receipts/VBoxUSB.pkg/"
71
72# python stuff
73python_versions="2.3 2.5 2.6"
74for p in $python_versions; do
75 test -f /Library/Python/$p/site-packages/vboxapi/VirtualBox_constants.py && my_files="$my_files /Library/Python/$p/site-packages/vboxapi/VirtualBox_constants.py"
76 test -f /Library/Python/$p/site-packages/vboxapi/VirtualBox_constants.pyc && my_files="$my_files /Library/Python/$p/site-packages/vboxapi/VirtualBox_constants.pyc"
77 test -f /Library/Python/$p/site-packages/vboxapi/__init__.py && my_files="$my_files /Library/Python/$p/site-packages/vboxapi/__init__.py"
78 test -f /Library/Python/$p/site-packages/vboxapi/__init__.pyc && my_files="$my_files /Library/Python/$p/site-packages/vboxapi/__init__.pyc"
79 test -f /Library/Python/$p/site-packages/vboxapi-1.0-py$p.egg-info && my_files="$my_files /Library/Python/$p/site-packages/vboxapi-1.0-py$p.egg-info"
80 test -d /Library/Python/$p/site-packages/vboxapi/ && my_directories="$my_directories /Library/Python/$p/site-packages/vboxapi/"
81done
82
83#
84# Collect KEXTs to remove.
85# Note that the unload order is significant.
86#
87my_kexts=""
88for kext in org.virtualbox.kext.VBoxUSB org.virtualbox.kext.VBoxNetFlt org.virtualbox.kext.VBoxNetAdp org.virtualbox.kext.VBoxDrv; do
89 if /usr/sbin/kextstat -b $kext -l | grep -q $kext; then
90 my_kexts="$my_kexts $kext"
91 fi
92done
93
94#
95# Did we find anything to uninstall?
96#
97if test -z "$my_directories" -a -z "$my_files" -a -z "$my_kexts"; then
98 echo "No VirtualBox files, directories or KEXTs to uninstall."
99 echo "Done."
100 exit 0;
101fi
102
103#
104# Look for running VirtualBox processes and warn the user
105# if something is running. Since deleting the files of
106# running processes isn't fatal as such, we will leave it
107# to the user to choose whether to continue or not.
108#
109# Note! comm isn't supported on Tiger, so we make -c to do the stripping.
110#
111my_processes="`ps -axco 'pid uid command' | grep -wEe '(VirtualBox|VirtualBoxVM|VBoxManage|VBoxHeadless|vboxwebsrv|VBoxXPCOMIPCD|VBoxSVC|VBoxNetDHCP)' | grep -vw grep | grep -vw VirtualBox_Uninstall.tool | tr '\n' '\a'`";
112if test -n "$my_processes"; then
113 echo 'Warning! Found the following active VirtualBox processes:'
114 echo "$my_processes" | tr '\a' '\n'
115 echo ""
116 echo "We recommend that you quit all VirtualBox processes before"
117 echo "uninstalling the product."
118 echo ""
119 if test "$my_default_prompt" != "Yes"; then
120 echo "Do you wish to continue none the less (Yes/No)?"
121 read my_answer
122 if test "$my_answer" != "Yes" -a "$my_answer" != "YES" -a "$my_answer" != "yes"; then
123 echo "Aborting uninstall. (answer: '$my_answer')".
124 exit 2;
125 fi
126 echo ""
127 my_answer=""
128 fi
129fi
130
131#
132# Display the files and directories that will be removed
133# and get the user's consent before continuing.
134#
135if test -n "$my_files" -o -n "$my_directories"; then
136 echo "The following files and directories (bundles) will be removed:"
137 for file in $my_files; do echo " $file"; done
138 for dir in $my_directories; do echo " $dir"; done
139fi
140if test -n "$my_kexts"; then
141echo "And the following KEXTs will be unloaded:"
142 for kext in $my_kexts; do echo " $kext"; done
143fi
144echo ""
145
146if test "$my_default_prompt" != "Yes"; then
147 echo "Do you wish to uninstall VirtualBox (Yes/No)?"
148 read my_answer
149 if test "$my_answer" != "Yes" -a "$my_answer" != "YES" -a "$my_answer" != "yes"; then
150 echo "Aborting uninstall. (answer: '$my_answer')".
151 exit 2;
152 fi
153 echo ""
154fi
155
156#
157# Display the sudo usage instructions and execute the command.
158#
159echo "The uninstallation processes requires administrative privileges"
160echo "because some of the installed files cannot be removed by a normal"
161echo "user. You may be prompted for your password now..."
162echo ""
163
164if test -n "$my_files" -o -n "$my_directories"; then
165 /usr/bin/sudo -p "Please enter %u's password:" /bin/rm -Rf $my_files $my_directories
166 my_rc=$?
167 if test "$my_rc" -ne 0; then
168 echo "An error occured durning 'sudo rm', there should be a message above. (rc=$my_rc)"
169 test -x /usr/bin/sudo || echo "warning: Cannot find /usr/bin/sudo or it's not an executable."
170 test -x /bin/rm || echo "warning: Cannot find /bin/rm or it's not an executable"
171 echo ""
172 echo "The uninstall failed. Please retry."
173 exit 1;
174 fi
175fi
176
177my_rc=0
178for kext in $my_kexts; do
179 echo unloading $kext
180 /usr/bin/sudo -p "Please enter %u's password (unloading $kext):" /sbin/kextunload -m $kext
181 my_rc2=$?
182 if test "$my_rc2" -ne 0; then
183 echo "An error occured durning 'sudo /sbin/kextunload -m $kext', there should be a message above. (rc=$my_rc2)"
184 test -x /usr/bin/sudo || echo "warning: Cannot find /usr/bin/sudo or it's not an executable."
185 test -x /sbin/kextunload || echo "warning: Cannot find /sbin/kextunload or it's not an executable"
186 my_rc=$my_rc2
187 fi
188done
189if test "$my_rc" -eq 0; then
190 echo "Successfully uninstalled VirtualBox."
191else
192 echo "Failed to unload on or more KEXTs, please reboot the machine to complete the uninstall."
193fi
194echo "Done."
195exit 0;
196
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette