From 5cca98db31caaf6ca7032a3d948c4feb6ca30e2e Mon Sep 17 00:00:00 2001 From: Joachim Tingvold Date: Wed, 30 May 2012 22:22:54 +0200 Subject: [PATCH] Check that settings.conf exists in FreeBSD init-script --- init/freebsd | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/init/freebsd b/init/freebsd index 465d7d3..830117c 100644 --- a/init/freebsd +++ b/init/freebsd @@ -35,9 +35,11 @@ load_rc_config ${name} : ${couchpotato_conf:="${couchpotato_dir}/data/settings.conf"} WGET="/usr/local/bin/wget" # You need wget for this script to safely shutdown CouchPotato. -HOST=`cat "${couchpotato_conf}"|grep -A14 "\[core\]"|egrep "^host"|perl -wple 's/^host = (.*)$/$1/'` -PORT=`cat "${couchpotato_conf}"|grep -A14 "\[core\]"|egrep "^api_key"|perl -wple 's/^api_key = (.*)$/$1/'` -CPAPI=`cat "${couchpotato_conf}"|grep -A14 "\[core\]"|egrep "^port"|perl -wple 's/^port = (.*)$/$1/'` +if [ -e "${couchpotato_conf}" ]; then + HOST=`cat "${couchpotato_conf}"|grep -A14 "\[core\]"|egrep "^host"|perl -wple 's/^host = (.*)$/$1/'` + PORT=`cat "${couchpotato_conf}"|grep -A14 "\[core\]"|egrep "^api_key"|perl -wple 's/^api_key = (.*)$/$1/'` + CPAPI=`cat "${couchpotato_conf}"|grep -A14 "\[core\]"|egrep "^port"|perl -wple 's/^port = (.*)$/$1/'` +fi status_cmd="${name}_status" stop_cmd="${name}_stop" @@ -66,6 +68,10 @@ 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