postinst.in revision f5ab5688c35373443d953e2a9fa8a054defdece8
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync#!/bin/sh
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync#
0887a65d2e1f7d938381bed11e859caed56cb47evboxsync# Copyright (C) 2006-2010 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
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 # install udev rule (disable with INSTALL_NO_UDEV=1 in /etc/default/virtualbox)
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync if [ -d /etc/udev/rules.d -a "$INSTALL_NO_UDEV" != "1" ]; then
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync udev_call=""
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync udev_app=`which udevadm 2> /dev/null`
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync if [ $? -eq 0 ]; then
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync udev_call="${udev_app} version 2> /dev/null"
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync else
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync udev_app=`which udevinfo 2> /dev/null`
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync if [ $? -eq 0 ]; then
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync udev_call="${udev_app} -V 2> /dev/null"
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync fi
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync fi
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync udev_fix="="
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync if [ "${udev_call}" != "" ]; then
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync udev_out=`${udev_call}`
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync udev_ver=`expr "$udev_out" : '[^0-9]*\([0-9]*\)'`
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync if [ "$udev_ver" = "" -o "$udev_ver" -lt 55 ]; then
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync udev_fix=""
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync fi
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync fi
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync echo "KERNEL=${udev_fix}\"vboxdrv\", NAME=\"vboxdrv\", OWNER=\"root\", GROUP=\"root\", MODE=\"0600\"" \
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync > /etc/udev/rules.d/10-vboxdrv.rules
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync if [ "$INSTALL_NO_GROUP" != "1" ]; then
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync echo "SUBSYSTEM=${udev_fix}\"usb_device\", GROUP=\"vboxusers\", MODE=\"0664\"" \
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync >> /etc/udev/rules.d/10-vboxdrv.rules
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync echo "SUBSYSTEM=${udev_fix}\"usb\", ENV{DEVTYPE}==\"usb_device\", GROUP=\"vboxusers\", MODE=\"0664\"" \
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync >> /etc/udev/rules.d/10-vboxdrv.rules
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync else
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync echo "SUBSYSTEM=${udev_fix}\"usb_device\", GROUP=\"root\", MODE=\"0664\"" \
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync >> /etc/udev/rules.d/10-vboxdrv.rules
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync echo "SUBSYSTEM=${udev_fix}\"usb\", ENV{DEVTYPE}==\"usb_device\", GROUP=\"root\", MODE=\"0664\"" \
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync >> /etc/udev/rules.d/10-vboxdrv.rules
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync fi
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync fi
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync # Remove old udev description file
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync if [ -f /etc/udev/rules.d/60-vboxdrv.rules ]; then
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync rm -f /etc/udev/rules.d/60-vboxdrv.rules 2> /dev/null
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync fi
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync # Push the permissions to the USB device nodes. One of these should match.
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync # Rather nasty to use udevadm trigger for this, but I don't know of any
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync # better way.
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync udevadm trigger --subsystem-match=usb > /dev/null 2>&1
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync udevtrigger --subsystem-match=usb > /dev/null 2>&1
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync udevtrigger --subsystem-match=usb_device > /dev/null 2>&1
003bed4b86e46315aaef143a73c95eb8eee7fe78vboxsync udevplug -Busb > /dev/null 2>&1
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
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
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync # Start vboxdrv/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 # There might be an old module active (e.g. manually loaded)
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync if lsmod | grep -q "vboxdrv[^_-]"; then
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync /etc/init.d/vboxdrv stop || true
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync fi
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
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
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync if [ -x "/etc/init.d/vboxweb-service" ]; then
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync update-rc.d vboxweb-service defaults >/dev/null
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync# if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync# invoke-rc.d vboxweb-service start || exit $?
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync# else
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync# /etc/init.d/vboxweb-service start || exit $?
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync# fi
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync fi
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsyncfi # $1 = "configure"
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsyncexit 0