prerm.in revision f2ca52afeb0baed982c05e9d8591e0e4c7539dbd
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync#!/bin/sh
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync#
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync# Copyright (C) 2006-2010 Oracle Corporation
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync#
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync# This file is part of VirtualBox Open Source Edition (OSE), as
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync# available from http://www.virtualbox.org. This file is free software;
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync# you can redistribute it and/or modify it under the terms of the GNU
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync# General Public License as published by the Free Software Foundation,
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync# in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync# distribution. VirtualBox OSE is distributed in the hope that it will
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync# be useful, but WITHOUT ANY WARRANTY of any kind.
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync#
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync# we can be called with the following arguments (6.5 of Debian policy):
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync# upgrade: (new version): upgrade to a new version
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync# failed-upgrade: (our version): failed to upgrade
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync# remove: (our version): remove this package
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync# purge: (our version): purge this package
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync# deconfigure: (our version): removing conflicting version
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsyncrm -f /etc/udev/rules.d/10-vboxdrv.rules
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsyncrm -f /etc/vbox/license_agreed
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsyncrm -f /etc/vbox/module_not_compiled
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync# remove our USB device tree
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsyncrm -rf /dev/vboxusb 2> /dev/null
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync# defaults
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync[ -r /etc/default/virtualbox ] && . /etc/default/virtualbox
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsyncif [ "$1" = "upgrade" -o "$1" = "remove" -o "$1" = "failed-upgrade" ]; then
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync . /usr/share/debconf/confmodule
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync db_version 2.0
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync db_capb backup
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync # check for active VMs
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync VBOXSVC_PID=`pidof VBoxSVC 2>/dev/null`
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync if [ -n "$VBOXSVC_PID" ]; then
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync # try graceful termination; terminate the balloon control servic first
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync invoke-rc.d vboxballoonctrl-service stop || true
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync else
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync /etc/init.d/vboxballoonctrl-service stop || true
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync fi
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync # try graceful termination; terminate the webservice first
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync invoke-rc.d vboxweb-service stop || true
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync else
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync /etc/init.d/vboxweb-service stop || true
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync fi
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync kill -USR1 $VBOXSVC_PID
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync sleep 1
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync if pidof VBoxSVC > /dev/null 2>&1; then
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync if [ "$1" != "failed-upgrade" ]; then
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync db_fset virtualbox/old-running seen false || true
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync db_input critical virtualbox/old-running || true
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync db_go || true
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync fi
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync exit 1
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync fi
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync fi
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsyncfi
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync# make sure we de-register the DMKS modules before the files get removed
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsyncif [ "$1" = "upgrade" -o "$1" = "remove" -o "$1" = "deconfigure" ]; then
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync DKMS=`which dkms 2>/dev/null`
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync if [ -n "$DKMS" ]; then
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync $DKMS remove -m vboxhost -v %VER% --all > /dev/null 2>&1 || true
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync fi
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsyncfi
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync# stop vboxnet/vboxdrv manually as we use our own error handling in postrm
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsyncif [ -x "/etc/init.d/vboxdrv" ]; then
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync invoke-rc.d vboxdrv stop || exit $?
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync else
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync /etc/init.d/vboxdrv stop || exit $?
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync fi
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsyncfi
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsyncif [ -x "/etc/init.d/vboxnet" ]; then
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync invoke-rc.d vboxnet stop || exit $?
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync else
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync /etc/init.d/vboxnet stop || exit $?
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync fi
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsyncfi
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync#DEBHELPER#
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsyncexit 0
8c48cf39dfb84c1f26e0e7fbd1c407e25a34eef1vboxsync