2011-07-21 00:14:43 +08:00
|
|
|
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
|
2012-10-18 21:54:01 +08:00
|
|
|
systemd-notify --booted
|
|
|
|
if [[ "$?" -eq 0 ]]; then
|
|
|
|
/usr/bin/vboxsetup setup
|
|
|
|
else
|
|
|
|
/etc/rc.d/vboxdrv setup
|
|
|
|
fi
|
2011-07-21 00:14:43 +08:00
|
|
|
|
|
|
|
# Show warnings
|
|
|
|
/bin/cat <<EOF
|
|
|
|
|
|
|
|
==> Remember to add allowed users to the vboxusers group:
|
|
|
|
==> # gpasswd -a USERNAME vboxusers
|
|
|
|
==>
|
2012-10-18 21:54:01 +08:00
|
|
|
==> With systemd:
|
|
|
|
==> 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
|
|
|
|
==>
|
|
|
|
==> With sysvinit:
|
2011-07-21 00:14:43 +08:00
|
|
|
==> To load virtualbox modules automatically you can add vboxdrv in your DAEMONS
|
|
|
|
==> To start virtualbox web service automatically you can add vboxweb in your DAEMONS
|
|
|
|
==> To fix missing usb devices, you can call rc.d fixusb vboxdrv or reboot your computer
|
2012-10-18 21:54:01 +08:00
|
|
|
==>
|
2011-07-21 00:14:43 +08:00
|
|
|
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
|
2012-10-18 21:54:01 +08:00
|
|
|
|
|
|
|
systemd-notify --booted
|
|
|
|
if [[ "$?" -eq 0 ]]; then
|
|
|
|
_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
|
|
|
|
else
|
|
|
|
[[ -x /etc/rc.d/vboxdrv ]] && /etc/rc.d/vboxdrv stop
|
|
|
|
[[ -x /etc/rc.d/vboxweb ]] && /etc/rc.d/vboxweb stop
|
|
|
|
fi
|
2011-07-21 00:14:43 +08:00
|
|
|
|
|
|
|
# Remove modules
|
2012-10-18 21:54:01 +08:00
|
|
|
systemd-notify --booted
|
|
|
|
if [[ "$?" -eq 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
|
2011-07-21 00:14:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
# vim:set ts=2 sw=2 ft=sh et:
|