2018-12-09 23:45:08 +00:00
|
|
|
### BEGIN INIT INFO
|
2018-12-10 00:09:43 +00:00
|
|
|
# Provides: Jellyfin Media Server
|
2018-12-09 22:33:40 +00:00
|
|
|
# Required-Start: $local_fs $network
|
|
|
|
# Required-Stop: $local_fs
|
2018-12-09 23:45:08 +00:00
|
|
|
# Default-Start: 2 3 4 5
|
|
|
|
# Default-Stop: 0 1 6
|
2018-12-10 00:09:43 +00:00
|
|
|
# Short-Description: Jellyfin Media Server
|
|
|
|
# Description: Runs Jellyfin Server
|
2018-12-09 23:45:08 +00:00
|
|
|
### END INIT INFO
|
|
|
|
|
2019-03-20 19:00:23 +00:00
|
|
|
set -e
|
|
|
|
|
2018-12-09 22:33:40 +00:00
|
|
|
# Carry out specific functions when asked to by the system
|
2018-12-15 02:21:48 +00:00
|
|
|
|
2019-03-20 19:00:23 +00:00
|
|
|
if test -f /etc/default/jellyfin; then
|
|
|
|
. /etc/default/jellyfin
|
|
|
|
fi
|
|
|
|
|
|
|
|
. /lib/lsb/init-functions
|
|
|
|
|
|
|
|
PIDFILE="/run/jellyfin.pid"
|
2018-12-09 23:45:08 +00:00
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
2019-03-20 19:00:23 +00:00
|
|
|
log_daemon_msg "Starting Jellyfin Media Server" "jellyfin" || true
|
|
|
|
|
|
|
|
if start-stop-daemon --start --quiet --oknodo --background --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
|
2018-12-09 23:45:08 +00:00
|
|
|
;;
|
2019-03-20 19:00:23 +00:00
|
|
|
|
2018-12-09 23:45:08 +00:00
|
|
|
stop)
|
2019-03-20 19:00:23 +00:00
|
|
|
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
|
2018-12-09 23:45:08 +00:00
|
|
|
;;
|
2019-03-20 19:00:23 +00:00
|
|
|
|
|
|
|
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 --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
|
|
|
|
;;
|
|
|
|
|
2018-12-09 23:45:08 +00:00
|
|
|
status)
|
2019-03-20 19:00:23 +00:00
|
|
|
status_of_proc -p $PIDFILE /usr/bin/jellyfin jellyfin && exit 0 || exit $?
|
2018-12-09 22:33:40 +00:00
|
|
|
;;
|
2019-03-20 19:00:23 +00:00
|
|
|
|
2018-12-09 23:45:08 +00:00
|
|
|
*)
|
2019-03-20 19:00:23 +00:00
|
|
|
echo "Usage: $0 {start|stop|restart|status}"
|
2018-12-09 22:33:40 +00:00
|
|
|
exit 1
|
2018-12-09 23:45:08 +00:00
|
|
|
;;
|
|
|
|
esac
|