1 | #!/bin/sh
|
---|
2 | #
|
---|
3 | # Oracle VM VirtualBox
|
---|
4 | # VirtualBox linux uninstallation script
|
---|
5 |
|
---|
6 | #
|
---|
7 | # Copyright (C) 2009-2010 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 web service
|
---|
51 | stop_init_script vboxweb-service
|
---|
52 | # Do this check here after we terminated the web service
|
---|
53 | check_running
|
---|
54 | # Terminate VBoxNetDHCP if running
|
---|
55 | terminate_proc VBoxNetDHCP
|
---|
56 | delrunlevel vboxweb-service > /dev/null 2>&1
|
---|
57 | remove_init_script vboxweb-service
|
---|
58 | # Stop kernel module and uninstall runlevel script
|
---|
59 | stop_init_script vboxdrv
|
---|
60 | delrunlevel vboxdrv > /dev/null 2>&1
|
---|
61 | remove_init_script vboxdrv
|
---|
62 | # Stop host networking and uninstall runlevel script (obsolete)
|
---|
63 | stop_init_script vboxnet
|
---|
64 | delrunlevel vboxnet > /dev/null 2>&1
|
---|
65 | remove_init_script vboxnet
|
---|
66 | # Remove kernel module installed
|
---|
67 | if [ -n "$DKMS" ]; then
|
---|
68 | $DKMS remove -m vboxhost -v $INSTALL_VER --all > /dev/null 2>&1
|
---|
69 | fi
|
---|
70 | if [ -z "$VBOX_DONT_REMOVE_OLD_MODULES" ]; then
|
---|
71 | find /lib/modules/`uname -r` -name "vboxdrv\.*" 2>/dev/null|xargs rm -f 2> /dev/null
|
---|
72 | find /lib/modules/`uname -r` -name "vboxnetflt\.*" 2>/dev/null|xargs rm -f 2> /dev/null
|
---|
73 | find /lib/modules/`uname -r` -name "vboxnetadp\.*" 2>/dev/null|xargs rm -f 2> /dev/null
|
---|
74 | # Remove directories we have installed to in the past
|
---|
75 | find /lib/modules/`uname -r` -name vbox\* 2>/dev/null|xargs rmdir -p 2> /dev/null
|
---|
76 | find /lib/modules/`uname -r` -name misc\* 2>/dev/null|xargs rmdir -p 2> /dev/null
|
---|
77 | rm -f /usr/src/vboxhost-$INSTALL_VER 2> /dev/null
|
---|
78 | rm -f /usr/src/vboxdrv-$INSTALL_VER 2> /dev/null
|
---|
79 | rm -f /usr/src/vboxnetflt-$INSTALL_VER 2> /dev/null
|
---|
80 | rm -f /usr/src/vboxnetadp-$INSTALL_VER 2> /dev/null
|
---|
81 | fi
|
---|
82 |
|
---|
83 | # Remove symlinks
|
---|
84 | rm -f \
|
---|
85 | /usr/bin/VirtualBox \
|
---|
86 | /usr/bin/VBoxManage \
|
---|
87 | /usr/bin/VBoxSDL \
|
---|
88 | /usr/bin/VBoxVRDP \
|
---|
89 | /usr/bin/VBoxHeadless \
|
---|
90 | /usr/bin/VBoxNetDHCP \
|
---|
91 | /usr/bin/vboxwebsrv \
|
---|
92 | /usr/bin/VBoxAddIF \
|
---|
93 | /usr/bin/VBoxDeleteIf \
|
---|
94 | /usr/bin/VBoxTunctl \
|
---|
95 | /usr/bin/virtualbox \
|
---|
96 | /usr/share/pixmaps/VBox.png \
|
---|
97 | /usr/share/applications/virtualbox.desktop \
|
---|
98 | /usr/share/mime/packages/virtualbox.xml \
|
---|
99 | /usr/bin/rdesktop-vrdp \
|
---|
100 | /usr/bin/virtualbox \
|
---|
101 | /usr/bin/vboxmanage \
|
---|
102 | /usr/bin/vboxsdl \
|
---|
103 | /usr/bin/vboxheadless \
|
---|
104 | $PREV_INSTALLATION/components/VBoxVMM.so \
|
---|
105 | $PREV_INSTALLATION/components/VBoxREM.so \
|
---|
106 | $PREV_INSTALLATION/components/VBoxRT.so \
|
---|
107 | $PREV_INSTALLATION/components/VBoxDDU.so \
|
---|
108 | $PREV_INSTALLATION/components/VBoxXPCOM.so \
|
---|
109 | 2> /dev/null
|
---|
110 |
|
---|
111 | # Remove udev description file
|
---|
112 | if [ -f /etc/udev/rules.d/60-vboxdrv.rules ]; then
|
---|
113 | rm -f /etc/udev/rules.d/60-vboxdrv.rules 2> /dev/null
|
---|
114 | fi
|
---|
115 | if [ -f /etc/udev/rules.d/10-vboxdrv.rules ]; then
|
---|
116 | rm -f /etc/udev/rules.d/10-vboxdrv.rules 2> /dev/null
|
---|
117 | fi
|
---|
118 |
|
---|
119 | # Remove our USB device tree
|
---|
120 | rm -rf /dev/vboxusb 2> /dev/null
|
---|
121 |
|
---|
122 | cwd=`pwd`
|
---|
123 | if [ -f $PREV_INSTALLATION/src/Makefile ]; then
|
---|
124 | cd $PREV_INSTALLATION/src
|
---|
125 | make clean > /dev/null 2>&1
|
---|
126 | fi
|
---|
127 | if [ -f $PREV_INSTALLATION/src/vboxdrv/Makefile ]; then
|
---|
128 | cd $PREV_INSTALLATION/src/vboxdrv
|
---|
129 | make clean > /dev/null 2>&1
|
---|
130 | fi
|
---|
131 | if [ -f $PREV_INSTALLATION/src/vboxnetflt/Makefile ]; then
|
---|
132 | cd $PREV_INSTALLATION/src/vboxnetflt
|
---|
133 | make clean > /dev/null 2>&1
|
---|
134 | fi
|
---|
135 | if [ -f $PREV_INSTALLATION/src/vboxnetadp/Makefile ]; then
|
---|
136 | cd $PREV_INSTALLATION/src/vboxnetadp
|
---|
137 | make clean > /dev/null 2>&1
|
---|
138 | fi
|
---|
139 | cd $PREV_INSTALLATION
|
---|
140 | if [ -r $CONFIG_DIR/$CONFIG_FILES ]; then
|
---|
141 | rm -f `cat $CONFIG_DIR/$CONFIG_FILES` 2> /dev/null
|
---|
142 | elif [ -n "$DEFAULT_FILES" -a -r "$DEFAULT_FILES" ]; then
|
---|
143 | DEFAULT_FILE_NAMES=""
|
---|
144 | . $DEFAULT_FILES
|
---|
145 | for i in "$DEFAULT_FILE_NAMES"; do
|
---|
146 | rm -f $i 2> /dev/null
|
---|
147 | done
|
---|
148 | fi
|
---|
149 | for file in `find $PREV_INSTALLATION 2> /dev/null`; do
|
---|
150 | rmdir -p $file 2> /dev/null
|
---|
151 | done
|
---|
152 | cd $cwd
|
---|
153 | mkdir -p $PREV_INSTALLATION 2> /dev/null # The above actually removes the current directory and parents!
|
---|
154 | rmdir $PREV_INSTALLATION 2> /dev/null
|
---|
155 | rm -r $CONFIG_DIR/$CONFIG 2> /dev/null
|
---|
156 |
|
---|
157 | if [ -z "$VBOX_NO_UNINSTALL_MESSAGE" ]; then
|
---|
158 | rm -r $CONFIG_DIR/$CONFIG_FILES 2> /dev/null
|
---|
159 | rmdir $CONFIG_DIR 2> /dev/null
|
---|
160 | [ -n "$INSTALL_REV" ] && INSTALL_REV=" r$INSTALL_REV"
|
---|
161 | info "VirtualBox $INSTALL_VER$INSTALL_REV has been removed successfully."
|
---|
162 | log "Successfully $INSTALL_VER$INSTALL_REV removed VirtualBox."
|
---|
163 | fi
|
---|
164 | update-mime-database /usr/share/mime >/dev/null 2>&1
|
---|