Created
June 29, 2014 09:21
-
-
Save pioz/737e8d2e5f6d35c72969 to your computer and use it in GitHub Desktop.
init.d script for serviio
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
#! /bin/sh | |
### BEGIN INIT INFO | |
# Provides: serviio | |
# Required-Start: $syslog | |
# Required-Stop: $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 1 | |
# Short-Description: Serviio daemon | |
# Description: Serviio is a free media server. It allows you to stream your media files (music, video or images) to renderer devices (e.g. a TV set, Bluray player, games console or mobile phone) on your connected home network. | |
### END INIT INFO | |
VERSION=1.4.1.2 | |
NAME=serviio | |
BIN=/opt/$NAME-$VERSION/bin/$NAME.sh | |
PIDFILE=/var/run/$NAME.pid | |
DESC="Serviio free media server" | |
# Exit if the package is not installed | |
test -x $BIN || exit 0 | |
# Import init functions | |
. /lib/lsb/init-functions | |
case "$1" in | |
start) | |
log_daemon_msg "Starting $DESC" "$NAME" | |
if [ -f $PIDFILE ]; then | |
log_end_msg 1 | |
log_failure_msg "$NAME is already running." | |
else | |
start-stop-daemon -b -p$PIDFILE --start --quiet --exec $BIN | |
status=$? | |
sleep 3 | |
echo `ps -ef | grep -v grep | grep "$BIN" | awk '{print $2}'` > $PIDFILE | |
log_end_msg $status | |
fi | |
;; | |
stop) | |
log_daemon_msg "Stopping $DESC" "$NAME" | |
if [ -f $PIDFILE ]; then | |
$BIN -stop | |
status=$? | |
#kill `cat $PIDFILE` | |
rm -f $PIDFILE | |
log_end_msg $status | |
else | |
log_end_msg 1 | |
log_failure_msg "$NAME is not running." | |
fi | |
;; | |
restart) | |
/etc/init.d/$NAME stop | |
sleep 1 | |
/etc/init.d/$NAME start | |
;; | |
*) | |
echo "Usage: /etc/init.d/$NAME {start|stop|restart}" >&2 | |
exit 1 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment