1 | #!/bin/sh
|
---|
2 | #
|
---|
3 | # Oracle VM VirtualBox
|
---|
4 | # VirtualBox linux uninstallation script
|
---|
5 |
|
---|
6 | #
|
---|
7 | # Copyright (C) 2009-2015 Oracle Corporation
|
---|
8 | #
|
---|
9 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | # available from http://www.virtualbox.org. This file is free software;
|
---|
11 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | # General Public License (GPL) as published by the Free Software
|
---|
13 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | #
|
---|
17 |
|
---|
18 | . `dirname $0`/routines.sh
|
---|
19 |
|
---|
20 | if [ -z "$ro_LOG_FILE" ]; then
|
---|
21 | create_log "/var/log/vbox-uninstall.log"
|
---|
22 | fi
|
---|
23 |
|
---|
24 | if [ -z "VBOX_NO_UNINSTALL_MESSAGE" ]; then
|
---|
25 | info "Uninstalling VirtualBox"
|
---|
26 | log "Uninstalling VirtualBox"
|
---|
27 | log ""
|
---|
28 | fi
|
---|
29 |
|
---|
30 | check_root
|
---|
31 |
|
---|
32 | [ -z "$DKMS" ] && DKMS=`which dkms 2> /dev/null`
|
---|
33 | [ -z "$CONFIG_DIR" ] && CONFIG_DIR="/etc/vbox"
|
---|
34 | [ -z "$CONFIG" ] && CONFIG="vbox.cfg"
|
---|
35 | [ -z "$CONFIG_FILES" ] && CONFIG_FILES="filelist"
|
---|
36 | [ -z "$DEFAULT_FILES" ] && DEFAULT_FILES=`pwd`/deffiles
|
---|
37 |
|
---|
38 | # Find previous installation
|
---|
39 | if [ -r $CONFIG_DIR/$CONFIG ]; then
|
---|
40 | . $CONFIG_DIR/$CONFIG
|
---|
41 | PREV_INSTALLATION=$INSTALL_DIR
|
---|
42 | fi
|
---|
43 |
|
---|
44 | # Remove previous installation
|
---|
45 | if [ "$PREV_INSTALLATION" = "" ]; then
|
---|
46 | log "Unable to find a VirtualBox installation, giving up."
|
---|
47 | abort "Couldn't find a VirtualBox installation to uninstall."
|
---|
48 | fi
|
---|
49 |
|
---|
50 | # Stop the ballon control service
|
---|
51 | stop_init_script vboxballoonctrl-service
|
---|
52 | # Stop the autostart service
|
---|
53 | stop_init_script vboxautostart-service
|
---|
54 | # Stop the web service
|
---|
55 | stop_init_script vboxweb-service
|
---|
56 | # Do this check here after we terminated the web service
|
---|
57 | check_running
|
---|
58 | # Terminate VBoxNetDHCP if running
|
---|
59 | terminate_proc VBoxNetDHCP
|
---|
60 | # Terminate VBoxNetNAT if running
|
---|
61 | terminate_proc VBoxNetNAT
|
---|
62 | delrunlevel vboxballoonctrl-service > /dev/null 2>&1
|
---|
63 | remove_init_script vboxballoonctrl-service
|
---|
64 | delrunlevel vboxautostart-service > /dev/null 2>&1
|
---|
65 | remove_init_script vboxautostart-service
|
---|
66 | delrunlevel vboxweb-service > /dev/null 2>&1
|
---|
67 | remove_init_script vboxweb-service
|
---|
68 | # Stop kernel module and uninstall runlevel script
|
---|
69 | stop_init_script vboxdrv
|
---|
70 | delrunlevel vboxdrv > /dev/null 2>&1
|
---|
71 | remove_init_script vboxdrv
|
---|
72 | # Stop host networking and uninstall runlevel script (obsolete)
|
---|
73 | stop_init_script vboxnet
|
---|
74 | delrunlevel vboxnet > /dev/null 2>&1
|
---|
75 | remove_init_script vboxnet
|
---|
76 | # Remove kernel module installed
|
---|
77 | if [ -n "$DKMS" ]; then
|
---|
78 | $DKMS remove -m vboxhost -v $INSTALL_VER --all > /dev/null 2>&1
|
---|
79 | fi
|
---|
80 | if [ -z "$VBOX_DONT_REMOVE_OLD_MODULES" ]; then
|
---|
81 | find /lib/modules/`uname -r` -name "vboxdrv\.*" 2>/dev/null|xargs rm -f 2> /dev/null
|
---|
82 | find /lib/modules/`uname -r` -name "vboxnetflt\.*" 2>/dev/null|xargs rm -f 2> /dev/null
|
---|
83 | find /lib/modules/`uname -r` -name "vboxnetadp\.*" 2>/dev/null|xargs rm -f 2> /dev/null
|
---|
84 | # Remove directories we have installed to in the past
|
---|
85 | find /lib/modules/`uname -r` -name vbox\* 2>/dev/null|xargs rmdir -p 2> /dev/null
|
---|
86 | find /lib/modules/`uname -r` -name misc\* 2>/dev/null|xargs rmdir -p 2> /dev/null
|
---|
87 | rm -f /usr/src/vboxhost-$INSTALL_VER 2> /dev/null
|
---|
88 | rm -f /usr/src/vboxdrv-$INSTALL_VER 2> /dev/null
|
---|
89 | rm -f /usr/src/vboxnetflt-$INSTALL_VER 2> /dev/null
|
---|
90 | rm -f /usr/src/vboxnetadp-$INSTALL_VER 2> /dev/null
|
---|
91 | fi
|
---|
92 |
|
---|
93 | # Remove symlinks
|
---|
94 | rm -f \
|
---|
95 | /usr/bin/VirtualBox \
|
---|
96 | /usr/bin/VBoxManage \
|
---|
97 | /usr/bin/VBoxSDL \
|
---|
98 | /usr/bin/VBoxVRDP \
|
---|
99 | /usr/bin/VBoxHeadless \
|
---|
100 | /usr/bin/VBoxDTrace \
|
---|
101 | /usr/bin/VBoxBalloonCtrl \
|
---|
102 | /usr/bin/VBoxAutostart \
|
---|
103 | /usr/bin/VBoxNetDHCP \
|
---|
104 | /usr/bin/VBoxNetNAT \
|
---|
105 | /usr/bin/vboxwebsrv \
|
---|
106 | /usr/bin/vbox-img \
|
---|
107 | /usr/bin/VBoxAddIF \
|
---|
108 | /usr/bin/VBoxDeleteIf \
|
---|
109 | /usr/bin/VBoxTunctl \
|
---|
110 | /usr/bin/virtualbox \
|
---|
111 | /usr/share/pixmaps/VBox.png \
|
---|
112 | /usr/share/pixmaps/virtualbox.png \
|
---|
113 | /usr/share/applications/virtualbox.desktop \
|
---|
114 | /usr/share/mime/packages/virtualbox.xml \
|
---|
115 | /usr/bin/rdesktop-vrdp \
|
---|
116 | /usr/bin/virtualbox \
|
---|
117 | /usr/bin/vboxmanage \
|
---|
118 | /usr/bin/vboxsdl \
|
---|
119 | /usr/bin/vboxheadless \
|
---|
120 | /usr/bin/vboxdtrace \
|
---|
121 | $PREV_INSTALLATION/components/VBoxVMM.so \
|
---|
122 | $PREV_INSTALLATION/components/VBoxREM.so \
|
---|
123 | $PREV_INSTALLATION/components/VBoxRT.so \
|
---|
124 | $PREV_INSTALLATION/components/VBoxDDU.so \
|
---|
125 | $PREV_INSTALLATION/components/VBoxXPCOM.so \
|
---|
126 | 2> /dev/null
|
---|
127 |
|
---|
128 | # Remove udev description file
|
---|
129 | if [ -f /etc/udev/rules.d/60-vboxdrv.rules ]; then
|
---|
130 | rm -f /etc/udev/rules.d/60-vboxdrv.rules 2> /dev/null
|
---|
131 | fi
|
---|
132 | if [ -f /etc/udev/rules.d/10-vboxdrv.rules ]; then
|
---|
133 | rm -f /etc/udev/rules.d/10-vboxdrv.rules 2> /dev/null
|
---|
134 | fi
|
---|
135 |
|
---|
136 | # Remove our USB device tree
|
---|
137 | rm -rf /dev/vboxusb 2> /dev/null
|
---|
138 |
|
---|
139 | cwd=`pwd`
|
---|
140 | if [ -f $PREV_INSTALLATION/src/Makefile ]; then
|
---|
141 | cd $PREV_INSTALLATION/src
|
---|
142 | make clean > /dev/null 2>&1
|
---|
143 | fi
|
---|
144 | if [ -f $PREV_INSTALLATION/src/vboxdrv/Makefile ]; then
|
---|
145 | cd $PREV_INSTALLATION/src/vboxdrv
|
---|
146 | make clean > /dev/null 2>&1
|
---|
147 | fi
|
---|
148 | if [ -f $PREV_INSTALLATION/src/vboxnetflt/Makefile ]; then
|
---|
149 | cd $PREV_INSTALLATION/src/vboxnetflt
|
---|
150 | make clean > /dev/null 2>&1
|
---|
151 | fi
|
---|
152 | if [ -f $PREV_INSTALLATION/src/vboxnetadp/Makefile ]; then
|
---|
153 | cd $PREV_INSTALLATION/src/vboxnetadp
|
---|
154 | make clean > /dev/null 2>&1
|
---|
155 | fi
|
---|
156 | cd $PREV_INSTALLATION
|
---|
157 | if [ -r $CONFIG_DIR/$CONFIG_FILES ]; then
|
---|
158 | rm -f `cat $CONFIG_DIR/$CONFIG_FILES` 2> /dev/null
|
---|
159 | elif [ -n "$DEFAULT_FILES" -a -r "$DEFAULT_FILES" ]; then
|
---|
160 | DEFAULT_FILE_NAMES=""
|
---|
161 | . $DEFAULT_FILES
|
---|
162 | for i in "$DEFAULT_FILE_NAMES"; do
|
---|
163 | rm -f $i 2> /dev/null
|
---|
164 | done
|
---|
165 | fi
|
---|
166 | for file in `find $PREV_INSTALLATION 2> /dev/null`; do
|
---|
167 | rmdir -p $file 2> /dev/null
|
---|
168 | done
|
---|
169 | cd $cwd
|
---|
170 | mkdir -p $PREV_INSTALLATION 2> /dev/null # The above actually removes the current directory and parents!
|
---|
171 | rmdir $PREV_INSTALLATION 2> /dev/null
|
---|
172 | rm -r $CONFIG_DIR/$CONFIG 2> /dev/null
|
---|
173 |
|
---|
174 | if [ -z "$VBOX_NO_UNINSTALL_MESSAGE" ]; then
|
---|
175 | rm -r $CONFIG_DIR/$CONFIG_FILES 2> /dev/null
|
---|
176 | rmdir $CONFIG_DIR 2> /dev/null
|
---|
177 | [ -n "$INSTALL_REV" ] && INSTALL_REV=" r$INSTALL_REV"
|
---|
178 | info "VirtualBox $INSTALL_VER$INSTALL_REV has been removed successfully."
|
---|
179 | log "Successfully $INSTALL_VER$INSTALL_REV removed VirtualBox."
|
---|
180 | fi
|
---|
181 | update-mime-database /usr/share/mime >/dev/null 2>&1
|
---|