Hi everyone, hoping someone can point me in the right direction here. I have SABnzbd+ running on a headless Ubuntu server, and want a script which will pause any downloading while my PS3 is online. Currently I have the script below running every minute via cron, which does what I want, except for one problem. I can't manually pause downloading for any longer than one minute, because the script resumes it again. I've been trying to figure out a way to use variables to store a value indicating if the queue was paused from the script or another means. I can't figure out how to store a variable for later use. I'm assuming I need to write the value to a file, but I haven't had any luck getting that to work either.
Essentially, here's is what I'm trying to do:
If PS3 running, pause queue
If PS3 not running, but queue was paused outside of script, leave paused
If PS3 not running, and queue was paused via script, resume downloading
It seems like it should be fairly simple, but everything I have tried has failed so far. Any help, or even a push in the right direction would be greatly appreciated. Thank you.
Code: Select all
#!/bin/sh
#
# Script to pause SABnzbd+ when PS3 active
#
if ping -c 1 PS3
then
curl http://localhost:8085/api\?mode\=pause\&apikey\=<apikey>
else
curl http://localhost:8085/api\?mode\=resume\&apikey\=<apikey>
fi