flathub / org.jellyfin.JellyfinServer

https://flathub.org/apps/details/org.jellyfin.JellyfinServer
0 stars 1 forks source link

Environment variables are not honored #87

Open lwbt opened 10 months ago

lwbt commented 10 months ago

I wanted to run the Flatpak version of Jellyfin server in headless mode and found that environment variables are not honored. To run in headless mode one is supposed to set $JELLYFIN_SERVICE_OPT to "--service".

This is unexpected for users who want to migrate from DEB/RPM to Flatpak. I want to suggest calling the binary with the same parameters as it is done in the upstream repository for Debian and Fedora. And also to not try to start a browser.

My suggestion would be to make the following changes:

--- org.jellyfin.JellyfinServer.sh  2023-08-12 23:57:11.115058971 +0200
+++ org.jellyfin.JellyfinServer_.sh 2023-08-13 00:12:29.853602245 +0200
@@ -3,9 +3,11 @@
 PORT=8096

 if ! curl http://localhost:$PORT > /dev/null 2>&1; then
-  (sleep 10 && xdg-open http://localhost:$PORT) &
+  if [ -z "$JELLYFIN_SERVICE_OPT" ]; then
+    (sleep 10 && xdg-open http://localhost:$PORT) &
+  fi
   mkdir -p ~/.var/app/org.jellyfin.JellyfinServer/media
-  jellyfin
+  jellyfin $JELLYFIN_WEB_OPT $JELLYFIN_FFMPEG_OPT $JELLYFIN_SERVICE_OPT $JELLYFIN_NOWEBAPP_OPT $JELLYFIN_ADDITIONAL_OPTS
 else
   xdg-open http://localhost:$PORT
 fi

I wanted to suggest using ! "${JELLYFIN_SERVICE_OPT}" =~ "--service" until I realized that the shebang is #!/bin/sh.

It should be possible for users to adapt the existing systemd service units with minor changes and have the flatpaked server run without manual intervention. When I tried, systemd said it received exit code 137.

istori1 commented 10 months ago

Please submit a pull request with the changes. Thank you.