mirror of
https://gitdl.cn/https://github.com/chakralinux/desktop.git
synced 2025-01-24 10:32:13 +08:00
89 lines
2.1 KiB
Bash
89 lines
2.1 KiB
Bash
#!/bin/bash
|
|
|
|
update_databases() {
|
|
# Update mime database
|
|
type -P update-mime-database &>/dev/null &&
|
|
update-mime-database /usr/share/mime &>/dev/null
|
|
|
|
# Update xdg icon database
|
|
type -P xdg-icon-resource &>/dev/null &&
|
|
xdg-icon-resource forceupdate --theme hicolor &>/dev/null
|
|
|
|
# Update desktop database
|
|
type -P update-desktop-database &>/dev/null &&
|
|
update-desktop-database -q &>/dev/null
|
|
}
|
|
|
|
# arg 1: the new package version
|
|
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 databases
|
|
update_databases
|
|
|
|
# Show warnings
|
|
cat <<EOF
|
|
|
|
==> Remember to add allowed users to the vboxusers group:
|
|
==> # gpasswd -a USERNAME vboxusers
|
|
==
|
|
==> To compile/load virtualbox modules automatically at startup you can systemctl enable dkms.service
|
|
==
|
|
==> To build and install your modules
|
|
==> # run dkms autoinstall
|
|
==> or
|
|
==> # vboxsetup setup
|
|
==> if you don't use dkms
|
|
EOF
|
|
}
|
|
|
|
# arg 1: the new package version
|
|
# arg 2: the old package version
|
|
pre_upgrade() {
|
|
(($(vercmp $2 '4.3.14-3') < 0 )) && /usr/bin/vboxsetup remove || true
|
|
pre_remove "$2"
|
|
|
|
# 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
|
|
[[ -n $1 ]] && dkms remove vboxhost/${1%-*} --all &>/dev/null || true
|
|
}
|
|
|
|
post_remove() {
|
|
# Remove any stuff remaining from the module compilation
|
|
rm -Rf "/opt/VirtualBox"
|
|
|
|
# Remove any run files
|
|
rm -Rf "/var/run/VirtualBox"
|
|
|
|
# Update databases
|
|
update_databases
|
|
|
|
# remove vboxusers group
|
|
groupdel vboxusers &>/dev/null || true
|
|
}
|
|
|
|
# vim:set ts=2 sw=2 ft=sh et:
|