PKGBUILDs/aur/sabnzbd/sabnzbd.install

105 lines
3.2 KiB
Text
Raw Normal View History

2011-05-17 22:02:46 +00:00
## arg 1: the new package version
2011-10-23 19:30:03 +00:00
post_install() {
2012-01-04 19:16:02 +00:00
. /etc/conf.d/sabnzbd
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"
2012-09-09 14:11:13 +00:00
==> Don't forget to edit /etc/conf.d/sabnzbd or /etc/conf.d/sabnzbd_systemd!
2012-01-04 19:16:02 +00:00
==> Add your Session key and if necessary your username and password to ensure a proper shutdown.
==> 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)"
if [ -f /run/daemons/sabnzbd ]; then
/etc/rc.d/sabnzbd stop # kill the daemon
fi
2012-09-09 14:11:13 +00:00
if [[ -d "/run/sabnzbd/" && "$(ls -A /run/sabnzbd/)" ]]; then
systemctl stop sabnzbd.service
fi
2012-01-04 19:16:02 +00:00
if [ -n "${PID}" ];then
kill "${PID}" # kill the daemon finaly
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() {
2011-10-23 19:30:03 +00:00
. /etc/conf.d/sabnzbd
2012-01-04 19:16:02 +00:00
if [ "${USE_SYSTEM_IDS}" == "1" ]; then
if grep -q "^sabnzbd:" /etc/group &> /dev/null; then
if grep -q "^SABNZBD_GID=" /etc/conf.d/sabnzbd &> /dev/null; then
groupmod -g "${SABNZBD_GID}" -n sabnzbd sabnzbd &> /dev/null
else
groupmod -r -n sabnzbd sabnzbd &> /dev/null
fi
else
if grep -q "^SABNZBD_GID=" /etc/conf.d/sabnzbd &> /dev/null; then
groupadd -g "${SABNZBD_GID}" sabnzbd &> /dev/null
else
groupadd -r sabnzbd &> /dev/null
fi
fi
2011-10-23 19:30:03 +00:00
2012-01-04 19:16:02 +00:00
if grep -q "^SABNZBD_AGROUP=" /etc/conf.d/sabnzbd &> /dev/null; then
SABNZBD_GS="-G ${SABNZBD_AGROUP}"
else
SABNZBD_GS=""
fi
if grep -q "^sabnzbd:" /etc/passwd 2> /dev/null; then
if grep -q "^SABNZBD_UID=" /etc/conf.d/sabnzbd &> /dev/null; then
usermod -s /sbin/nologin -c "SABnzbd user" -d "${SABNZBD_DIR}" \
-u "${SABNZBD_UID}" -g sabnzbd ${SABNZBD_GS} sabnzbd &> /dev/null
else
usermod -s /sbin/nologin -c "SABnzbd user" -d "${SABNZBD_DIR}" \
-g sabnzbd ${SABNZBD_GS} -r sabnzbd &> /dev/null
fi
else
if grep -q "^SABNZBD_UID=" /etc/conf.d/sabnzbd &> /dev/null; then
useradd -s /sbin/nologin -c "SABnzbd user" -d "${SABNZBD_DIR}" \
-u ${SABNZBD_UID} -g sabnzbd "${SABNZBD_GS}" -r sabnzbd &> /dev/null
else
useradd -s /sbin/nologin -c "SABnzbd user" -d "${SABNZBD_DIR}" \
-g sabnzbd ${SABNZBD_GS} -r sabnzbd &> /dev/null
fi
fi
fi
chown -R "${SABNZBD_USER}:${SABNZBD_GROUP}" "${SABNZBD_DIR}"
2012-09-09 14:11:13 +00:00
if command -v "systemd-tmpfiles" &> /dev/null; then
systemd-tmpfiles --create /usr/lib/tmpfiles.d/sabnzbd.conf
fi
2011-05-17 22:02:46 +00:00
}
## arg 1: the old package version
pre_remove() {
2012-01-04 19:16:02 +00:00
. /etc/conf.d/sabnzbd
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() {
2011-05-17 22:02:46 +00:00
userdel sabnzbd &> /dev/null
2012-01-04 19:16:02 +00:00
groupdel sabnzbd &> /dev/null || /bin/true
echo "==> There may be some files left in /opt/sabnzbd."
2011-10-23 19:30:03 +00:00
}
2012-01-04 19:16:02 +00:00
# vim:set ts=2 sw=2 et: