postinst.in revision 4a4856069da3a44c647c802b7df4f0c9ae1ea179
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync#!/bin/sh
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync#
f2ca52afeb0baed982c05e9d8591e0e4c7539dbdvboxsync# Copyright (C) 2006-2011 Oracle Corporation
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync#
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync# This file is part of VirtualBox Open Source Edition (OSE), as
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync# available from http://www.virtualbox.org. This file is free software;
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync# you can redistribute it and/or modify it under the terms of the GNU
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync# General Public License as published by the Free Software Foundation,
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync# in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync# distribution. VirtualBox OSE is distributed in the hope that it will
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync# be useful, but WITHOUT ANY WARRANTY of any kind.
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync#
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync# we can be called with the following arguments (6.5 of Debian policy):
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync# configure: (our version): installing/configuring new version
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync# abort-upgrade: (old version): upgrading to a new version failed
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync# abort-remove: (our version): removing this package failed
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync# abort-deconfigure: (our version): error during resolving conflicts
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync
4a4856069da3a44c647c802b7df4f0c9ae1ea179vboxsync#include installer-common.sh
4a4856069da3a44c647c802b7df4f0c9ae1ea179vboxsync
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsyncLOG="/var/log/vbox-install.log"
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync# defaults
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync[ -r /etc/default/virtualbox ] && . /etc/default/virtualbox
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsyncif [ "$1" = "configure" ]; then
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync # for debconf
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync . /usr/share/debconf/confmodule
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync db_version 2.0
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync # remove old cruft
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync if [ -f /etc/init.d/vboxdrv.sh ]; then
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync echo "Found old version of /etc/init.d/vboxdrv.sh, removing."
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync rm /etc/init.d/vboxdrv.sh
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync update-rc.d vboxdrv.sh remove >/dev/null
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync fi
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync if [ -f /etc/vbox/vbox.cfg ]; then
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync echo "Found old version of /etc/vbox/vbox.cfg, removing."
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync rm /etc/vbox/vbox.cfg
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync fi
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync # create users groups (disable with INSTALL_NO_GROUP=1 in /etc/default/virtualbox)
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync if [ "$INSTALL_NO_GROUP" != "1" ]; then
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync db_input low virtualbox/group-vboxusers || true
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync db_go || true
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync addgroup --system vboxusers || true
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync fi
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync
4a4856069da3a44c647c802b7df4f0c9ae1ea179vboxsync # install udev rule (disable with INSTALL_NO_UDEV=1 in
4a4856069da3a44c647c802b7df4f0c9ae1ea179vboxsync # /etc/default/virtualbox) and /dev/vboxdrv and /dev/vboxusb/*/* device nodes
4a4856069da3a44c647c802b7df4f0c9ae1ea179vboxsync install_device_node_setup root 0600 /usr/share/virtualbox "${usb_group}"
4a4856069da3a44c647c802b7df4f0c9ae1ea179vboxsync
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync # The starters need to be Suid root. They drop the privileges before starting
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync # the real frontend.
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync if ! dpkg-statoverride --list /usr/lib/virtualbox/VirtualBox > /dev/null 2>&1; then
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync chmod 4511 /usr/lib/virtualbox/VirtualBox
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync fi
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync if ! dpkg-statoverride --list /usr/lib/virtualbox/VBoxHeadless > /dev/null 2>&1; then
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync chmod 4511 /usr/lib/virtualbox/VBoxHeadless
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync fi
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync if ! dpkg-statoverride --list /usr/lib/virtualbox/VBoxSDL > /dev/null 2>&1; then
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync chmod 4511 /usr/lib/virtualbox/VBoxSDL
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync fi
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync if ! dpkg-statoverride --list /usr/lib/virtualbox/VBoxNetDHCP > /dev/null 2>&1; then
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync chmod 4511 /usr/lib/virtualbox/VBoxNetDHCP
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync fi
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync if ! dpkg-statoverride --list /usr/lib/virtualbox/VBoxNetAdpCtl > /dev/null 2>&1; then
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync chmod 4511 /usr/lib/virtualbox/VBoxNetAdpCtl
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync fi
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync # if INSTALL_NO_VBOXDRV is set to 1, remove all shipped modules
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync if [ "$INSTALL_NO_VBOXDRV" = "1" ]; then
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync rm -f /lib/modules/*/misc/vboxdrv.ko
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync rm -f /lib/modules/*/misc/vboxnetflt.ko
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync rm -f /lib/modules/*/misc/vboxnetadp.ko
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync fi
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsyncfi # $1 = "configure"
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync#DEBHELPER#
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsyncif [ "$1" = "configure" ]; then
f2ca52afeb0baed982c05e9d8591e0e4c7539dbdvboxsync # Start vboxdrv/vboxballoonctrl/vboxweb-service manually as we use our own error handling in postrm
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync if [ -x "/etc/init.d/vboxdrv" ]; then
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync update-rc.d vboxdrv defaults >/dev/null
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync BUILD_MODULES=0
f5ab5688c35373443d953e2a9fa8a054defdece8vboxsync REGISTER_MODULES=1
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync # Disable module compilation with INSTALL_NO_VBOXDRV=1 in /etc/default/virtualbox
f5ab5688c35373443d953e2a9fa8a054defdece8vboxsync if [ ! -f /lib/modules/`uname -r`/misc/vboxdrv.ko ]; then
f5ab5688c35373443d953e2a9fa8a054defdece8vboxsync REGISTER_MODULES=0
f5ab5688c35373443d953e2a9fa8a054defdece8vboxsync if [ "$INSTALL_NO_VBOXDRV" != "1" ]; then
f5ab5688c35373443d953e2a9fa8a054defdece8vboxsync db_get virtualbox/module-compilation-allowed
f5ab5688c35373443d953e2a9fa8a054defdece8vboxsync if [ "$RET" = "false" ]; then
f5ab5688c35373443d953e2a9fa8a054defdece8vboxsync cat << EOF
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsyncUnable to find a precompiled module for the current kernel
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsyncthough module compilation denied by debconf setting.
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsyncEOF
f5ab5688c35373443d953e2a9fa8a054defdece8vboxsync else
f5ab5688c35373443d953e2a9fa8a054defdece8vboxsync db_input low virtualbox/module-compilation-allowed || true
f5ab5688c35373443d953e2a9fa8a054defdece8vboxsync db_go || true
f5ab5688c35373443d953e2a9fa8a054defdece8vboxsync db_get virtualbox/module-compilation-allowed
f5ab5688c35373443d953e2a9fa8a054defdece8vboxsync if [ "$RET" = "true" ]; then
f5ab5688c35373443d953e2a9fa8a054defdece8vboxsync BUILD_MODULES=1
f5ab5688c35373443d953e2a9fa8a054defdece8vboxsync fi
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync fi
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync fi
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync fi
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync
f5ab5688c35373443d953e2a9fa8a054defdece8vboxsync if [ $BUILD_MODULES -eq 1 ]; then
f5ab5688c35373443d953e2a9fa8a054defdece8vboxsync if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync invoke-rc.d vboxdrv setup || true
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync else
f5ab5688c35373443d953e2a9fa8a054defdece8vboxsync /etc/init.d/vboxdrv setup || true
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync fi
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync else
f5ab5688c35373443d953e2a9fa8a054defdece8vboxsync # shipped modules found, register sources at DKMS anyway
0c587d7af645db20acefebcfc15b6f46c440ba4avboxsync if lsmod | grep -q "vboxdrv[^_-]"; then
0c587d7af645db20acefebcfc15b6f46c440ba4avboxsync /etc/init.d/vboxdrv stop || true
0c587d7af645db20acefebcfc15b6f46c440ba4avboxsync fi
f5ab5688c35373443d953e2a9fa8a054defdece8vboxsync if [ $REGISTER_MODULES -eq 1 ]; then
f5ab5688c35373443d953e2a9fa8a054defdece8vboxsync DKMS=`which dkms 2>/dev/null`
f5ab5688c35373443d953e2a9fa8a054defdece8vboxsync if [ -n "$DKMS" ]; then
f5ab5688c35373443d953e2a9fa8a054defdece8vboxsync $DKMS add -m vboxhost -v %VER% > /dev/null 2>&1 || true
f5ab5688c35373443d953e2a9fa8a054defdece8vboxsync fi
f5ab5688c35373443d953e2a9fa8a054defdece8vboxsync fi
f5ab5688c35373443d953e2a9fa8a054defdece8vboxsync if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
f5ab5688c35373443d953e2a9fa8a054defdece8vboxsync invoke-rc.d vboxdrv start || exit $?
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync else
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync /etc/init.d/vboxdrv start || exit $?
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync fi
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync fi
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync fi
f2ca52afeb0baed982c05e9d8591e0e4c7539dbdvboxsync if [ -x "/etc/init.d/vboxballoonctrl-service" ]; then
f2ca52afeb0baed982c05e9d8591e0e4c7539dbdvboxsync update-rc.d vboxballoonctrl-service defaults >/dev/null
f2ca52afeb0baed982c05e9d8591e0e4c7539dbdvboxsync if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
f2ca52afeb0baed982c05e9d8591e0e4c7539dbdvboxsync invoke-rc.d vboxballoonctrl-service start || exit $?
f2ca52afeb0baed982c05e9d8591e0e4c7539dbdvboxsync else
f2ca52afeb0baed982c05e9d8591e0e4c7539dbdvboxsync /etc/init.d/vboxballoonctrl-service start || exit $?
f2ca52afeb0baed982c05e9d8591e0e4c7539dbdvboxsync fi
f2ca52afeb0baed982c05e9d8591e0e4c7539dbdvboxsync fi
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync if [ -x "/etc/init.d/vboxweb-service" ]; then
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync update-rc.d vboxweb-service defaults >/dev/null
4ab3529cde8c5258f459eeb71a532d1ba522111avboxsync if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
4ab3529cde8c5258f459eeb71a532d1ba522111avboxsync invoke-rc.d vboxweb-service start || exit $?
4ab3529cde8c5258f459eeb71a532d1ba522111avboxsync else
4ab3529cde8c5258f459eeb71a532d1ba522111avboxsync /etc/init.d/vboxweb-service start || exit $?
4ab3529cde8c5258f459eeb71a532d1ba522111avboxsync fi
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync fi
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsyncfi # $1 = "configure"
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsyncexit 0