desktop/unvanquished/unvanquished.install
2014-11-11 11:48:10 +00:00

68 lines
1.5 KiB
Plaintext

_update_desktop_environment() {
# update icon cache
xdg-icon-resource forceupdate --theme hicolor &> /dev/null
# install unv:// protocol handler
update-desktop-database -q
update-mime-database /usr/share/mime >/dev/null
}
_add_server_user() {
if ! getent passwd unvanquished >/dev/null; then
useradd -rM -d /var/lib/unvanquished-server -c "Unvanquished dedicated server" -s /bin/false unvanquished
fi
}
_delete_server_user() {
if getent passwd unvanquished >/dev/null; then
userdel unvanquished
groupdel unvanquished
fi
}
_chown_server_home() {
chown -R unvanquished:unvanquished /var/lib/unvanquished-server
}
_migrate() {
# delete pre unvanquished-data assets
if [ -d /var/lib/unvanquished ] && ! pacman -Qo /var/lib/unvanquished >/dev/null 2>&1; then
echo "Deleting old asset directory..."
if [ -d /var/lib/unvanquished/main ]; then
rm -f /var/lib/unvanquished/main/*.pk3
rmdir /var/lib/unvanquished/main
fi
if [ -d /var/lib/unvanquished/pkg ]; then
rm -f /var/lib/unvanquished/pkg/*.pk3
rmdir /var/lib/unvanquished/pkg
fi
rmdir /var/lib/unvanquished
fi
if [ -d /var/cache/unvanquished ] && ! pacman -Qo /var/cache/unvanquished >/dev/null 2>&1; then
echo "Deleting old asset update cache..."
rm -r /var/cache/unvanquished
fi
}
post_install() {
_add_server_user
_chown_server_home
_update_desktop_environment
}
post_upgrade() {
_migrate
}
pre_remove() {
true
}
post_remove() {
_delete_server_user
_update_desktop_environment
}