|
|
@ -31,14 +31,27 @@ load_rc_config ${name} |
|
|
|
: ${couchpotato_user:="_sabnzbd"} |
|
|
|
: ${couchpotato_dir:="/usr/local/couchpotato"} |
|
|
|
: ${couchpotato_chdir:="${couchpotato_dir}"} |
|
|
|
: ${couchpotato_pid:="/var/run/couchpotato.pid"} |
|
|
|
: ${couchpotato_pid:="${couchpotato_dir}/couchpotato.pid"} |
|
|
|
: ${couchpotato_conf:="${couchpotato_dir}/data/settings.conf"} |
|
|
|
|
|
|
|
WGET="/usr/local/bin/wget" # You need wget for this script to safely shutdown CouchPotato. |
|
|
|
if [ -e "${couchpotato_conf}" ]; then |
|
|
|
HOST=`grep -A14 "\[core\]" "${couchpotato_conf}"|egrep "^host"|perl -wple 's/^host = (.*)$/$1/'` |
|
|
|
PORT=`grep -A14 "\[core\]" "${couchpotato_conf}"|egrep "^port"|perl -wple 's/^port = (.*)$/$1/'` |
|
|
|
CPAPI=`grep -A14 "\[core\]" "${couchpotato_conf}"|egrep "^api_key"|perl -wple 's/^api_key = (.*)$/$1/'` |
|
|
|
fi |
|
|
|
|
|
|
|
pidfile="${couchpotato_pid}" |
|
|
|
status_cmd="${name}_status" |
|
|
|
stop_cmd="${name}_stop" |
|
|
|
|
|
|
|
command="/usr/sbin/daemon" |
|
|
|
command_args="-f -p ${couchpotato_pid} python ${couchpotato_dir}/CouchPotato.py ${couchpotato_flags} --pid_file=${couchpotato_pid}" |
|
|
|
command_args="-f -p ${couchpotato_pid} python ${couchpotato_dir}/CouchPotato.py ${couchpotato_flags}" |
|
|
|
|
|
|
|
# Check for wget and refuse to start without it. |
|
|
|
if [ ! -x "${WGET}" ]; then |
|
|
|
warn "couchpotato not started: You need wget to safely shut down CouchPotato." |
|
|
|
exit 1 |
|
|
|
fi |
|
|
|
|
|
|
|
# Ensure user is root when running this script. |
|
|
|
if [ `id -u` != "0" ]; then |
|
|
@ -55,17 +68,17 @@ verify_couchpotato_pid() { |
|
|
|
|
|
|
|
# Try to stop CouchPotato cleanly by calling shutdown over http. |
|
|
|
couchpotato_stop() { |
|
|
|
|
|
|
|
if [ ! -e "${couchpotato_conf}" ]; then |
|
|
|
echo "CouchPotato's settings file does not exist. Try starting CouchPotato, as this should create the file." |
|
|
|
exit 1 |
|
|
|
fi |
|
|
|
echo "Stopping $name" |
|
|
|
verify_couchpotato_pid |
|
|
|
|
|
|
|
${WGET} -O - -q "http://${HOST}:${PORT}/api/${CPAPI}/app.shutdown/" >/dev/null |
|
|
|
if [ -n "${pid}" ]; then |
|
|
|
kill -SIGTERM ${pid} 2> /dev/null |
|
|
|
wait_for_pids ${pid} |
|
|
|
kill -9 ${pid} 2> /dev/null |
|
|
|
echo "Stopped" |
|
|
|
fi |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
couchpotato_status() { |
|
|
|