From 23a667239d7cada64edd1e6cb9070ac3cd700642 Mon Sep 17 00:00:00 2001 From: 360iDEVph Date: Sun, 8 Apr 2012 05:24:23 -0400 Subject: [PATCH] New init for fedora 15+ using systemd Previous init will not work with Fedora15+ Fedora14 has been EOF 2011-12-08 --- init.fedora | 99 +++++++++-------------------------------------------- 1 file changed, 16 insertions(+), 83 deletions(-) diff --git a/init.fedora b/init.fedora index 9807645e20..1b9158ef32 100755 --- a/init.fedora +++ b/init.fedora @@ -1,92 +1,25 @@ -### BEGIN INIT INFO -# Provides: sickbeard -# Required-Start: $all -# Required-Stop: $all -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: starts Sick Beard -# Description: starts Sick Beard -### END INIT INFO +### New configuration for fedora 15+ using systemd -# Source function library. -. /etc/init.d/functions +# File need to be copied in /lib/systemd/system/sickbeard.service -# Source SickBeard configuration -if [ -f /etc/sysconfig/sickbeard ]; then - . /etc/sysconfig/sickbeard -fi +# To enable sickbeard at startup : systemctl enable sickbeard.service +# To start sickbeard : systemctl start sickbeard.service +# To stop sickbeard : systemctl stop sickbeard.service +# To restart sickbeard : systemctl restart sickbeard.service -prog=sickbeard -lockfile=/var/lock/subsys/$prog +# To get the status sickbeard : systemctl status sickbeard.service -## Edit user configuation in /etc/sysconfig/sickbeard to change -## the defaults -username=${SB_USER-sickbeard} -homedir=${SB_HOME-/opt/sickbeard} -datadir=${SB_DATA-~/.sickbeard} -pidfile=${SB_PIDFILE-/var/run/sickbeard/sickbeard.pid} -nice=${SB_NICE-} -## -pidpath=`dirname ${pidfile}` -options=" --daemon --nolaunch --pidfile=${pidfile} --datadir=${datadir}" +[Unit] +Description=Sick Beard -# create PID directory if not exist and ensure the SickBeard user can write to it -if [ ! -d $pidpath ]; then - mkdir -p $pidpath - chown $username $pidpath -fi +[Service] +ExecStart=/home/movies/sickbeard/SickBeard.py +Type=simple +User=YOUR-USER #need to be change with the user that is supposed to run Sick Beard +Group=YOUR-GROUP #need to be change with the group that is supposed to run Sick Beard -if [ ! -d $datadir ]; then - mkdir -p $datadir - chown $username $datadir -fi +[Install] +WantedBy=multi-user.target -start() { - # Start daemon. - echo -n $"Starting $prog: " - daemon --user=${username} --pidfile=${pidfile} ${nice} python ${homedir}/SickBeard.py ${options} - RETVAL=$? - echo - [ $RETVAL -eq 0 ] && touch $lockfile - return $RETVAL -} - -stop() { - echo -n $"Shutting down $prog: " - killproc -p ${pidfile} python - RETVAL=$? - echo - [ $RETVAL -eq 0 ] && rm -f $lockfile - return $RETVAL -} - -# See how we were called. -case "$1" in - start) - start - ;; - stop) - stop - ;; - status) - status $prog - ;; - restart|force-reload) - stop - start - ;; - try-restart|condrestart) - if status $prog > /dev/null; then - stop - start - fi - ;; - reload) - exit 3 - ;; - *) - echo $"Usage: $0 {start|stop|status|restart|try-restart|force-reload}" - exit 2 -esac