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. 23
      init/freebsd

23
init/freebsd

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

Loading…
Cancel
Save