desktop/unvanquished/unvanquished.install

70 lines
1.5 KiB
Plaintext
Raw Normal View History

2013-12-05 05:31:20 +08:00
_update_assets() {
/usr/bin/unvanquished-update-paks
}
_delete_assets() {
rm -f /var/lib/unvanquished/main/*.pk3
rm -f /var/cache/unvanquished/update-paks/*
}
_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
fi
}
_chown_server_home() {
chown -R unvanquished:unvanquished /var/lib/unvanquished-server
}
_migrate() {
# if there is /opt/unvanquished/main (containing untracked asset files) we have to migrate to the new filesystem layout
if [ -d /opt/unvanquished/main ]; then
# move assets
echo "Moving assets from /opt/unvanquished to /var/lib/unvanquished..."
mv -v /opt/unvanquished/main/*.pk3 /var/lib/unvanquished/main/
# delete old asset directory
rmdir /opt/unvanquished/main && rmdir /opt/unvanquished
# chown new server directory
_chown_server_home
fi
}
post_install() {
_add_server_user
_chown_server_home
_update_desktop_environment
_update_assets
}
post_upgrade() {
_migrate
_update_assets
}
pre_remove() {
_delete_assets
}
post_remove() {
_delete_server_user
_update_desktop_environment
}