postinst revision 5b802b5e11fed6e163afca32e9118d2599d312fb
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync#!/bin/sh
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync#
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync# Copyright (C) 2006-2007 Sun Microsystems, Inc.
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync#
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync# This file is part of VirtualBox Open Source Edition (OSE), as
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync# available from http://www.virtualbox.org. This file is free software;
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync# you can redistribute it and/or modify it under the terms of the GNU
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync# General Public License as published by the Free Software Foundation,
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync# in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync# distribution. VirtualBox OSE is distributed in the hope that it will
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync# be useful, but WITHOUT ANY WARRANTY of any kind.
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync#
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync
085bc29163eb87e345acaae02789e4c233d51f3bvboxsyncLOG="/var/log/vbox-install.log"
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync# for debconf
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync. /usr/share/debconf/confmodule
085bc29163eb87e345acaae02789e4c233d51f3bvboxsyncdb_version 2.0
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync# remove old cruft
085bc29163eb87e345acaae02789e4c233d51f3bvboxsyncif [ -f /etc/init.d/vboxdrv.sh ]; then
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync echo "Found old version of /etc/init.d/vboxdrv.sh, removing."
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync rm /etc/init.d/vboxdrv.sh
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync update-rc.d vboxdrv.sh remove >/dev/null
085bc29163eb87e345acaae02789e4c233d51f3bvboxsyncfi
085bc29163eb87e345acaae02789e4c233d51f3bvboxsyncif [ -f /etc/init.d/virtualbox ]; then
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync echo "Found old version of /etc/init.d/virtualbox, removing."
0de1998ac52682bb5322df476e45f237265ea9b7vboxsync rm /etc/init.d/virtualbox
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync update-rc.d virtualbox remove >/dev/null
085bc29163eb87e345acaae02789e4c233d51f3bvboxsyncfi
085bc29163eb87e345acaae02789e4c233d51f3bvboxsyncif [ -f /etc/vbox/vbox.cfg ]; then
af62929dce3cc5e14c75438cd2b893f82ae6dbc8vboxsync echo "Found old version of /etc/vbox/vbox.cfg, removing."
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync rm /etc/vbox/vbox.cfg
0ae258e7d0d2520036514d896a9eea58bf285f03vboxsyncfi
83fd17a3a00dc7bf6a36e23bbd2393dfc953da06vboxsync
0ae258e7d0d2520036514d896a9eea58bf285f03vboxsync# install udev rule
0ae258e7d0d2520036514d896a9eea58bf285f03vboxsyncif [ -d /etc/udev/rules.d ]; then
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync udev_out=`udevinfo -V 2> /dev/null`
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync udev_ver=`expr "$udev_out" : '[^0-9]*\([0-9]*\)'`
04e845ee9ef813501cd2570a4188cb852d170408vboxsync if [ "$udev_ver" = "" -o "$udev_ver" -lt 55 ]; then
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync echo 'KERNEL="vboxdrv", NAME="vboxdrv", OWNER="root", GROUP="vboxusers", MODE="0660"' \
04e845ee9ef813501cd2570a4188cb852d170408vboxsync > /etc/udev/rules.d/60-vboxdrv.rules
04e845ee9ef813501cd2570a4188cb852d170408vboxsync else
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync echo 'KERNEL=="vboxdrv", NAME="vboxdrv", OWNER="root", GROUP="vboxusers", MODE="0660"' \
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync > /etc/udev/rules.d/60-vboxdrv.rules
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync fi
085bc29163eb87e345acaae02789e4c233d51f3bvboxsyncfi
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync# create users groups
085bc29163eb87e345acaae02789e4c233d51f3bvboxsyncdb_input high virtualbox-ose/group-vboxusers || true
085bc29163eb87e345acaae02789e4c233d51f3bvboxsyncdb_go || true
085bc29163eb87e345acaae02789e4c233d51f3bvboxsyncaddgroup --system vboxusers
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync
085bc29163eb87e345acaae02789e4c233d51f3bvboxsyncif [ ! -f /lib/modules/`uname -r`/misc/vboxdrv.ko ]; then
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync db_get virtualbox-ose/module-compilation-allowed
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync if [ "$RET" = "false" ]; then
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync cat << EOF
085bc29163eb87e345acaae02789e4c233d51f3bvboxsyncUnable to find a precompiled module for the current kernel
085bc29163eb87e345acaae02789e4c233d51f3bvboxsyncthough module compilation denied by debconf setting.
085bc29163eb87e345acaae02789e4c233d51f3bvboxsyncEOF
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync else
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync db_input critical virtualbox-ose/module-compilation-allowed || true
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync db_go || true
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync db_get virtualbox-ose/module-compilation-allowed
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync if [ "$RET" = "true" ]; then
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync # Compile module. Don't show a message box here if everything works well.
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync cat << EOF
085bc29163eb87e345acaae02789e4c233d51f3bvboxsyncMessages emitted during module compilation will be logged to $LOG.
085bc29163eb87e345acaae02789e4c233d51f3bvboxsyncEOF
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync if ! /usr/share/virtualbox-ose/src/build_in_tmp install > /var/log/vbox-install.log 2>&1; then
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync db_fset virtualbox-ose/module-compilation-failed seen false
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync db_input critical virtualbox-ose/module-compilation-failed || true
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync db_go || true
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync touch /etc/vbox/module_not_compiled
7e77c8f54449be6f28ccbf32f7e651554d9f4060vboxsync # don't abort the installation!
7e77c8f54449be6f28ccbf32f7e651554d9f4060vboxsync else
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync # success
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync cat << EOF
d9d070cfd2c99624fe6974842b7ad4a30d5b71e7vboxsyncSuccess!
d9d070cfd2c99624fe6974842b7ad4a30d5b71e7vboxsyncEOF
d9d070cfd2c99624fe6974842b7ad4a30d5b71e7vboxsync rm -f /etc/vbox/module_not_compiled
0de1998ac52682bb5322df476e45f237265ea9b7vboxsync fi
085bc29163eb87e345acaae02789e4c233d51f3bvboxsync fi
0de1998ac52682bb5322df476e45f237265ea9b7vboxsync fi
04e845ee9ef813501cd2570a4188cb852d170408vboxsyncfi
d9d070cfd2c99624fe6974842b7ad4a30d5b71e7vboxsync
af62929dce3cc5e14c75438cd2b893f82ae6dbc8vboxsync# There might be an old module active (e.g. manually loaded)
af62929dce3cc5e14c75438cd2b893f82ae6dbc8vboxsyncif lsmod | grep -q "vboxdrv[^_-]"; then
83fd17a3a00dc7bf6a36e23bbd2393dfc953da06vboxsync /etc/init.d/vboxdrv stop || true
04e845ee9ef813501cd2570a4188cb852d170408vboxsyncfi
0de1998ac52682bb5322df476e45f237265ea9b7vboxsync
0de1998ac52682bb5322df476e45f237265ea9b7vboxsync#DEBHELPER#
0de1998ac52682bb5322df476e45f237265ea9b7vboxsync
0de1998ac52682bb5322df476e45f237265ea9b7vboxsyncexit 0
0de1998ac52682bb5322df476e45f237265ea9b7vboxsync