aboutsummaryrefslogtreecommitdiff
path: root/debian/jellyfin.init
blob: d103fb0f1239338570489b30e3f5b215208fc5f6 (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
### BEGIN INIT INFO
# Provides:          Jellyfin Media Server
# Required-Start:    $local_fs $network
# Required-Stop:     $local_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Jellyfin Media Server
# Description:       Runs Jellyfin Server
### END INIT INFO

# Carry out specific functions when asked to by the system

pidfile="/var/run/jellyfin.pid"
pid=`cat $pidfile`

case "$1" in
  start)
        if [ "$pid" == "" ]; then
                echo "Starting Jellyfin..."
                . /etc/default/jellyfin
                nohup su -u $JELLYFIN_USER -c /usr/bin/jellyfin $JELLYFIN_ARGS
                echo ?? > $pidfile
        else
                echo "Jellyfin already running"
        fi
    ;;
  stop)
        if [ "$pid" != "" ]; then
                echo "Stopping Jellyfin..."
                kill $pid
                sleep 2
                rm -f $pidfile
        else
                echo "Jellyfin not running"
        fi
    ;;
  status)
        if [ "$pid" != "" ]; then
                echo "Jellyfin running as $pid"
                ps -f $pid
        else
                echo "Jellyfin is not running"
        fi
  ;;
  *)
    echo "Usage: $0 {start|stop}"
    exit 1
    ;;
esac