post_install() { # Add vboxusers group, GID 108 is reserved (http://wiki.archlinux.org/index.php/UID_and_GID_list), getent group vboxusers &> /dev/null || groupadd -f -g 108 vboxusers # Load new udev rule for module vboxdrv udevadm control --reload-rules # Update mime database [[ -x =update-mime-database ]] && update-mime-database /usr/share/mime &>/dev/null # Update desktop database [[ -x =update-desktop-database ]] && update-desktop-database -q &>/dev/null # Build new module /usr/bin/vboxsetup setup # Show warnings /bin/cat < Remember to add allowed users to the vboxusers group: ==> # gpasswd -a USERNAME vboxusers ==> ==> To load virtualbox modules automatically you can add vboxdrv to a file /etc/modules-load.d/vbox.conf ==> To start virtualbox web service automatically you need to enable and start the service through systemctl ==> ==> To fix missing usb devices, you can call 'vboxsetup fixusb' or reboot your computer EOF } pre_upgrade() { pre_remove # Remove any stuff remaining from the module compilation rm -Rf "/opt/VirtualBox" } post_upgrade() { post_install } pre_remove() { # Stop running services _service="vboxweb.service" systemctl is-active ${_service} &>/dev/null if [[ $? -eq 0 ]] ; then systemctl stop ${_service} fi systemctl is-enabled ${_service} &>/dev/null if [[ $? -eq 0 ]] ; then systemctl disable ${_service} fi # Remove modules if [ $(vercmp $2 4.2.0-4) -lt 0 ]; then /usr/bin/vboxsetup remove elif [[ -f /etc/rc.d/vboxdrv && -f /usr/sbin/rc.d ]]; then rc.d unload vboxdrv rc.d remove vboxdrv else echo -e "\n==> Modules could not be deleted. Please check manually.\n" fi } post_remove() { # Remove any stuff remaining from the module compilation rm -Rf "/opt/VirtualBox" # Remove any run files rm -Rf "/var/run/VirtualBox" # Update mime database [[ -x =update-mime-database ]] && update-mime-database /usr/share/mime &>/dev/null # Update desktop database [[ -x =update-desktop-database ]] && update-desktop-database -q &>/dev/null # remove vboxusers group groupdel vboxusers &>/dev/null || true }