#!/sbin/runscript # Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ depend() { need net } run_dir="/var/run/couchpotato" pidfile="$run_dir/couchpotato.pid" etc_dir="/etc/couchpotato" var_dir="/var/couchpotato" log_dir="/var/log/couchpotato" program="$CODE_DIR/CouchPotato.py" bin=`which $PYTHON_BIN` check_config() { if [ ! -d "${run_dir}" ]; then mkdir "${run_dir}" fi # Permission stuff. Should ensure that the daemon user always have write permissions. # Quick and ugly but should get the job done. chown -R ${USER}:${GROUP} "${run_dir}" chown -R ${USER}.${GROUP} "${var_dir}" chown -R ${USER}.${GROUP} "${etc_dir}" if [ "${WEBUPDATER}" = "YES" ]; then chown -R ${USER}.${GROUP} "${CODE_DIR}" fi } start() { check_config ebegin "Starting CouchPotato" start-stop-daemon --start --pidfile ${pidfile} -u ${USER} -g ${GROUP}\ --exec ${bin} ${program} -- \ --daemon --pid_file ${pidfile} --data_dir ${var_dir} --config_file ${CONFIG_FILE} eend $? } stop() { ebegin "Stopping CouchPotato" start-stop-daemon --stop --pidfile ${pidfile} --retry 15 eend $? }