aboutsummaryrefslogtreecommitdiff
path: root/multimedia/serviio/rc.serviio
blob: f81a3bfd74c8f735fd92c1ebdf6702533cc4c672 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash

# rc.serviio - script to run with slackware

# Location of serviio.sh
SERVIIO_CMD=/opt/serviio/bin/serviio.sh
 
# The user Serviio should run under
SERVIIO_USER=serviio

# pid file used
PIDFILE=/var/run/serviio/serviio.pid

# stop/start functions

start() {
    if [ -f "$PIDFILE" ] ; then
        echo "Serviio DNLA server already running or incorrectly stopped!"
        echo "If Serviio DNLA server isn't running, please check if"
        echo "$PIDFILE exists and delete it."
    else
        echo 'Starting Serviio DNLA server...'
        su --login -c "$SERVIIO_CMD" $SERVIIO_USER
    fi
}

stop(){
    if [ -f "$PIDFILE" ] ; then
        echo "Stopping Serviio DNLA server..."
        kill -9 $(<"$PIDFILE")
        if [ -f "$PIDFILE" ] ; then
            rm "$PIDFILE"
        fi
    else
        echo "Serviio DNLA server isn't running or $PIDFILE file is absent!"
    fi
}

case "$1" in
    'start')
        start
        ;;
    'stop')
        stop
        ;;
    'restart')
        stop
        start
        ;;
    *)
        echo "Usage: $0 {start|stop|restart}"
        ;;
esac