1 | #!/bin/bash
|
---|
2 | #
|
---|
3 | # Copyright (C) 2006-2015 Oracle Corporation
|
---|
4 | #
|
---|
5 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
6 | # available from http://www.virtualbox.org. This file is free software;
|
---|
7 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
8 | # General Public License (GPL) as published by the Free Software
|
---|
9 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
10 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
11 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
12 | #
|
---|
13 |
|
---|
14 | # we can be called with the following arguments (6.5 of Debian policy):
|
---|
15 | # install: (our version): install our version
|
---|
16 | # upgrade: (our version): upgrade to our version
|
---|
17 | # abort-upgrade: (old version): upgrade to a new version failed
|
---|
18 |
|
---|
19 | # defaults
|
---|
20 | [ -r /etc/default/virtualbox ] && . /etc/default/virtualbox
|
---|
21 |
|
---|
22 | if [ "$1" = "install" -o "$1" = "upgrade" ]; then
|
---|
23 |
|
---|
24 | . /usr/share/debconf/confmodule
|
---|
25 | db_version 2.0
|
---|
26 | db_capb backup
|
---|
27 |
|
---|
28 | # check for old installation
|
---|
29 | if [ -r /etc/vbox/vbox.cfg ]; then
|
---|
30 | . /etc/vbox/vbox.cfg
|
---|
31 | if [ "x$INSTALL_DIR" != "x" -a -d "$INSTALL_DIR" ]; then
|
---|
32 | db_fset virtualbox/old-installation-found seen false || true
|
---|
33 | db_input critical virtualbox/old-installation-found || true
|
---|
34 | db_go || true
|
---|
35 | exit 1
|
---|
36 | fi
|
---|
37 | # we will remove that file in postinst
|
---|
38 | fi
|
---|
39 |
|
---|
40 | # check for active VMs
|
---|
41 | # Execute the installed package's pre-uninstaller if present.
|
---|
42 | /usr/lib/virtualbox/prerm-common.sh 2>/dev/null || true
|
---|
43 | # Stop services from older versions without pre-uninstaller.
|
---|
44 | invoke-rc.d vboxballoonctrl-service stop 2>/dev/null || true
|
---|
45 | /etc/init.d/vboxballoonctrl-service stop 2>/dev/null || true
|
---|
46 | invoke-rc.d vboxautostart-service stop 2>/dev/null || true
|
---|
47 | /etc/init.d/vboxautostart-service stop 2>/dev/null || true
|
---|
48 | invoke-rc.d vboxweb-service stop 2>/dev/null || true
|
---|
49 | /etc/init.d/vboxweb-service stop 2>/dev/null || true
|
---|
50 | VBOXSVC_PID=`pidof VBoxSVC 2>/dev/null || true`
|
---|
51 | if [ -n "$VBOXSVC_PID" ]; then
|
---|
52 | # ask the daemon to terminate immediately
|
---|
53 | kill -USR1 $VBOXSVC_PID
|
---|
54 | sleep 1
|
---|
55 | if pidof VBoxSVC > /dev/null 2>&1; then
|
---|
56 | db_fset virtualbox/old-running seen false || true
|
---|
57 | db_input critical virtualbox/old-running || true
|
---|
58 | db_go || true
|
---|
59 | exit 1
|
---|
60 | fi
|
---|
61 | fi
|
---|
62 |
|
---|
63 | # check for old vboxdrv modules
|
---|
64 | if [ "$INSTALL_NO_VBOXDRV" != "1" ]; then
|
---|
65 | if find /lib/modules -name "vboxdrv\.*" 2>/dev/null|grep -q vboxdrv; then
|
---|
66 | # old modules found
|
---|
67 | db_get virtualbox/delete-old-modules || true
|
---|
68 | if [ "$RET" = "false" ]; then
|
---|
69 | cat << EOF
|
---|
70 | Old vboxdrv kernel modules found in
|
---|
71 | EOF
|
---|
72 | find /lib/modules -name "vboxdrv\.*" 2>/dev/null|sed "s+\(.*\)+ \1+g"
|
---|
73 | cat << EOF
|
---|
74 | Removing of these modules denied by debconf setting
|
---|
75 | EOF
|
---|
76 | else
|
---|
77 | db_input low virtualbox/delete-old-modules || true
|
---|
78 | db_go || true
|
---|
79 | db_get virtualbox/delete-old-modules || true
|
---|
80 | if [ "$RET" = "true" ]; then
|
---|
81 | for i in /lib/modules/*; do
|
---|
82 | if test -e "${i}/misc/vboxdrv.ko"; then
|
---|
83 | rm -f "${i}/misc/vboxdrv.ko" "${i}/misc/vboxnetadp.ko" \
|
---|
84 | "${i}/misc/vboxnetflt.ko" "${i}/misc/vboxpci.ko"
|
---|
85 | # Remove the kernel version folder if it was empty except for us.
|
---|
86 | test "`echo ${i}/misc/* ${i}/misc/.?* ${i}/* ${i}/.?*`" = \
|
---|
87 | "${i}/misc/* ${i}/misc/.. ${i}/misc ${i}/.." &&
|
---|
88 | rmdir "${i}/misc" "${i}" # We used to leave empty folders.
|
---|
89 | fi
|
---|
90 | done
|
---|
91 | fi
|
---|
92 | fi
|
---|
93 | fi
|
---|
94 | fi
|
---|
95 |
|
---|
96 | fi # "$1" = "install" -o "$1" = "upgrade"
|
---|
97 |
|
---|
98 | #DEBHELPER#
|
---|
99 |
|
---|