forked from midgetspy/Sick-Beard
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request midgetspy#357 from fyelles/fedora14+
New init for fedora 15+ using systemd
- Loading branch information
Showing
1 changed file
with
16 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|