installer-common.sh revision 3a57b442195315f0e98e6e9b56ee1dc198cb9ce7
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync# Oracle VM VirtualBox
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync# VirtualBox installer shell routines
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync# Copyright (C) 2007-2011 Oracle Corporation
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync# This file is part of VirtualBox Open Source Edition (OSE), as
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync# available from http://www.virtualbox.org. This file is free software;
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync# you can redistribute it and/or modify it under the terms of the GNU
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync# General Public License (GPL) as published by the Free Software
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync# Foundation, in version 2 as it comes in the "COPYING" file of the
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync## @todo Make this file into a script in the VirtualBox lib directory once
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync# enough code has been made shared between the different installers.
a9b62afc62b28da7a1a77f34259f8013892d9664vboxsync# This is used for unit testing and will be reset after the file is sourced for
a9b62afc62b28da7a1a77f34259f8013892d9664vboxsync# test runs.
a9b62afc62b28da7a1a77f34259f8013892d9664vboxsync echo "KERNEL==\"vboxdrv\", NAME=\"vboxdrv\", OWNER=\"root\", GROUP=\"$VBOXDRV_GRP\", MODE=\"$VBOXDRV_MODE\""
a9b62afc62b28da7a1a77f34259f8013892d9664vboxsync echo "SUBSYSTEM==\"usb_device\", ACTION==\"add\", RUN+=\"$INSTALLATION_DIR/VBoxCreateUSBNode.sh \$major \$minor \$attr{bDeviceClass}${USB_GROUP}\""
a9b62afc62b28da7a1a77f34259f8013892d9664vboxsync echo "SUBSYSTEM==\"usb\", ACTION==\"add\", ENV{DEVTYPE}==\"usb_device\", RUN+=\"$INSTALLATION_DIR/VBoxCreateUSBNode.sh \$major \$minor \$attr{bDeviceClass}${USB_GROUP}\""
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync echo "SUBSYSTEM==\"usb_device\", ACTION==\"remove\", RUN+=\"$INSTALLATION_DIR/VBoxCreateUSBNode.sh --remove \$major \$minor\""
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync echo "SUBSYSTEM==\"usb\", ACTION==\"remove\", ENV{DEVTYPE}==\"usb_device\", RUN+=\"$INSTALLATION_DIR/VBoxCreateUSBNode.sh --remove \$major \$minor\""
492de26ad701185b6f6cf63eb346b34a4440268dvboxsync VBOXDRV_GRP="$1" # The group owning the vboxdrv device
878731e72e401b7e2a0434e5ab36ca633c7f2586vboxsync VBOXDRV_MODE="$2" # The access mode for the vboxdrv device
326456b8d1aba5e9371d8ede11afd67ab132f2eavboxsync INSTALLATION_DIR="$3" # The directory VirtualBox is installed in
878731e72e401b7e2a0434e5ab36ca633c7f2586vboxsync USB_GROUP="$4" # The group that has permission to access USB devices
492de26ad701185b6f6cf63eb346b34a4440268dvboxsync NO_INSTALL="$5" # Set this to "1" to remove but not re-install rules
326456b8d1aba5e9371d8ede11afd67ab132f2eavboxsync UDEV_STRING="$6" # The output of the udev version command
326456b8d1aba5e9371d8ede11afd67ab132f2eavboxsync case "$USB_GROUP" in ?*) USB_GROUP=" $USB_GROUP" ;; esac
f0821e819e51b95ecaf7b12c742da563b4ddf7e5vboxsync udev_ver=`expr "$UDEV_STRING" : '[^0-9]*\([0-9]*\)'`
c47fa4987358016899f59a10bfba217a1cc8ba47vboxsync udev_write_vboxdrv "$VBOXDRV_GRP" "$VBOXDRV_MODE" |
b7e694c031e36f70134c1d25506fd910dc413a52vboxsync # install udev rule (disable with INSTALL_NO_UDEV=1 in /etc/default/virtualbox) for distribution packages
b7e694c031e36f70134c1d25506fd910dc413a52vboxsync VBOXDRV_GRP="$1" # The group owning the vboxdrv device
b7e694c031e36f70134c1d25506fd910dc413a52vboxsync VBOXDRV_MODE="$2" # The access mode for the vboxdrv device
b7e694c031e36f70134c1d25506fd910dc413a52vboxsync INSTALLATION_DIR="$3" # The directory VirtualBox is installed in
b7e694c031e36f70134c1d25506fd910dc413a52vboxsync USB_GROUP="$4" # The group that has permission to access USB devices
b7e694c031e36f70134c1d25506fd910dc413a52vboxsync NO_INSTALL="$5" # Set this to "1" to remove but not re-install rules
b7e694c031e36f70134c1d25506fd910dc413a52vboxsync if test -d /etc/udev/rules.d; then
b7e694c031e36f70134c1d25506fd910dc413a52vboxsync udev_out="`udevadm version 2>/dev/null || udevinfo -V 2>/dev/null`"
b7e694c031e36f70134c1d25506fd910dc413a52vboxsync generate_udev_rule "$VBOXDRV_GRP" "$VBOXDRV_MODE" "$INSTALLATION_DIR" \
b7e694c031e36f70134c1d25506fd910dc413a52vboxsync rm -f /etc/udev/rules.d/60-vboxdrv.rules 2> /dev/null
b7e694c031e36f70134c1d25506fd910dc413a52vboxsync# Add a unit test if/when needed following the same pattern as for
b7e694c031e36f70134c1d25506fd910dc413a52vboxsync# install_udev.
b7e694c031e36f70134c1d25506fd910dc413a52vboxsync usb_createnode="$2" # Path to the USB device node creation script
b7e694c031e36f70134c1d25506fd910dc413a52vboxsync usb_group="$3" # The group to give ownership of the node to
b7e694c031e36f70134c1d25506fd910dc413a52vboxsync class="`$EXTERN cat ${path}/bDeviceClass 2> /dev/null`"
b7e694c031e36f70134c1d25506fd910dc413a52vboxsync $EXTERN sh "${usb_createnode}" "$major" "$minor" "$class" \
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync# install_device_node_setup contains some aliases for unit testing purposes. # Set them to their normal values here.
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsyncudev_rule_file=/etc/udev/rules.d/10-vboxdrv.rules # Set this to /dev/null
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync # for unit testing
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync # Install udev rules and create device nodes for usb access
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync # To unit test, set $EXTERN to point to a function simulating these
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync # functions (defined further up in this file): install_udev;
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync # install_create_usb_node_for_sysfs. See the code for usage.
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync VBOXDRV_GRP="$1" # The group that should own /dev/vboxdrv
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync VBOXDRV_MODE="$2" # The mode to be used for /dev/vboxdrv
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync INSTALLATION_DIR="$3" # The directory VirtualBox is installed in
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync USB_GROUP="$4" # The group that should own the /dev/vboxusb device
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync usb_createnode="$INSTALLATION_DIR/VBoxCreateUSBNode.sh"
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync # install udev rule (disable with INSTALL_NO_UDEV=1 in
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync $EXTERN install_udev "${vboxdrv_group}" "$VBOXDRV_MODE" \
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync for i in ${sysfs_usb_devices}; do # This line intentionally without quotes.
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync $EXTERN install_create_usb_node_for_sysfs "$i" "${usb_createnode}" \
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync INSTALLATION_DIR="$1" # Where the VirtualBox binaries are installed to
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync SHARE_DIR="$2" # Where shared bits are installed to
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync if [ -x /usr/bin/chcon ]; then
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync chcon -t texrel_shlib_t "$INSTALLATION_DIR"/*VBox* > /dev/null 2>&1
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync chcon -t texrel_shlib_t "$INSTALLATION_DIR"/VBoxAuth.so \
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync chcon -t texrel_shlib_t "$INSTALLATION_DIR"/VirtualBox.so \
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync chcon -t texrel_shlib_t "$INSTALLATION_DIR"/components/VBox*.so \
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync chcon -t java_exec_t "$INSTALLATION_DIR"/VirtualBox > /dev/null 2>&1
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync chcon -t java_exec_t "$INSTALLATION_DIR"/VBoxSDL > /dev/null 2>&1
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync chcon -t java_exec_t "$INSTALLATION_DIR"/VBoxHeadless \
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync chcon -t java_exec_t "$INSTALLATION_DIR"/VBoxNetDHCP \
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync chcon -t java_exec_t "$INSTALLATION_DIR"/VBoxExtPackHelperApp \
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync chcon -t java_exec_t "$INSTALLATION_DIR"/vboxwebsrv > /dev/null 2>&1
1c88e893e641d60853d1c2b516f8b01c767f6667vboxsync chcon -t java_exec_t "$INSTALLATION_DIR"/webtest > /dev/null 2>&1