1 | #!/bin/sh
|
---|
2 |
|
---|
3 | #
|
---|
4 | # Copyright (C) 2006-2010 Oracle Corporation
|
---|
5 | #
|
---|
6 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
7 | # available from http://www.virtualbox.org. This file is free software;
|
---|
8 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
9 | # General Public License as published by the Free Software Foundation,
|
---|
10 | # in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
11 | # distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
12 | # be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
13 | #
|
---|
14 |
|
---|
15 | # we can be called with the following arguments (6.5 of Debian policy):
|
---|
16 | # upgrade: (new version): upgrade to a new version
|
---|
17 | # failed-upgrade: (our version): failed to upgrade
|
---|
18 | # remove: (our version): remove this package
|
---|
19 | # purge: (our version): purge this package
|
---|
20 | # deconfigure: (our version): removing conflicting version
|
---|
21 |
|
---|
22 | rm -f /etc/udev/rules.d/10-vboxdrv.rules
|
---|
23 | rm -f /etc/vbox/license_agreed
|
---|
24 | rm -f /etc/vbox/module_not_compiled
|
---|
25 |
|
---|
26 | # defaults
|
---|
27 | [ -r /etc/default/virtualbox ] && . /etc/default/virtualbox
|
---|
28 |
|
---|
29 | if [ "$1" = "upgrade" -o "$1" = "remove" -o "$1" = "failed-upgrade" ]; then
|
---|
30 | . /usr/share/debconf/confmodule
|
---|
31 | db_version 2.0
|
---|
32 | db_capb backup
|
---|
33 |
|
---|
34 | # check for active VMs
|
---|
35 | VBOXSVC_PID=`pidof VBoxSVC 2>/dev/null`
|
---|
36 | if [ -n "$VBOXSVC_PID" ]; then
|
---|
37 | # try graceful termination; terminate the webservice first
|
---|
38 | if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
|
---|
39 | invoke-rc.d vboxweb-service stop || true
|
---|
40 | else
|
---|
41 | /etc/init.d/vboxweb-service stop || true
|
---|
42 | fi
|
---|
43 | kill -USR1 $VBOXSVC_PID
|
---|
44 | sleep 1
|
---|
45 | if pidof VBoxSVC > /dev/null 2>&1; then
|
---|
46 | if [ "$1" != "failed-upgrade" ]; then
|
---|
47 | db_fset virtualbox/old-running seen false || true
|
---|
48 | db_input critical virtualbox/old-running || true
|
---|
49 | db_go || true
|
---|
50 | fi
|
---|
51 | exit 1
|
---|
52 | fi
|
---|
53 | fi
|
---|
54 | fi
|
---|
55 |
|
---|
56 | # make sure we de-register the DMKS modules before the files get removed
|
---|
57 | if [ "$1" = "upgrade" -o "$1" = "remove" -o "$1" = "deconfigure" ]; then
|
---|
58 | DKMS=`which dkms 2>/dev/null`
|
---|
59 | if [ -n "$DKMS" ]; then
|
---|
60 | $DKMS remove -m vboxhost -v %VER% --all > /dev/null 2>&1 || true
|
---|
61 | fi
|
---|
62 | fi
|
---|
63 |
|
---|
64 | # Stop vboxnet/vboxdrv manually as we use our own error handling in postrm
|
---|
65 | if [ -x "/etc/init.d/vboxdrv" ]; then
|
---|
66 | if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
|
---|
67 | invoke-rc.d vboxdrv stop || exit $?
|
---|
68 | else
|
---|
69 | /etc/init.d/vboxdrv stop || exit $?
|
---|
70 | fi
|
---|
71 | fi
|
---|
72 | if [ -x "/etc/init.d/vboxnet" ]; then
|
---|
73 | if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
|
---|
74 | invoke-rc.d vboxnet stop || exit $?
|
---|
75 | else
|
---|
76 | /etc/init.d/vboxnet stop || exit $?
|
---|
77 | fi
|
---|
78 | fi
|
---|
79 |
|
---|
80 | #DEBHELPER#
|
---|
81 |
|
---|
82 | exit 0
|
---|