Browse Source

fix FreeBSD init script

-add actual start command
-fix verify_couchpotato_pid function, 'ps' command failed if PID var was empty
-fix verify_couchpotato_pid usage, acutally use the return of verify_couchpotato_pid in the 'stop' routine
pull/1244/head
ikkemaniac 13 years ago
committed by Ruud
parent
commit
3a2861f72a
  1. 11
      init/freebsd

11
init/freebsd

@ -49,6 +49,7 @@ stop_cmd="${name}_stop"
command="/usr/sbin/daemon"
command_args="-f -p ${couchpotato_pid} python ${couchpotato_dir}/CouchPotato.py ${couchpotato_flags}"
start_cmd="${command} ${command_args}"
# Check for wget and refuse to start without it.
if [ ! -x "${WGET}" ]; then
@ -65,8 +66,11 @@ fi
verify_couchpotato_pid() {
# Make sure the pid corresponds to the CouchPotato process.
pid=`cat ${couchpotato_pid} 2>/dev/null`
if [ -n "${pid}" ]; then
ps -p ${pid} | grep -q "python ${couchpotato_dir}/CouchPotato.py"
return $?
fi
return 1
}
# Try to stop CouchPotato cleanly by calling shutdown over http.
@ -75,13 +79,18 @@ couchpotato_stop() {
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
if [ "${?}" -eq 0 ]; then
echo "Stopping $name"
${WGET} -O - -q "http://${HOST}:${PORT}/api/${CPAPI}/app.shutdown/" >/dev/null
if [ -n "${pid}" ]; then
wait_for_pids ${pid}
echo "Stopped"
fi
else
echo "$name not running?"
exit 1
fi
}
couchpotato_status() {

Loading…
Cancel
Save