1 | #!/bin/sh
|
---|
2 | #
|
---|
3 | # Oracle VM VirtualBox
|
---|
4 | # VirtualBox linux uninstallation script
|
---|
5 |
|
---|
6 | #
|
---|
7 | # Copyright (C) 2009-2023 Oracle and/or its affiliates.
|
---|
8 | #
|
---|
9 | # This file is part of VirtualBox base platform packages, as
|
---|
10 | # available from https://www.virtualbox.org.
|
---|
11 | #
|
---|
12 | # This program is free software; you can redistribute it and/or
|
---|
13 | # modify it under the terms of the GNU General Public License
|
---|
14 | # as published by the Free Software Foundation, in version 3 of the
|
---|
15 | # License.
|
---|
16 | #
|
---|
17 | # This program is distributed in the hope that it will be useful, but
|
---|
18 | # WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | # General Public License for more details.
|
---|
21 | #
|
---|
22 | # You should have received a copy of the GNU General Public License
|
---|
23 | # along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | #
|
---|
25 | # SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | #
|
---|
27 |
|
---|
28 | # The below is GNU-specific. See VBox.sh for the longer Solaris/OS X version.
|
---|
29 | TARGET=`readlink -e -- "${0}"` || exit 1
|
---|
30 | MY_PATH="${TARGET%/[!/]*}"
|
---|
31 | . "${MY_PATH}/routines.sh"
|
---|
32 |
|
---|
33 | if [ -z "$ro_LOG_FILE" ]; then
|
---|
34 | create_log "/var/log/vbox-uninstall.log"
|
---|
35 | fi
|
---|
36 |
|
---|
37 | if [ -z "VBOX_NO_UNINSTALL_MESSAGE" ]; then
|
---|
38 | info "Uninstalling VirtualBox"
|
---|
39 | log "Uninstalling VirtualBox"
|
---|
40 | log ""
|
---|
41 | fi
|
---|
42 |
|
---|
43 | check_root
|
---|
44 |
|
---|
45 | [ -z "$CONFIG_DIR" ] && CONFIG_DIR="/etc/vbox"
|
---|
46 | [ -z "$CONFIG" ] && CONFIG="vbox.cfg"
|
---|
47 | [ -z "$CONFIG_FILES" ] && CONFIG_FILES="filelist"
|
---|
48 | [ -z "$DEFAULT_FILES" ] && DEFAULT_FILES=`pwd`/deffiles
|
---|
49 |
|
---|
50 | # Find previous installation
|
---|
51 | if [ -r "$CONFIG_DIR/$CONFIG" ]; then
|
---|
52 | . "$CONFIG_DIR/$CONFIG"
|
---|
53 | PREV_INSTALLATION="$INSTALL_DIR"
|
---|
54 | fi
|
---|
55 |
|
---|
56 | # Remove previous installation
|
---|
57 | if [ "$PREV_INSTALLATION" = "" ]; then
|
---|
58 | log "Unable to find a VirtualBox installation, giving up."
|
---|
59 | abort "Couldn't find a VirtualBox installation to uninstall."
|
---|
60 | fi
|
---|
61 |
|
---|
62 | # Do pre-removal common to all installer types, currently service script
|
---|
63 | # clean-up.
|
---|
64 | "${MY_PATH}/prerm-common.sh" || exit 1
|
---|
65 |
|
---|
66 | # Remove kernel module installed
|
---|
67 | if [ -z "$VBOX_DONT_REMOVE_OLD_MODULES" ]; then
|
---|
68 | rm -f "/usr/src/vboxhost-$INSTALL_VER" 2> /dev/null
|
---|
69 | rm -f "/usr/src/vboxdrv-$INSTALL_VER" 2> /dev/null
|
---|
70 | rm -f "/usr/src/vboxnetflt-$INSTALL_VER" 2> /dev/null
|
---|
71 | rm -f "/usr/src/vboxnetadp-$INSTALL_VER" 2> /dev/null
|
---|
72 | rm -f "/usr/src/vboxpci-$INSTALL_VER" 2> /dev/null
|
---|
73 | fi
|
---|
74 |
|
---|
75 | # Remove symlinks
|
---|
76 | rm -f \
|
---|
77 | /usr/bin/VirtualBox \
|
---|
78 | /usr/bin/VirtualBoxVM \
|
---|
79 | /usr/bin/VBoxManage \
|
---|
80 | /usr/bin/VBoxSDL \
|
---|
81 | /usr/bin/VBoxVRDP \
|
---|
82 | /usr/bin/VBoxHeadless \
|
---|
83 | /usr/bin/VBoxDTrace \
|
---|
84 | /usr/bin/VBoxAudioTest \
|
---|
85 | /usr/bin/VBoxBugReport \
|
---|
86 | /usr/bin/VBoxBalloonCtrl \
|
---|
87 | /usr/bin/VBoxAutostart \
|
---|
88 | /usr/bin/VBoxNetDHCP \
|
---|
89 | /usr/bin/VBoxNetNAT \
|
---|
90 | /usr/bin/vboxwebsrv \
|
---|
91 | /usr/bin/vbox-img \
|
---|
92 | /usr/bin/vboximg-mount \
|
---|
93 | /usr/bin/VBoxAddIF \
|
---|
94 | /usr/bin/VBoxDeleteIf \
|
---|
95 | /usr/bin/VBoxTunctl \
|
---|
96 | /usr/bin/virtualbox \
|
---|
97 | /usr/bin/virtualboxvm \
|
---|
98 | /usr/share/pixmaps/VBox.png \
|
---|
99 | /usr/share/pixmaps/virtualbox.png \
|
---|
100 | /usr/share/applications/virtualbox.desktop \
|
---|
101 | /usr/share/applications/virtualboxvm.desktop \
|
---|
102 | /usr/share/mime/packages/virtualbox.xml \
|
---|
103 | /usr/bin/rdesktop-vrdp \
|
---|
104 | /usr/bin/virtualbox \
|
---|
105 | /usr/bin/vboxmanage \
|
---|
106 | /usr/bin/vboxsdl \
|
---|
107 | /usr/bin/vboxheadless \
|
---|
108 | /usr/bin/vboxdtrace \
|
---|
109 | /usr/bin/vboxaudiotest \
|
---|
110 | /usr/bin/vboxbugreport \
|
---|
111 | "$PREV_INSTALLATION/components/VBoxVMM.so" \
|
---|
112 | "$PREV_INSTALLATION/components/VBoxREM.so" \
|
---|
113 | "$PREV_INSTALLATION/components/VBoxRT.so" \
|
---|
114 | "$PREV_INSTALLATION/components/VBoxDDU.so" \
|
---|
115 | "$PREV_INSTALLATION/components/VBoxXPCOM.so" \
|
---|
116 | "$PREV_INSTALLATION/VBoxREM.so" \
|
---|
117 | "$PREV_INSTALLATION/VBoxVRDP" \
|
---|
118 | "$PREV_INSTALLATION/VBoxVRDP.so" \
|
---|
119 | 2> /dev/null
|
---|
120 |
|
---|
121 | cwd=`pwd`
|
---|
122 | if [ -f "$PREV_INSTALLATION/src/Makefile" ]; then
|
---|
123 | cd "$PREV_INSTALLATION/src"
|
---|
124 | make clean > /dev/null 2>&1
|
---|
125 | fi
|
---|
126 | if [ -f "$PREV_INSTALLATION/src/vboxdrv/Makefile" ]; then
|
---|
127 | cd "$PREV_INSTALLATION/src/vboxdrv"
|
---|
128 | make clean > /dev/null 2>&1
|
---|
129 | fi
|
---|
130 | if [ -f "$PREV_INSTALLATION/src/vboxnetflt/Makefile" ]; then
|
---|
131 | cd "$PREV_INSTALLATION/src/vboxnetflt"
|
---|
132 | make clean > /dev/null 2>&1
|
---|
133 | fi
|
---|
134 | if [ -f "$PREV_INSTALLATION/src/vboxnetadp/Makefile" ]; then
|
---|
135 | cd "$PREV_INSTALLATION/src/vboxnetadp"
|
---|
136 | make clean > /dev/null 2>&1
|
---|
137 | fi
|
---|
138 | if [ -f "$PREV_INSTALLATION/src/vboxpci/Makefile" ]; then
|
---|
139 | cd "$PREV_INSTALLATION/src/vboxpci"
|
---|
140 | make clean > /dev/null 2>&1
|
---|
141 | fi
|
---|
142 | cd "$PREV_INSTALLATION"
|
---|
143 | if [ -r "$CONFIG_DIR/$CONFIG_FILES" ]; then
|
---|
144 | rm -f `cat "$CONFIG_DIR/$CONFIG_FILES"` 2> /dev/null
|
---|
145 | elif [ -n "$DEFAULT_FILES" -a -r "$DEFAULT_FILES" ]; then
|
---|
146 | DEFAULT_FILE_NAMES=""
|
---|
147 | . "$DEFAULT_FILES"
|
---|
148 | rm -f $DEFAULT_FILE_NAMES 2> /dev/null
|
---|
149 | fi
|
---|
150 | for file in `find "$PREV_INSTALLATION" 2> /dev/null`; do
|
---|
151 | rmdir -p "$file" 2> /dev/null
|
---|
152 | done
|
---|
153 | cd "$cwd" 2> /dev/null
|
---|
154 | mkdir -p "$PREV_INSTALLATION" 2> /dev/null # The above actually removes the current directory and parents!
|
---|
155 | rmdir "$PREV_INSTALLATION" 2> /dev/null
|
---|
156 | rm -f "$CONFIG_DIR/$CONFIG" 2> /dev/null
|
---|
157 | rm -f "$CONFIG_DIR/$CONFIG_FILES" 2> /dev/null
|
---|
158 | rmdir "$CONFIG_DIR" 2> /dev/null
|
---|
159 |
|
---|
160 | update-mime-database /usr/share/mime >/dev/null 2>&1
|
---|
161 |
|
---|
162 | if [ -z "$VBOX_NO_UNINSTALL_MESSAGE" ]; then
|
---|
163 | [ -n "$INSTALL_REV" ] && INSTALL_REV=" r$INSTALL_REV"
|
---|
164 | info "VirtualBox $INSTALL_VER$INSTALL_REV has been removed successfully."
|
---|
165 | log "Successfully $INSTALL_VER$INSTALL_REV removed VirtualBox."
|
---|
166 | fi
|
---|