From 18ef4a46842c30c3da3a93cca6c5f1c6110307a0 Mon Sep 17 00:00:00 2001 From: Joshua Boniface Date: Wed, 12 Dec 2018 19:14:20 -0500 Subject: [PATCH 1/5] Major rejigger of init configurations --- debian/conf/jellyfin | 46 +++++++++++-------------------- debian/conf/jellyfin.conf | 24 ---------------- debian/conf/jellyfin.service.conf | 8 ++++++ debian/install | 2 +- debian/jellyfin.init | 5 ++-- debian/jellyfin.service | 16 ++++++----- debian/jellyfin.upstart | 4 +-- 7 files changed, 39 insertions(+), 66 deletions(-) delete mode 100644 debian/conf/jellyfin.conf create mode 100644 debian/conf/jellyfin.service.conf diff --git a/debian/conf/jellyfin b/debian/conf/jellyfin index 57f424c060..7014899458 100644 --- a/debian/conf/jellyfin +++ b/debian/conf/jellyfin @@ -1,37 +1,23 @@ -# Defaults for jellyfin initscript -# sourced by /etc/init.d/jellyfin and /usr/lib/jellyfin/jellyfin.sh -# installed at /etc/default/jellyfin by the maintainer scripts +# Jellyfin default configuration options + +# Use this file to override the default configurations; add additional +# options with JELLYFIN_ADD_OPTS. + +# Under systemd, use +# /etc/systemd/system/jellyfin.service.d/jellyfin.service.conf +# to override the user, the exec command, or this config file's location. # # This is a POSIX shell fragment # -## Don't edit this file -## Edit user configuration in /etc/jellyfin.conf to change -## -## JELLYFIN_USER= #$JELLYFIN_USER, username to run Jellyfin under, the default is jellyfin -## JELLYFIN_GROUP= #$JELLYFIN_GROUP, Jellyfin group where Jellyfin user belongs -## JELLYFIN_DIR= #$JELLYFIN_DIR, the location of Jellyfin program files the default is /usr/lib/jellyfin -## JELLYFIN_BIN= #$JELLYFIN_BIN, full path of MediaBrowser.Server.Mono.exe the default is /usr/lib/jellyfin/bin/MediaBrowser.Server.Mono.exe -## JELLYFIN_DATA= #$JELLYFIN_DATA, the location of Jellyfin data, cache, logs, the default is /var/lib/jellyfin -## JELLYFIN_PIDFILE= #$JELLYFIN_PIDFILE, the location of jellyfin.pid, the default is /var/run/jellyfin/jellyfin.pid -## JELLYFIN_ADD_OPTS= #$JELLYFIN_ADD_OPTS, additional options to pass to the Jellyfin executable, beyond ffmpeg, ffprobe and restart -## MONO_BIN= #$MONO_BIN, full path of mono binary, the default is /usr/bin/mono-sgen -## MONO_OPTS= #$MONO_OPTS, list of additional options to pass to mono binary -## MONO_ENV= #$MONO_ENV, list of environment variables for running mono binary -## -## EXAMPLE if want to run as different user -## add JELLYFIN_USER=username to /etc/jellyfin.conf -## otherwise default jellyfin is used - -JELLYFIN_USER="jellyfin" -JELLYFIN_GROUP="jellyfin" -JELLYFIN_DIR="/usr/lib/jellyfin" -JELLYFIN_BIN="/usr/lib/jellyfin/bin/MediaBrowser.Server.Mono.exe" +# General options +JELLYFIN_EXE="/usr/lib/jellyfin/bin/jellyfin.dll" JELLYFIN_DATA="/var/lib/jellyfin" -JELLYFIN_PIDFILE="/var/run/jellyfin.pid" +JELLYFIN_RESTART_SCRIPT="/usr/lib/jellyfin/restart.sh" JELLYFIN_ADD_OPTS="" -MONO_BIN="/usr/bin/mono-sgen" -MONO_OPTS="--optimize=all" -MONO_ENV="MONO_THREADS_PER_CPU=250 MONO_GC_PARAMS=nursery-size=128m" -UMASK="002" + +# init/upstart options +JELLYFIN_USER="jellyfin" +JELLYFIN_DOTNET="/usr/bin/dotnet" +JELLYFIN_COMMAND="$JELLYFIN_EXE -programdata $JELLYFIN_DATA -restartpath $JELLYFIN_RESTART_SCRIPT $JELLYFIN_ADD_OPTS" diff --git a/debian/conf/jellyfin.conf b/debian/conf/jellyfin.conf deleted file mode 100644 index ef5c424e87..0000000000 --- a/debian/conf/jellyfin.conf +++ /dev/null @@ -1,24 +0,0 @@ -# Override defaults for jellyfin initscript -# sourced by /etc/init.d/jellyfin and /usr/bin/jellyfin -# installed at /etc/jellyfin.conf by the maintainer scripts - -# -# This is a POSIX shell fragment -# - -## To change the defaults add any of the following settings below the comments -## -## JELLYFIN_USER= #$JELLYFIN_USER, username to run Jellyfin under, the default is jellyfin -## JELLYFIN_GROUP= #$JELLYFIN_GROUP, Jellyfin group where Jellyfin user belongs -## JELLYFIN_DIR= #$JELLYFIN_DIR, the location of Jellyfin program files the default is /usr/lib/jellyfin -## JELLYFIN_BIN= #$JELLYFIN_BIN, full path of MediaBrowser.Server.Mono.exe the default is /usr/lib/jellyfin/bin/MediaBrowser.Server.Mono.exe -## JELLYFIN_DATA= #$JELLYFIN_DATA, the location of Jellyfin data, cache, logs, the default is /var/lib/jellyfin -## JELLYFIN_PIDFILE= #$JELLYFIN_PIDFILE, the location of jellyfin.pid, the default is /var/run/jellyfin/jellyfin.pid -## JELLYFIN_ADD_OPTS= #$JELLYFIN_ADD_OPTS, additional options to pass to the Jellyfin executable, beyond ffmpeg, ffprobe and restart -## MONO_BIN= #$MONO_BIN, full path of mono binary, the default is /usr/bin/mono-sgen -## MONO_OPTS= #$MONO_OPTS, list of additional options to pass to mono binary -## MONO_ENV= #$MONO_ENV, list of environment variables for running mono binary -## -## EXAMPLE if want to run as different user -## add JELLYFIN_USER=username -## otherwise default jellyfin is used diff --git a/debian/conf/jellyfin.service.conf b/debian/conf/jellyfin.service.conf new file mode 100644 index 0000000000..fdc0aba817 --- /dev/null +++ b/debian/conf/jellyfin.service.conf @@ -0,0 +1,8 @@ +# Jellyfin systemd configuration options + +# Use this file to override the user, environment file, or exec command. + +[Service] +#User = jellyfin +#EnvironmentFile = /etc/default/jellyfin +#ExecStart = /usr/bin/dotnet ${JELLYFIN_EXE} -programdata ${JELLYFIN_DATA} -restartpath ${JELLYFIN_RESTART_SCRIPT} ${JELLYFIN_ADD_OPTS} diff --git a/debian/install b/debian/install index a45091a3cf..bc26f9f09a 100644 --- a/debian/install +++ b/debian/install @@ -1,5 +1,5 @@ usr/lib/jellyfin usr/lib/ -debian/conf/jellyfin.conf etc/ debian/conf/jellyfin etc/default/ +debian/conf/jellyfin.service.conf etc/systemd/system/jellyfin.service.d/ debian/bin/jellyfin-sudoers etc/sudoers.d/ debian/bin/restart.sh usr/lib/jellyfin/ diff --git a/debian/jellyfin.init b/debian/jellyfin.init index 4f23e13f07..18c7d02a10 100644 --- a/debian/jellyfin.init +++ b/debian/jellyfin.init @@ -9,13 +9,14 @@ ### END INIT INFO # Carry out specific functions when asked to by the system -pid=`ps -fA|grep dotnet|grep JellyfinServer|awk '{print $2}'| tr -d '\n'` +pid=`ps -fA|grep dotnet|grep jellyfin|awk '{print $2}'| tr -d '\n'` case "$1" in start) if [ "$pid" == "" ]; then echo "Starting Jellyfin..." - nohup dotnet /usr/lib/jellyfin/bin/EmbyServer.dll >/dev/null 2>&1 & + . /etc/default/jellyfin + nohup su -u $JELLYFIN_USER -c $JELLYFIN_DOTNET $JELLYFIN_COMMAND else echo "Jellyfin already running" fi diff --git a/debian/jellyfin.service b/debian/jellyfin.service index 751d19f895..982608a7e0 100644 --- a/debian/jellyfin.service +++ b/debian/jellyfin.service @@ -1,12 +1,14 @@ [Unit] -Description=Jellyfin Media Server -After=network.target +Description = Jellyfin Media Server +After = network.target [Service] -User=jellyfin -ExecStart=/usr/bin/dotnet /usr/lib/jellyfin/bin/EmbyServer.dll -Restart=on-abort -TimeoutSec=20 +Type = simple +EnvironmentFile = /etc/default/jellyfin +User = jellyfin +ExecStart = /usr/bin/dotnet ${JELLYFIN_EXE} -programdata ${JELLYFIN_DATA} -restartpath ${JELLYFIN_RESTART_SCRIPT} ${JELLYFIN_ADD_OPTS} +Restart = on-abort +TimeoutSec = 20 [Install] -WantedBy=multi-user.target +WantedBy = multi-user.target diff --git a/debian/jellyfin.upstart b/debian/jellyfin.upstart index ea7831ac00..ebbceaf578 100644 --- a/debian/jellyfin.upstart +++ b/debian/jellyfin.upstart @@ -15,6 +15,6 @@ script # Log file logger -t "$0" "DEBUG: `set`" - exec /usr/bin/jellyfin start - exec /usr/bin/dotnet /usr/lib/jellyfin/bin/EmbyServer.dll + . /etc/default/jellyfin + exec su -u $JELLYFIN_USER -c $JELLYFIN_DOTNET $JELLYFIN_COMMAND end script From 401c08ebae62bba53fb633059078b2f1864d755f Mon Sep 17 00:00:00 2001 From: Joshua Boniface Date: Wed, 12 Dec 2018 19:27:32 -0500 Subject: [PATCH 2/5] Turn off dotnet build --- debian/rules | 1 - 1 file changed, 1 deletion(-) diff --git a/debian/rules b/debian/rules index 864b64f6f4..eddf9b9bae 100755 --- a/debian/rules +++ b/debian/rules @@ -15,7 +15,6 @@ override_dh_auto_test: override_dh_clistrip: override_dh_auto_build: - dotnet build --configuration $(CONFIG) $(CURDIR)/MediaBrowser.sln --output='$(CURDIR)/usr/lib/jellyfin/bin' dotnet publish --configuration $(CONFIG) $(CURDIR)/MediaBrowser.sln --output='$(CURDIR)/usr/lib/jellyfin/bin' override_dh_auto_clean: From 90a65c009f312c6726dce6abc41f8a178d6fce23 Mon Sep 17 00:00:00 2001 From: Joshua Boniface Date: Wed, 12 Dec 2018 19:33:12 -0500 Subject: [PATCH 3/5] Can't override ExecStart --- debian/conf/jellyfin.service.conf | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/debian/conf/jellyfin.service.conf b/debian/conf/jellyfin.service.conf index fdc0aba817..1b69dd74ef 100644 --- a/debian/conf/jellyfin.service.conf +++ b/debian/conf/jellyfin.service.conf @@ -1,8 +1,7 @@ # Jellyfin systemd configuration options -# Use this file to override the user, environment file, or exec command. +# Use this file to override the user or environment file location. [Service] #User = jellyfin #EnvironmentFile = /etc/default/jellyfin -#ExecStart = /usr/bin/dotnet ${JELLYFIN_EXE} -programdata ${JELLYFIN_DATA} -restartpath ${JELLYFIN_RESTART_SCRIPT} ${JELLYFIN_ADD_OPTS} From 629bedc6e8517adcb338bdd99a1d8ec81de3ab80 Mon Sep 17 00:00:00 2001 From: Joshua Boniface Date: Wed, 12 Dec 2018 19:34:51 -0500 Subject: [PATCH 4/5] Fix up the comment --- debian/conf/jellyfin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/conf/jellyfin b/debian/conf/jellyfin index 7014899458..33b6eee822 100644 --- a/debian/conf/jellyfin +++ b/debian/conf/jellyfin @@ -5,7 +5,7 @@ # Under systemd, use # /etc/systemd/system/jellyfin.service.d/jellyfin.service.conf -# to override the user, the exec command, or this config file's location. +# to override the user or this config file's location. # # This is a POSIX shell fragment From 917ccad0abfeb41f000459d6be24412774a029dc Mon Sep 17 00:00:00 2001 From: Joshua Boniface Date: Wed, 12 Dec 2018 19:37:40 -0500 Subject: [PATCH 5/5] Improve formatting and add comments --- debian/conf/jellyfin | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/debian/conf/jellyfin b/debian/conf/jellyfin index 33b6eee822..5c26d12c3e 100644 --- a/debian/conf/jellyfin +++ b/debian/conf/jellyfin @@ -11,13 +11,26 @@ # This is a POSIX shell fragment # +# # General options +# + +# Path to the jellyfin.dll executable JELLYFIN_EXE="/usr/lib/jellyfin/bin/jellyfin.dll" +# Data directory JELLYFIN_DATA="/var/lib/jellyfin" +# Restart script for in-app server control JELLYFIN_RESTART_SCRIPT="/usr/lib/jellyfin/restart.sh" +# Additional options for the binary JELLYFIN_ADD_OPTS="" -# init/upstart options +# +# SysV init/Upstart options +# + +# Application username JELLYFIN_USER="jellyfin" +# .NET Core runtime binary JELLYFIN_DOTNET="/usr/bin/dotnet" +# Full application command JELLYFIN_COMMAND="$JELLYFIN_EXE -programdata $JELLYFIN_DATA -restartpath $JELLYFIN_RESTART_SCRIPT $JELLYFIN_ADD_OPTS"