Fri Dec 11, 2009 7:59 pm by Qkxy
Hi!
I made this script for serviio 0.2 on OpenSuSE 11.2:
/etc/init.d/serviio
- Code:
#! /bin/sh
# Copyright (c) 2009 Zoltan Kukk
#
# Author: zoltan.kukk@gmail.com
#
# /etc/init.d/serviio
#
#
### BEGIN INIT INFO
# Provides: serviio
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Description: Start the serviio DLNA server in headless mode
### END INIT INFO
SERVIIO_BIN=/usr/bin/serviio
test -x $SERVIIO_BIN || { echo "$SERVIIO_BIN not installed";
if [ "$1" = "stop" ]; then exit 0;
else exit 5; fi; }
# Load the rc.status script for this service.
. /etc/rc.status
# Shell functions sourced from /etc/rc.status:
# rc_check check and set local and overall rc status
# rc_status check and set local and overall rc status
# rc_status -v ditto but be verbose in local rc status
# rc_status -v -r ditto and clear the local rc status
# rc_failed set local and overall rc status to failed
# rc_reset clear local rc status (overall remains)
# rc_exit exit appropriate to overall rc status
# First reset status of this service
rc_reset
case "$1" in
start)
echo -n "Starting Serviio DLNA server"
## Start daemon with startproc(8). If this fails
## the echo return value is set appropriate.
startproc -f -u nobody -g video -l /var/log/serviio.log $SERVIIO_BIN -headless
# Remember status and be verbose
rc_status -v
;;
start-gui)
echo -n "Starting Serviio DLNA server"
## Start daemon with startproc(8). If this fails
## the echo return value is set appropriate.
startproc -f -u nobody -g video -l /var/log/serviio.log $SERVIIO_BIN
# Remember status and be verbose
rc_status -v
;;
stop)
echo -n "Shutting down Serviio DLNA daemon"
## Stop daemon with killproc(8) and if this fails
## set echo the echo return value.
startproc -f -u nobody -g video -l /var/log/serviio.log $SERVIIO_BIN -stop
# Remember status and be verbose
rc_status -v
;;
try-restart)
## Stop the service and if this succeeds (i.e. the
## service was running before), start it again.
$0 status >/dev/null && $0 restart
# Remember status and be quiet
rc_status
;;
restart)
## Stop the service and regardless of whether it was
## running or not, start it again.
$0 stop
$0 start
# Remember status and be quiet
rc_status
;;
force-reload|reload)
## Signal the daemon to reload its config. Most daemons
## do this on signal 1 (SIGHUP).
echo -n "Reload Serviio DLNA server"
rc_failed 3
rc_status -v
;;
status)
echo -n "Checking for service serviio "
## Check status with checkproc(8), if process is running
## checkproc will return with exit status 0.
# Status has a slightly different for the status command:
# 0 - service running
# 1 - service dead, but /var/run/ pid file exists
# 2 - service dead, but /var/lock/ lock file exists
# 3 - service not running
# NOTE: checkproc returns LSB compliant status values.
checkproc $SERVIIO_BIN
# NOTE: rc_status knows that we called this init script with
# "status" option and adapts its messages accordingly.
rc_status -v
;;
probe)
## Optional: Probe for the necessity of a reload,
## give out the argument which is required for a reload.
;;
*)
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
exit 1
;;
esac
rc_exit
Set Serviio owner (My video files owned by video group):
chown -R nobody:video /path_to_pc5dczc_root
Symlinks:
ln -s /path_to_pc5dczc_root/bin/serviio.sh /usr/bin/serviio
ln -s /etc/init.d/serviio /sbin/rcserviio
Set up running on default runlevel:
/sbin/insserv /etc/init.d/serviio
Samsung LE40B650T2W - SQ04 - 2009/09/30_002005
OpenSuSE 11.2
Serviio 0.3