PKGBUILDs/aur/sabnzbd/sabnzbd.install

66 lines
1.8 KiB
Text
Raw Normal View History

2013-01-12 00:24:04 +00:00
# Change these to modify the ownership of sabnzbd
# If you change this here, you also have to change
# the user and group in the systemd service file.
SABNZBD_USER="sabnzbd"
SABNZBD_GROUP="sabnzbd"
SABNZBD_DIR="/opt/sabnzbd" # should not be changed
2011-05-17 22:02:46 +00:00
## arg 1: the new package version
2011-10-23 19:30:03 +00:00
post_install() {
2011-05-17 22:02:46 +00:00
# add x-nzb mimetype
2012-01-04 19:16:02 +00:00
xdg-mime install --mode system "${SABNZBD_DIR}/x-nzb.xml"
xdg-icon-resource install --context mimetypes --size 64 "${SABNZBD_DIR}/nzb-2.png" application-x-nzb
2011-10-23 19:30:03 +00:00
2012-01-04 19:16:02 +00:00
post_upgrade
cat << "EOM"
==> If you want to associate .nzb-files with SABnzbd, run 'xdg-mime default sabnzbd.desktop applications/x-nzb'
EOM
}
## arg 1: the new package version
## arg 2: the old package version
pre_upgrade() {
PID="$(pgrep -f SABnzbd.py)"
2013-01-12 00:24:04 +00:00
if [ -n "${PID}" ];then
2012-09-09 14:11:13 +00:00
systemctl stop sabnzbd.service
fi
2011-05-17 22:02:46 +00:00
}
2011-10-23 19:30:03 +00:00
2011-05-17 22:02:46 +00:00
## arg 1: the new package version
## arg 2: the old package version
post_upgrade() {
2013-01-12 00:24:04 +00:00
# if the group or user already exists, the request will be denied
# and all original settings will be retained
if [ "$SABNZBD_GROUP" == "sabnzbd" ]; then
groupadd -r sabnzbd &> /dev/null
fi
2012-01-04 19:16:02 +00:00
2013-01-12 00:24:04 +00:00
if [ "$SABNZBD_USER" == "sabnzbd" ]; then
useradd -s /sbin/nologin -c "SABnzbd user" -d "${SABNZBD_DIR}" \
-g sabnzbd -r sabnzbd &> /dev/null
2012-01-04 19:16:02 +00:00
fi
chown -R "${SABNZBD_USER}:${SABNZBD_GROUP}" "${SABNZBD_DIR}"
2011-05-17 22:02:46 +00:00
}
## arg 1: the old package version
pre_remove() {
2012-01-04 19:16:02 +00:00
pre_upgrade
xdg-mime uninstall --mode system "${SABNZBD_DIR}/x-nzb.xml"
2011-10-23 19:30:03 +00:00
xdg-icon-resource uninstall --context mimetypes --size 64 application-x-nzb
}
2012-01-04 19:16:02 +00:00
## arg 1: the old package version
2011-10-23 19:30:03 +00:00
post_remove() {
2013-01-12 00:24:04 +00:00
# only delete if user is sabnzbd
userdel sabnzbd &> /dev/null
2012-01-04 19:16:02 +00:00
groupdel sabnzbd &> /dev/null || /bin/true
2013-01-12 00:24:04 +00:00
echo "==> There may be some files left in ${SABNZBD_DIR}."
2011-10-23 19:30:03 +00:00
}
2012-01-04 19:16:02 +00:00
# vim:set ts=2 sw=2 et: