1 | #!/bin/sh
|
---|
2 |
|
---|
3 | . `dirname $0`/routines.sh
|
---|
4 |
|
---|
5 | if [ -z "$ro_LOG_FILE" ]; then
|
---|
6 | create_log "/var/log/vbox-uninstall.log"
|
---|
7 | fi
|
---|
8 |
|
---|
9 | if [ -z "VBOX_NO_UNINSTALL_MESSAGE" ]; then
|
---|
10 | info "Uninstalling VirtualBox"
|
---|
11 | log "Uninstalling VirtualBox"
|
---|
12 | log ""
|
---|
13 | fi
|
---|
14 |
|
---|
15 | [ -z "$DKMS" ] && DKMS=`which dkms 2> /dev/null`
|
---|
16 | [ -z "$CONFIG_DIR" ] && CONFIG_DIR="/etc/vbox"
|
---|
17 | [ -z "$CONFIG" ] && CONFIG="vbox.cfg"
|
---|
18 | [ -z "$CONFIG_FILES" ] && CONFIG_FILES="filelist"
|
---|
19 | [ -z "$DEFAULT_FILES" ] && DEFAULT_FILES=`pwd`/deffiles
|
---|
20 |
|
---|
21 | # Terminate Server and VBoxNetDHCP if running
|
---|
22 | terminate_proc VBoxSVC
|
---|
23 | terminate_proc VBoxNetDHCP
|
---|
24 |
|
---|
25 | # Find previous installation
|
---|
26 | if [ -r $CONFIG_DIR/$CONFIG ]; then
|
---|
27 | . $CONFIG_DIR/$CONFIG
|
---|
28 | PREV_INSTALLATION=$INSTALL_DIR
|
---|
29 | fi
|
---|
30 |
|
---|
31 | # Remove previous installation
|
---|
32 | if [ "$PREV_INSTALLATION" = "" ]; then
|
---|
33 | log "Unable to find a VirtualBox installation, giving up."
|
---|
34 | abort "Couldn't find a VirtualBox installation to uninstall."
|
---|
35 | fi
|
---|
36 |
|
---|
37 | # Stop the web service
|
---|
38 | stop_init_script vboxweb-service
|
---|
39 | delrunlevel vboxweb-service > /dev/null 2>&1
|
---|
40 | remove_init_script vboxweb-service
|
---|
41 | # Stop kernel module and uninstall runlevel script
|
---|
42 | stop_init_script vboxdrv
|
---|
43 | delrunlevel vboxdrv > /dev/null 2>&1
|
---|
44 | remove_init_script vboxdrv
|
---|
45 | # Stop host networking and uninstall runlevel script (obsolete)
|
---|
46 | stop_init_script vboxnet
|
---|
47 | delrunlevel vboxnet > /dev/null 2>&1
|
---|
48 | remove_init_script vboxnet
|
---|
49 | # Remove kernel module installed
|
---|
50 | if [ -n "$DKMS" ]; then
|
---|
51 | $DKMS remove -m vboxdrv -v $INSTALL_VER --all > /dev/null 2>&1
|
---|
52 | fi
|
---|
53 | if [ -z "$VBOX_DONT_REMOVE_OLD_MODULES" ]; then
|
---|
54 | find /lib/modules/`uname -r` -name "vboxdrv\.*" 2>/dev/null|xargs rm -f 2> /dev/null
|
---|
55 | find /lib/modules/`uname -r` -name "vboxnetflt\.*" 2>/dev/null|xargs rm -f 2> /dev/null
|
---|
56 | find /lib/modules/`uname -r` -name "vboxnetadp\.*" 2>/dev/null|xargs rm -f 2> /dev/null
|
---|
57 | # Remove directories we have installed to in the past
|
---|
58 | find /lib/modules/`uname -r` -name vbox\* 2>/dev/null|xargs rmdir -p 2> /dev/null
|
---|
59 | find /lib/modules/`uname -r` -name misc\* 2>/dev/null|xargs rmdir -p 2> /dev/null
|
---|
60 | rm -f /usr/src/vboxdrv-$INSTALL_VER 2> /dev/null
|
---|
61 | rm -f /usr/src/vboxnetflt-$INSTALL_VER 2> /dev/null
|
---|
62 | rm -f /usr/src/vboxnetadp-$INSTALL_VER 2> /dev/null
|
---|
63 | fi
|
---|
64 |
|
---|
65 | # Remove symlinks
|
---|
66 | rm -f /usr/bin/VirtualBox 2> /dev/null
|
---|
67 | rm -f /usr/bin/VBoxManage 2> /dev/null
|
---|
68 | rm -f /usr/bin/VBoxSDL 2> /dev/null
|
---|
69 | rm -f /usr/bin/VBoxVRDP 2> /dev/null
|
---|
70 | rm -f /usr/bin/VBoxHeadless 2> /dev/null
|
---|
71 | rm -f /usr/bin/VBoxNetDHCP 2> /dev/null
|
---|
72 | rm -f /usr/bin/vboxwebsrv 2> /dev/null
|
---|
73 | rm -f /usr/bin/VBoxAddIF 2> /dev/null
|
---|
74 | rm -f /usr/bin/VBoxDeleteIf 2> /dev/null
|
---|
75 | rm -f /usr/bin/VBoxTunctl 2> /dev/null
|
---|
76 | rm -f /usr/share/pixmaps/VBox.png 2> /dev/null
|
---|
77 | rm -f /usr/share/applications/virtualbox.desktop 2> /dev/null
|
---|
78 | rm -f /usr/bin/rdesktop-vrdp 2> /dev/null
|
---|
79 | rm -f $PREV_INSTALLATION/components/VBoxVMM.so
|
---|
80 | rm -f $PREV_INSTALLATION/components/VBoxREM.so
|
---|
81 | rm -f $PREV_INSTALLATION/components/VBoxRT.so
|
---|
82 | rm -f $PREV_INSTALLATION/components/VBoxDDU.so
|
---|
83 | rm -f $PREV_INSTALLATION/components/VBoxXPCOM.so
|
---|
84 |
|
---|
85 | # Remove udev description file
|
---|
86 | if [ -f /etc/udev/rules.d/60-vboxdrv.rules ]; then
|
---|
87 | rm -f /etc/udev/rules.d/60-vboxdrv.rules 2> /dev/null
|
---|
88 | fi
|
---|
89 | if [ -f /etc/udev/rules.d/10-vboxdrv.rules ]; then
|
---|
90 | rm -f /etc/udev/rules.d/10-vboxdrv.rules 2> /dev/null
|
---|
91 | fi
|
---|
92 |
|
---|
93 | cwd=`pwd`
|
---|
94 | if [ -f $PREV_INSTALLATION/src/Makefile ]; then
|
---|
95 | cd $PREV_INSTALLATION/src
|
---|
96 | make clean > /dev/null 2>&1
|
---|
97 | fi
|
---|
98 | if [ -f $PREV_INSTALLATION/src/vboxdrv/Makefile ]; then
|
---|
99 | cd $PREV_INSTALLATION/src/vboxdrv
|
---|
100 | make clean > /dev/null 2>&1
|
---|
101 | fi
|
---|
102 | if [ -f $PREV_INSTALLATION/src/vboxnetflt/Makefile ]; then
|
---|
103 | cd $PREV_INSTALLATION/src/vboxnetflt
|
---|
104 | make clean > /dev/null 2>&1
|
---|
105 | fi
|
---|
106 | if [ -f $PREV_INSTALLATION/src/vboxnetadp/Makefile ]; then
|
---|
107 | cd $PREV_INSTALLATION/src/vboxnetadp
|
---|
108 | make clean > /dev/null 2>&1
|
---|
109 | fi
|
---|
110 | cd $PREV_INSTALLATION
|
---|
111 | if [ -r $CONFIG_DIR/$CONFIG_FILES ]; then
|
---|
112 | rm -f `cat $CONFIG_DIR/$CONFIG_FILES` 2> /dev/null
|
---|
113 | elif [ -n "$DEFAULT_FILES" -a -r "$DEFAULT_FILES" ]; then
|
---|
114 | DEFAULT_FILE_NAMES=""
|
---|
115 | . $DEFAULT_FILES
|
---|
116 | for i in "$DEFAULT_FILE_NAMES"; do
|
---|
117 | rm -f $i 2> /dev/null
|
---|
118 | done
|
---|
119 | fi
|
---|
120 | for file in `find $PREV_INSTALLATION 2> /dev/null`; do
|
---|
121 | rmdir -p $file 2> /dev/null
|
---|
122 | done
|
---|
123 | cd $cwd
|
---|
124 | mkdir -p $PREV_INSTALLATION 2> /dev/null # The above actually removes the current directory and parents!
|
---|
125 | rmdir $PREV_INSTALLATION 2> /dev/null
|
---|
126 | rm -r $CONFIG_DIR/$CONFIG 2> /dev/null
|
---|
127 |
|
---|
128 | if [ -z "$VBOX_NO_UNINSTALL_MESSAGE" ]; then
|
---|
129 | rm -r $CONFIG_DIR/$CONFIG_FILES 2> /dev/null
|
---|
130 | rmdir $CONFIG_DIR 2> /dev/null
|
---|
131 | [ -n "$INSTALL_REV" ] && INSTALL_REV=" r$INSTALL_REV"
|
---|
132 | info "VirtualBox $INSTALL_VER$INSTALL_REV has been removed successfully."
|
---|
133 | log "Successfully $INSTALL_VER$INSTALL_REV removed VirtualBox."
|
---|
134 | fi
|
---|