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
|
|
|
|
xdg-mime install --mode system /opt/sabnzbd/x-nzb.xml
|
|
|
|
xdg-icon-resource install --context mimetypes --size 64 /opt/sabnzbd/nzb-2.png application-x-nzb
|
2011-10-23 19:30:03 +00:00
|
|
|
|
2011-05-17 22:02:46 +00:00
|
|
|
groupadd sabnzbd &> /dev/null
|
|
|
|
useradd -g sabnzbd -d /opt/sabnzbd -s /bin/false sabnzbd &> /dev/null
|
|
|
|
chown -R sabnzbd:sabnzbd /opt/sabnzbd
|
2011-10-23 19:30:03 +00:00
|
|
|
|
2011-05-17 22:02:46 +00:00
|
|
|
echo " >> Don't forget to edit /etc/conf.d/sabnzbd!"
|
|
|
|
echo " >> Add your Session key and if necessary your username and password to ensure a proper shutdown."
|
|
|
|
echo " >> "
|
|
|
|
echo " >> If you want to associate .nzb-files with SABnzbd, run 'xdg-mime default sabnzbd.desktop applications/x-nzb'"
|
|
|
|
}
|
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
|
|
|
|
|
|
|
|
grep -q "SABNZBD_GROUP" /etc/conf.d/sabnzbd || echo 'SABNZBD_GROUP="sabnzbd"' >> /etc/conf.d/sabnzbd
|
|
|
|
grep -q "SABNZBD_ARGS" /etc/conf.d/sabnzbd || echo 'SABNZBD_ARGS="-f ${SABNZBD_CONF} -s ${SABNZBD_IP}:${SABNZBD_PORT} -d"' >> /etc/conf.d/sabnzbd
|
|
|
|
|
|
|
|
chown -R "${SABNZBD_USER}:${SABNZBD_GROUP}" /opt/sabnzbd
|
2011-05-17 22:02:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
## arg 1: the old package version
|
|
|
|
pre_remove() {
|
2011-10-23 19:30:03 +00:00
|
|
|
SABNZBD_PID="$(ps aux | grep "python2 /opt/sabnzbd/SABnzbd.py" | sort | uniq -c | tail -n 1 | awk '{ print $3 }')"
|
|
|
|
[ -f /run/daemons/sabnzbd ]; /etc/rc.d/sabnzbd stop # kill the daemon
|
|
|
|
[ -n ${SABNZBD_PID} ]; kill -9 "${SABNZBD_PID}" # kill the daemon finaly
|
|
|
|
xdg-mime uninstall --mode system /opt/sabnzbd/x-nzb.xml
|
|
|
|
xdg-icon-resource uninstall --context mimetypes --size 64 application-x-nzb
|
|
|
|
}
|
|
|
|
|
|
|
|
post_remove() {
|
2011-05-17 22:02:46 +00:00
|
|
|
userdel sabnzbd &> /dev/null
|
2011-10-23 19:30:03 +00:00
|
|
|
groupdel sabnzbd &> /dev/null
|
|
|
|
echo " >> There may be some files left in /opt/sabnzbd."
|
|
|
|
}
|