From a5d6e0ddeaef186c3fd6f129f6cd32fdb681f3fc Mon Sep 17 00:00:00 2001 From: darf Date: Wed, 30 Apr 2014 14:40:52 -0400 Subject: [PATCH] added gentoo linux init script --- init.gentoo | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 init.gentoo diff --git a/init.gentoo b/init.gentoo new file mode 100644 index 00000000..9791edd6 --- /dev/null +++ b/init.gentoo @@ -0,0 +1,78 @@ +#!/sbin/runscript +# Copyright 1999-2013 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +# History +# ------- +# 1/29 Created Richard Powell richard@powell.ws + +# You will need to create a configuration file in order for this script +# to work properly. Please create /etc/conf.d/sickbeard with the following: +# +# SICKBEARD_USER= +# SICKBEARD_GROUP= +# SICKBEARD_DIR= +# PATH_TO_PYTHON_2=/usr/bin/python2 +# SICKBEARD_DATADIR= +# SICKBEARD_CONFDIR= +# + +RUNDIR=/var/run/sickbeard + +depend() { + need net +} + +get_pidfile() { + # Parse the config.ini file for the value of web_port in the General section + eval `sed -e 's/[[:space:]]*\=[[:space:]]*/=/g' \ + -e 's/;.*$//' \ + -e 's/[[:space:]]*$//' \ + -e 's/^[[:space:]]*//' \ + -e "s/^\(.*\)=\([^\"']*\)$/\1=\"\2\"/" \ + < ${SICKBEARD_CONFDIR}/config.ini \ + | sed -n -e "/^\[General\]/,/^\s*\[/{/^[^;].*\=.*/p;}"` + + echo "${RUNDIR}/sickbeard-${web_port}.pid" +} + +start() { + ebegin "Starting Sickbeard" + + checkpath -q -d -o ${SICKBEARD_USER}:${SICKBEARD_GROUP} -m 0770 "${RUNDIR}" + + start-stop-daemon \ + --quiet \ + --start \ + --user ${SICKBEARD_USER} \ + --group ${SICKBEARD_GROUP} \ + --name sickbeard \ + --background \ + --pidfile $(get_pidfile) \ + --exec ${PATH_TO_PYTHON_2} \ + -- \ + ${SICKBEARD_DIR}/SickBeard.py \ + -d \ + --pidfile $(get_pidfile) \ + --config ${SICKBEARD_CONFDIR}/config.ini \ + --datadir ${SICKBEARD_DATADIR} + eend $? +} + +start_pre() { + if [ "$RC_CMD" == "restart" ]; then + local pidfile=$(get_pidfile) + while [ -e ${pidfile} ]; do + sleep 1 + done + fi + + return 0 +} + +stop() { + local pidfile=$(get_pidfile) + local rc + + ebegin "Stopping Sickbeard" +}