aur/sabnzbd to 0.6.14-1

This commit is contained in:
Kevin Mihelich 2012-01-04 14:16:02 -05:00
parent 9828d75688
commit 9d41e40f9e
4 changed files with 124 additions and 29 deletions

View file

@ -2,7 +2,7 @@ plugrel=1
pkgname=sabnzbd
_pkgname=SABnzbd
pkgver=0.6.10
pkgver=0.6.14
pkgrel=1
pkgdesc="A web-interface based binary newsgrabber with NZB file support"
url="http://www.sabnzbd.org"
@ -16,10 +16,10 @@ backup=("etc/conf.d/${pkgname}" "opt/${pkgname}/${pkgname}.ini")
source=("http://downloads.sourceforge.net/sabnzbdplus/${_pkgname}-${pkgver}-src.tar.gz"
"${pkgname}" "${pkgname}.confd" "${pkgname}.init" "${pkgname}.desktop"
"addnzb.sh" "nzb-2.png" "sab2_64.png" "x-nzb.xml")
md5sums=("4ade5eef10fa652bb96cb53e6864063c"
md5sums=("249dc97ed187065198bcb83acb04738b"
"48d60a1c626503c7fef1bc5374390513"
"014c37c32114806191cce361e16862fa"
"d1d545b67ddea706e607db52c90c4ccd"
"7d7ae7cca08e90582587773da3b55de8"
"848c7b117388671f243bd0833ff41f89"
"f9bd5485072714b11f8c30a28024dc4d"
"c0d52ba8d47f731790cd717fde46b829"
"2a49c07b1e3e6448eabe92644315f983"

View file

@ -1,12 +1,17 @@
# Set to the protocol, IP and port
# Set the protocol, IP and port
SABNZBD_PROTOCOL="http"
SABNZBD_IP="127.0.0.1"
SABNZBD_PORT="8080"
# Set your default user/group, startarguments and your configfile
# Set your default user/group(id), startarguments and your configfile
USE_SYSTEM_IDS="1"
SABNZBD_DIR="/opt/sabnzbd"
#SABNZBD_UID="423"
#SABNZBD_GID="423"
SABNZBD_USER="sabnzbd"
SABNZBD_GROUP="sabnzbd"
SABNZBD_CONF="/opt/sabnzbd/sabnzbd.ini"
#SABNZBD_AGROUP="users" # separate groups by ,
SABNZBD_CONF="${SABNZBD_DIR}/sabnzbd.ini"
SABNZBD_ARGS="-f ${SABNZBD_CONF} -s ${SABNZBD_IP}:${SABNZBD_PORT} -d"
# Put the session keys from Config > General here

View file

@ -4,17 +4,20 @@
. /etc/rc.d/functions
. /etc/conf.d/sabnzbd
PID="$(pgrep -f -u "${SABNZBD_USER}" SABnzbd.py)"
case "${1}" in
start)
stat_busy "Starting SABnzbd"
if [ -f /var/run/daemons/sabnzbd ]; then
echo -n "Sabnzbd is already running as a daemon! If you are certain it is not running, remove /var/run/daemons/sabnzbd."
if [ -f /run/daemons/sabnzbd ]; then
echo -n "Sabnzbd is already running as a daemon! If you are certain it is not running, remove /run/daemons/sabnzbd."
stat_fail
else
su - "${SABNZBD_USER}" -c "python2 /opt/sabnzbd/SABnzbd.py ${SABNZBD_ARGS}" -s /bin/sh
su - "${SABNZBD_USER}" -c "python2 ${SABNZBD_DIR}/SABnzbd.py ${SABNZBD_ARGS}" -s /bin/sh
if [ "${?}" -gt 0 ]; then
stat_fail
exit 1
else
add_daemon sabnzbd
stat_done
@ -25,19 +28,45 @@ case "${1}" in
stat_busy "Stopping SABnzbd"
curl -f "${SABNZBD_PROTOCOL}://${SABNZBD_USPW}${SABNZBD_IP}:${SABNZBD_PORT}/sabnzbd/api?mode=shutdown&apikey=${SABNZBD_KEY}" &> /dev/null
if [ "${?}" -gt 0 ]; then
stat_fail
exit 1
else
rm_daemon sabnzbd
stat_done
fi
;;
force-stop)
stat_busy "Stopping SABnzbd (forced)"
[ -n "${PID}" ]; kill "${PID}" &> /dev/null
if [ "${?}" -gt 0 ]; then
stat_fail
exit 1
else
[ -f /run/daemons/sabnzbd ]; rm -f /run/daemons/sabnzbd &> /dev/null
rm_daemon sabnzbd
stat_done
fi
;;
restart)
"${0}" stop
sleep 1
"${0}" start
;;
force-restart)
"${0}" force-stop
sleep 1
"${0}" start
;;
status)
stat_busy "Checking SABnzbd status";
ck_status sabnzbd
;;
*)
echo "usage: ${0} {start|stop|restart}"
echo "usage: ${0} {start|stop|restart|force-stop|force-restart|status}"
esac
exit 0

View file

@ -1,17 +1,37 @@
## arg 1: the new package version
post_install() {
. /etc/conf.d/sabnzbd
# 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
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
groupadd sabnzbd &> /dev/null
useradd -g sabnzbd -d /opt/sabnzbd -s /bin/false sabnzbd &> /dev/null
chown -R sabnzbd:sabnzbd /opt/sabnzbd
post_upgrade
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'"
cat << "EOM"
==> Don't forget to edit /etc/conf.d/sabnzbd!
==> 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
if [ -n "${PID}" ];then
kill "${PID}" # kill the daemon finaly
fi
#remove with 0.7.x release {{{
grep -q "SABNZBD_GROUP" /etc/conf.d/sabnzbd || \
echo 'SABNZBD_GROUP="sabnzbd"' >> /etc/conf.d/sabnzbd
grep -q "SABNZBD_DIR" /etc/conf.d/sabnzbd || \
echo 'SABNZBD_DIR="/opt/sabnzbd"' >> /etc/conf.d/sabnzbd
#}}}
}
## arg 1: the new package version
@ -19,23 +39,64 @@ post_install() {
post_upgrade() {
. /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
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
chown -R "${SABNZBD_USER}:${SABNZBD_GROUP}" /opt/sabnzbd
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}"
}
## arg 1: the old package version
pre_remove() {
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
. /etc/conf.d/sabnzbd
pre_upgrade
xdg-mime uninstall --mode system "${SABNZBD_DIR}/x-nzb.xml"
xdg-icon-resource uninstall --context mimetypes --size 64 application-x-nzb
}
## arg 1: the old package version
post_remove() {
userdel sabnzbd &> /dev/null
groupdel sabnzbd &> /dev/null
echo " >> There may be some files left in /opt/sabnzbd."
groupdel sabnzbd &> /dev/null || /bin/true
echo "==> There may be some files left in /opt/sabnzbd."
}
# vim:set ts=2 sw=2 et: