SABnzbd-Suite: add option to enable restart on resume, add sleep.d script

This commit is contained in:
Stefan Saraev 2013-02-09 13:40:35 +02:00
parent 36f99727ee
commit dae8099efc
4 changed files with 54 additions and 0 deletions

View File

@ -10,4 +10,5 @@
<setting id="COUCHPOTATO_LAUNCH" value="true" />
<setting id="COUCHPOTATO_VERSION" value="1" />
<setting id="HEADPHONES_LAUNCH" value="true" />
<setting id="RESTART_ON_RESUME" value="false" />
</settings>

View File

@ -17,5 +17,6 @@
<string id="3021">Keep awake while downloading</string>
<string id="3030">Wake up periodically</string>
<string id="3031">Wake up at</string>
<string id="3032">Restart on suspend / resume</string>
</strings>

View File

@ -24,6 +24,7 @@
<setting id="SABNZBD_WAKE_AT" type="enum" subsetting="true" enable="eq(-1,true)"
label="3031" default="01"
values="|01:00|03:00|05:00|07:00|09:00|11:00|13:00|15:00|17:00|19:00|21:00|23:00"/>
<setting id="RESTART_ON_RESUME" type="bool" label="3032" default="false" />
</category>
</settings>

View File

@ -0,0 +1,51 @@
#!/bin/sh
################################################################################
# This file is part of OpenELEC - http://www.openelec.tv
# Copyright (C) 2009-2012 Stephan Raue (stephan@openelec.tv)
#
# This Program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This Program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenELEC.tv; see the file COPYING. If not, write to
# the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110, USA.
# http://www.gnu.org/copyleft/gpl.html
################################################################################
. /etc/profile
ADDON_HOME="$HOME/.xbmc/userdata/addon_data/service.downloadmanager.SABnzbd-Suite"
ADDON_SETTINGS="$ADDON_HOME/settings.xml"
RESTART_ON_RESUME=`grep RESTART_ON_RESUME $ADDON_SETTINGS | awk '{print $3}' | sed -e "s,value=,," -e "s,\",,g"`
LOCKFILE="/var/lock/SABnzbd-Suite.sleep"
if [ "$RESTART_ON_RESUME" == "true" ] ; then
case "$1" in
hibernate|suspend)
if [ ! -z "`ps | grep -E 'python.*service.downloadmanager.SABnzbd-Suite' | awk '{print $1}'`" ] ; then
progress "Shutting down SABnzbd-Suite for suspending..."
SABnzbd-Suite.stop
touch $LOCKFILE
fi
;;
thaw|resume)
progress "Restarting SABnzbd-Suite for wakeup..."
if [ -f "$LOCKFILE" ] ; then
rm -rf "$LOCKFILE"
python $HOME/.xbmc/addons/service.downloadmanager.SABnzbd-Suite/bin/SABnzbd-Suite.py
fi
;;
*) exit $NA
;;
esac
fi