postinst.in revision 7eaaa8a4480370b82ef3735994f986f338fb4df2
#!/bin/sh
#
# Copyright (C) 2006-2010 Oracle Corporation
#
# This file is part of VirtualBox Open Source Edition (OSE), as
# available from http://www.virtualbox.org. This file is free software;
# you can redistribute it and/or modify it under the terms of the GNU
# General Public License as published by the Free Software Foundation,
# in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
# distribution. VirtualBox OSE is distributed in the hope that it will
# be useful, but WITHOUT ANY WARRANTY of any kind.
#
# we can be called with the following arguments (6.5 of Debian policy):
# configure: (our version): installing/configuring new version
# abort-upgrade: (old version): upgrading to a new version failed
# abort-remove: (our version): removing this package failed
# abort-deconfigure: (our version): error during resolving conflicts
LOG="/var/log/vbox-install.log"
# defaults
[ -r /etc/default/virtualbox ] && . /etc/default/virtualbox
if [ "$1" = "configure" ]; then
# for debconf
. /usr/share/debconf/confmodule
db_version 2.0
# remove old cruft
if [ -f /etc/init.d/vboxdrv.sh ]; then
echo "Found old version of /etc/init.d/vboxdrv.sh, removing."
rm /etc/init.d/vboxdrv.sh
update-rc.d vboxdrv.sh remove >/dev/null
fi
if [ -f /etc/vbox/vbox.cfg ]; then
echo "Found old version of /etc/vbox/vbox.cfg, removing."
rm /etc/vbox/vbox.cfg
fi
# install udev rule (disable with INSTALL_NO_UDEV=1 in /etc/default/virtualbox)
if [ -d /etc/udev/rules.d -a "$INSTALL_NO_UDEV" != "1" ]; then
udev_call=""
udev_app=`which udevadm 2> /dev/null`
if [ $? -eq 0 ]; then
udev_call="${udev_app} version 2> /dev/null"
else
udev_app=`which udevinfo 2> /dev/null`
if [ $? -eq 0 ]; then
udev_call="${udev_app} -V 2> /dev/null"
fi
fi
udev_fix="="
if [ "${udev_call}" != "" ]; then
udev_out=`${udev_call}`
udev_ver=`expr "$udev_out" : '[^0-9]*\([0-9]*\)'`
if [ "$udev_ver" = "" -o "$udev_ver" -lt 55 ]; then
udev_fix=""
fi
fi
echo "KERNEL=${udev_fix}\"vboxdrv\", NAME=\"vboxdrv\", OWNER=\"root\", GROUP=\"root\", MODE=\"0600\"" \
> /etc/udev/rules.d/10-vboxdrv.rules
if [ "$INSTALL_NO_GROUP" != "1" ]; then
echo "SUBSYSTEM=${udev_fix}\"usb_device\", GROUP=\"vboxusers\", MODE=\"0664\"" \
>> /etc/udev/rules.d/10-vboxdrv.rules
echo "SUBSYSTEM=${udev_fix}\"usb\", ENV{DEVTYPE}==\"usb_device\", GROUP=\"vboxusers\", MODE=\"0664\"" \
>> /etc/udev/rules.d/10-vboxdrv.rules
else
echo "SUBSYSTEM=${udev_fix}\"usb_device\", GROUP=\"root\", MODE=\"0664\"" \
>> /etc/udev/rules.d/10-vboxdrv.rules
echo "SUBSYSTEM=${udev_fix}\"usb\", ENV{DEVTYPE}==\"usb_device\", GROUP=\"root\", MODE=\"0664\"" \
>> /etc/udev/rules.d/10-vboxdrv.rules
fi
fi
# Remove old udev description file
if [ -f /etc/udev/rules.d/60-vboxdrv.rules ]; then
rm -f /etc/udev/rules.d/60-vboxdrv.rules 2> /dev/null
fi
# Push the permissions to the USB device nodes. One of these should match.
# Rather nasty to use udevadm trigger for this, but I don't know of any
# better way.
udevadm trigger --subsystem-match=usb > /dev/null 2>&1
udevtrigger --subsystem-match=usb > /dev/null 2>&1
udevtrigger --subsystem-match=usb_device > /dev/null 2>&1
udevplug -Busb > /dev/null 2>&1
# create users groups (disable with INSTALL_NO_GROUP=1 in /etc/default/virtualbox)
if [ "$INSTALL_NO_GROUP" != "1" ]; then
db_input low virtualbox/group-vboxusers || true
db_go || true
addgroup --system vboxusers || true
fi
# The starters need to be Suid root. They drop the privileges before starting
# the real frontend.
if ! dpkg-statoverride --list /usr/lib/virtualbox/VirtualBox > /dev/null 2>&1; then
chmod 4511 /usr/lib/virtualbox/VirtualBox
fi
if ! dpkg-statoverride --list /usr/lib/virtualbox/VBoxHeadless > /dev/null 2>&1; then
chmod 4511 /usr/lib/virtualbox/VBoxHeadless
fi
if ! dpkg-statoverride --list /usr/lib/virtualbox/VBoxSDL > /dev/null 2>&1; then
chmod 4511 /usr/lib/virtualbox/VBoxSDL
fi
if ! dpkg-statoverride --list /usr/lib/virtualbox/VBoxNetDHCP > /dev/null 2>&1; then
chmod 4511 /usr/lib/virtualbox/VBoxNetDHCP
fi
if ! dpkg-statoverride --list /usr/lib/virtualbox/VBoxNetAdpCtl > /dev/null 2>&1; then
chmod 4511 /usr/lib/virtualbox/VBoxNetAdpCtl
fi
# if INSTALL_NO_VBOXDRV is set to 1, remove all shipped modules
if [ "$INSTALL_NO_VBOXDRV" = "1" ]; then
rm -f /lib/modules/*/misc/vboxdrv.ko
rm -f /lib/modules/*/misc/vboxnetflt.ko
rm -f /lib/modules/*/misc/vboxnetadp.ko
fi
fi # $1 = "configure"
#DEBHELPER#
if [ "$1" = "configure" ]; then
# Start vboxdrv/vboxweb-service manually as we use our own error handling in postrm
if [ -x "/etc/init.d/vboxdrv" ]; then
update-rc.d vboxdrv defaults >/dev/null
# There might be an old module active (e.g. manually loaded)
if lsmod | grep -q "vboxdrv[^_-]"; then
/etc/init.d/vboxdrv stop || true
fi
BUILD_MODULES=0
# Disable module compilation with INSTALL_NO_VBOXDRV=1 in /etc/default/virtualbox
if [ ! -f /lib/modules/`uname -r`/misc/vboxdrv.ko -a "$INSTALL_NO_VBOXDRV" != "1" ]; then
db_get virtualbox/module-compilation-allowed
if [ "$RET" = "false" ]; then
cat << EOF
Unable to find a precompiled module for the current kernel
though module compilation denied by debconf setting.
EOF
else
db_input low virtualbox/module-compilation-allowed || true
db_go || true
db_get virtualbox/module-compilation-allowed
if [ "$RET" = "true" ]; then
BUILD_MODULES=1
fi
fi
fi
if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
if [ $BUILD_MODULES -eq 1 ]; then
invoke-rc.d vboxdrv setup || true
else
invoke-rc.d vboxdrv start || exit $?
fi
else
if [ $BUILD_MODULES -eq 1 ]; then
/etc/init.d/vboxdrv setup || true
else
/etc/init.d/vboxdrv start || exit $?
fi
fi
fi
if [ -x "/etc/init.d/vboxweb-service" ]; then
update-rc.d vboxweb-service defaults >/dev/null
# if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
# invoke-rc.d vboxweb-service start || exit $?
# else
# /etc/init.d/vboxweb-service start || exit $?
# fi
fi
fi # $1 = "configure"
exit 0