aboutsummaryrefslogtreecommitdiff
path: root/debian/conf/jellyfin.init
blob: 02c15adb5c39dde1ab3f4c5d320737f9de9ef5b5 (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
54
55
56
57
58
59
60
61
62
#!/bin/sh
### 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

set -e

# Carry out specific functions when asked to by the system

if test -f /etc/default/jellyfin; then
    . /etc/default/jellyfin
fi

. /lib/lsb/init-functions

PIDFILE="/run/jellyfin.pid"

case "$1" in
  start)
	log_daemon_msg "Starting Jellyfin Media Server" "jellyfin" || true

	if start-stop-daemon --start --quiet --oknodo --background --chdir $JELLYFIN_DATA_DIR --pidfile $PIDFILE --make-pidfile --user $JELLYFIN_USER --chuid $JELLYFIN_USER --exec /usr/bin/jellyfin -- $JELLYFIN_ARGS; then
	    log_end_msg 0 || true
	else
	    log_end_msg 1 || true
	fi
    ;;

  stop)
	log_daemon_msg "Stopping Jellyfin Media Server" "jellyfin" || true
	if start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE --remove-pidfile; then
	    log_end_msg 0 || true
	else
	    log_end_msg 1 || true
	fi
    ;;

  restart)
	log_daemon_msg "Restarting Jellyfin Media Server" "jellyfin" || true
	start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile $PIDFILE --remove-pidfile
	if start-stop-daemon --start --quiet --oknodo --background --chdir $JELLYFIN_DATA_DIR --pidfile $PIDFILE --make-pidfile --user $JELLYFIN_USER --chuid $JELLYFIN_USER --exec /usr/bin/jellyfin -- $JELLYFIN_ARGS; then
	    log_end_msg 0 || true
	else
	    log_end_msg 1 || true
	fi
	;;

  status)
	status_of_proc -p $PIDFILE /usr/bin/jellyfin jellyfin && exit 0 || exit $?
  ;;

  *)
    echo "Usage: $0 {start|stop|restart|status}"
    exit 1
    ;;
esac
bgstack15