diff --git a/README.md b/README.md index 265cf29..83516a6 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ It shall NOT be edited by hand. Jellyfin enables you to collect, manage, and stream your media. Run the Jellyfin server on your system and gain access to the leading free-software entertainment system, bells and whistles included. -**Shipped version:** 10.8.13~ynh2 +**Shipped version:** 10.9.7~ynh1 **Demo:** diff --git a/README_es.md b/README_es.md index 419835d..a14c929 100644 --- a/README_es.md +++ b/README_es.md @@ -19,7 +19,7 @@ No se debe editar a mano. Jellyfin enables you to collect, manage, and stream your media. Run the Jellyfin server on your system and gain access to the leading free-software entertainment system, bells and whistles included. -**Versión actual:** 10.8.13~ynh2 +**Versión actual:** 10.9.7~ynh1 **Demo:** diff --git a/README_eu.md b/README_eu.md index 53d83cd..0e15f52 100644 --- a/README_eu.md +++ b/README_eu.md @@ -19,7 +19,7 @@ EZ editatu eskuz. Jellyfin enables you to collect, manage, and stream your media. Run the Jellyfin server on your system and gain access to the leading free-software entertainment system, bells and whistles included. -**Paketatutako bertsioa:** 10.8.13~ynh2 +**Paketatutako bertsioa:** 10.9.7~ynh1 **Demoa:** diff --git a/README_fr.md b/README_fr.md index 2c6df13..bbce509 100644 --- a/README_fr.md +++ b/README_fr.md @@ -19,7 +19,7 @@ Il NE doit PAS être modifié à la main. Jellyfin vous permet de collecter, gérer et diffuser vos médias. Exécutez le serveur Jellyfin sur votre système et accédez au principal système de divertissement à logiciel libre. -**Version incluse :** 10.8.13~ynh2 +**Version incluse :** 10.9.7~ynh1 **Démo :** diff --git a/README_gl.md b/README_gl.md index 58658b1..4df6bc4 100644 --- a/README_gl.md +++ b/README_gl.md @@ -19,7 +19,7 @@ NON debe editarse manualmente. Jellyfin enables you to collect, manage, and stream your media. Run the Jellyfin server on your system and gain access to the leading free-software entertainment system, bells and whistles included. -**Versión proporcionada:** 10.8.13~ynh2 +**Versión proporcionada:** 10.9.7~ynh1 **Demo:** diff --git a/README_it.md b/README_it.md index 1890511..938290e 100644 --- a/README_it.md +++ b/README_it.md @@ -19,7 +19,7 @@ NON DEVE essere modificato manualmente. Jellyfin enables you to collect, manage, and stream your media. Run the Jellyfin server on your system and gain access to the leading free-software entertainment system, bells and whistles included. -**Versione pubblicata:** 10.8.13~ynh1 +**Versione pubblicata:** 10.9.1~ynh1 **Prova:** diff --git a/README_zh_Hans.md b/README_zh_Hans.md index 5133051..ee428fc 100644 --- a/README_zh_Hans.md +++ b/README_zh_Hans.md @@ -19,7 +19,7 @@ Jellyfin enables you to collect, manage, and stream your media. Run the Jellyfin server on your system and gain access to the leading free-software entertainment system, bells and whistles included. -**分发版本:** 10.8.13~ynh2 +**分发版本:** 10.9.7~ynh1 **演示:** diff --git a/conf/network.xml b/conf/network.xml index 1d60af9..d39dfad 100644 --- a/conf/network.xml +++ b/conf/network.xml @@ -1,35 +1,15 @@ false - - __PATH__ - 8920 - __PORT__ - 8920 + __PORT__ false - __PORT__ - false - true true - false - - 2 - 100 - true - vEthernet* - 60 - false - - - false true - - false true true - - - + + 127.0.0.1 + diff --git a/conf/systemd.service b/conf/systemd.service new file mode 100644 index 0000000..b188e03 --- /dev/null +++ b/conf/systemd.service @@ -0,0 +1,2 @@ +[Service] +Environment="JELLYFIN_PublishedServerUrl=https://__DOMAIN____PATH__" diff --git a/manifest.toml b/manifest.toml index 0c8f86b..1743687 100644 --- a/manifest.toml +++ b/manifest.toml @@ -7,7 +7,7 @@ name = "Jellyfin" description.en = "Media System that manage and stream your media" description.fr = "Système multimédia qui gère et diffuse vos médias" -version = "10.8.13~ynh2" +version = "10.9.7~ynh1" maintainers = ["tituspijean"] @@ -44,7 +44,11 @@ ram.runtime = "100M" type = "group" default = "visitors" - [install.admin] + [install.init_admin_permission] + ask.en = "Select an account to grant it access to Jellyfin's administration panel." + ask.fr = "Choisissez un compte pour lui accorder l'accès au tableau de bord d'administration de Jellyfin." + help.en = "You can grant this access to other accounts and groups with the permission system later." + help.fr = "Vous pourrez octroire l'accès à d'autres comptes et groupes avec le système de permissions plus tard." type = "user" [install.discovery] @@ -56,78 +60,77 @@ ram.runtime = "100M" default = true [resources] - [resources.sources] - [resources.sources.server] - armhf.url = "https://repo.jellyfin.org/files/server/debian/stable/10.8.13/armhf/jellyfin-server_10.8.13-1_armhf.deb" - armhf.sha256 = "ee4588aeeb55282b044d3bb4efef146a43abd742d3ef9327e042b2959008dc60" - arm64.url = "https://repo.jellyfin.org/files/server/debian/stable/10.8.13/arm64/jellyfin-server_10.8.13-1_arm64.deb" - arm64.sha256 = "b9b917ec6ed4ddd3c728cb7be84245ff625c0a7ae12653a921cb3a9f6149252d" - - amd64.url = "https://repo.jellyfin.org/files/server/debian/stable/10.8.13/amd64/jellyfin-server_10.8.13-1_amd64.deb" - amd64.sha256 = "d54decc098d5e61be50847edba8722d6468e22134bae2df514859e064eb8d727" + [resources.sources.server_bullseye] + armhf.url = "https://repo.jellyfin.org/files/server/debian/stable/v10.9.7/armhf/jellyfin-server_10.9.7+deb11_armhf.deb" + armhf.sha256 = "a05083388d32f8de32b9860a41d59d42fc6a976e1f19f44465105cac9e6809b5" + arm64.url = "https://repo.jellyfin.org/files/server/debian/stable/v10.9.7/arm64/jellyfin-server_10.9.7+deb11_arm64.deb" + arm64.sha256 = "09e21c2ef81e15fddb905ec90082b275c13c1a996be2a0defe0256feede89537" + amd64.url = "https://repo.jellyfin.org/files/server/debian/stable/v10.9.7/amd64/jellyfin-server_10.9.7+deb11_amd64.deb" + amd64.sha256 = "55f7f18ee2812aa55e4c5956c954310fd3b37c99d89e1f1dde14b2c5cce2c62c" + format = "whatever" + extract = false rename = "jellyfin-server.deb" + + [resources.sources.server_bookworm] + armhf.url = "https://repo.jellyfin.org/files/server/debian/stable/v10.9.7/armhf/jellyfin-server_10.9.7+deb12_armhf.deb" + armhf.sha256 = "c5f0cd1a685c31276204b85bda20f6739945f3c4c27212ef116fd91364a3afef" + arm64.url = "https://repo.jellyfin.org/files/server/debian/stable/v10.9.7/arm64/jellyfin-server_10.9.7+deb12_arm64.deb" + arm64.sha256 = "f096803d494fe6b60faeb787a11a6e4a3576c13eee46db393f40767d156d0568" + amd64.url = "https://repo.jellyfin.org/files/server/debian/stable/v10.9.7/amd64/jellyfin-server_10.9.7+deb12_amd64.deb" + amd64.sha256 = "fcd2486ce67ab6eba639e06865cc17945a785b698f34e0e9b102807413d727c1" + format = "whatever" extract = false + rename = "jellyfin-server.deb" - [resources.sources.web] - url = "https://repo.jellyfin.org/files/server/debian/stable/10.8.13/amd64/jellyfin-web_10.8.13-1_all.deb" - sha256 = "8a30e2239f97d1d749f6059db0ff1e4189f44babfb9b0cf236102b7c95b0babe" + [resources.sources.web_bullseye] + url = "https://repo.jellyfin.org/files/server/debian/stable/v10.9.7/amd64/jellyfin-web_10.9.7+deb11_all.deb" + sha256 = "3ce87029296d88cbb63a8d114c4b45a2999f4b79fac6ca2fce41be7fe406ba09" + + format = "whatever" + extract = false rename = "jellyfin-web.deb" + + [resources.sources.web_bookworm] + url = "https://repo.jellyfin.org/files/server/debian/stable/v10.9.7/amd64/jellyfin-web_10.9.7+deb12_all.deb" + sha256 = "f203d9a031ee1c781a7cb71f2fee3f998d59d0c94dfdfb6033e5b2d83b3d2007" + format = "whatever" extract = false - - - [resources.sources.ffmpeg_bookworm] - armhf.url = "https://repo.jellyfin.org/files/ffmpeg/debian/6.x/6.0.1-3/armhf/jellyfin-ffmpeg6_6.0.1-3-bookworm_armhf.deb" - armhf.sha256 = "bdb28e67fa4dc8e321366c4a19e18bcc6166a60d6aa5a4bf2da1263489b4f25f" - - arm64.url = "https://repo.jellyfin.org/files/ffmpeg/debian/6.x/6.0.1-3/arm64/jellyfin-ffmpeg6_6.0.1-3-bookworm_arm64.deb" - arm64.sha256 = "aabf62104399f242ddb7b8c2e308976f6b233ceac5ffccbabd340a28e428ca3c" - - amd64.url = "https://repo.jellyfin.org/files/ffmpeg/debian/6.x/6.0.1-3/amd64/jellyfin-ffmpeg6_6.0.1-3-bookworm_amd64.deb" - amd64.sha256 = "cb40c04e026d83b9265535e214f883d4a26824b5703304064fd38fffa70ac449" - - rename = "jellyfin-ffmpeg6.deb" - format = "whatever" - extract = false + rename = "jellyfin-web.deb" [resources.sources.ffmpeg_bullseye] - armhf.url = "https://repo.jellyfin.org/files/ffmpeg/debian/6.x/6.0.1-3/armhf/jellyfin-ffmpeg6_6.0.1-3-bullseye_armhf.deb" - armhf.sha256 = "700bab9e8c96594f83d731019cdbc20fbab303c1d8440288e463e372cd16ed7a" + armhf.url = "https://repo.jellyfin.org/files/ffmpeg/debian/latest-6.x/armhf/jellyfin-ffmpeg6_6.0.1-7-bullseye_armhf.deb" + armhf.sha256 = "4940083aa8bf6f04df7fbd3c5740f96b8b1d41ae2aeef8aba25eed7fbc72dd57" + arm64.url = "https://repo.jellyfin.org/files/ffmpeg/debian/latest-6.x/arm64/jellyfin-ffmpeg6_6.0.1-7-bullseye_arm64.deb" + arm64.sha256 = "106311dfc45cfa69f9588772b9c0327e1558fd5186f6b4ce6d1f615ad09893bb" + amd64.url = "https://repo.jellyfin.org/files/ffmpeg/debian/latest-6.x/amd64/jellyfin-ffmpeg6_6.0.1-7-bullseye_amd64.deb" + amd64.sha256 = "ee50c84a501c530e179088cf3f6d9048fe446e186d93f726a2073b860a313c5c" - arm64.url = "https://repo.jellyfin.org/files/ffmpeg/debian/6.x/6.0.1-3/arm64/jellyfin-ffmpeg6_6.0.1-3-bullseye_arm64.deb" - arm64.sha256 = "56ef93f285e922417cda98b109021be614a5307d9d7c18aff22fa0c439ab77b5" - - amd64.url = "https://repo.jellyfin.org/files/ffmpeg/debian/6.x/6.0.1-3/amd64/jellyfin-ffmpeg6_6.0.1-3-bullseye_amd64.deb" - amd64.sha256 = "50b0cbd2cd0ab64fd6803d2bdfd15946ec6f80c0b492f81ad85e921ffafdcf7e" - - rename = "jellyfin-ffmpeg6.deb" format = "whatever" extract = false - - - [resources.sources.ffmpeg_buster] - armhf.url = "https://repo.jellyfin.org/files/ffmpeg/debian/6.x/6.0.1-3/armhf/jellyfin-ffmpeg6_6.0.1-3-buster_armhf.deb" - armhf.sha256 = "6f3beae72aec030aae96dc044bfcf736f12fc135cc574cde8085609e47374a43" - - arm64.url = "https://repo.jellyfin.org/files/ffmpeg/debian/6.x/6.0.1-3/arm64/jellyfin-ffmpeg6_6.0.1-3-buster_arm64.deb" - arm64.sha256 = "109ea41f17e314e3e9b32689844841ddd54a600419ff89e0e979e195a25b91c5" - - amd64.url = "https://repo.jellyfin.org/files/ffmpeg/debian/6.x/6.0.1-3/amd64/jellyfin-ffmpeg6_6.0.1-3-buster_amd64.deb" - amd64.sha256 = "a1c55b7f439f2b9a487ea90341a280467f1973fcd12607f08bcd16cf22ce307a" - rename = "jellyfin-ffmpeg6.deb" + + [resources.sources.ffmpeg_bookworm] + armhf.url = "https://repo.jellyfin.org/files/ffmpeg/debian/latest-6.x/armhf/jellyfin-ffmpeg6_6.0.1-7-bookworm_armhf.deb" + armhf.sha256 = "03d8a5512c7406e77359475da729157fc653dc5203f2399b59c71c6f59ca10f3" + arm64.url = "https://repo.jellyfin.org/files/ffmpeg/debian/latest-6.x/arm64/jellyfin-ffmpeg6_6.0.1-7-bookworm_arm64.deb" + arm64.sha256 = "6c21dfdd931c576fcd5c095d4aae2cf92d4720beba6c73404f3d56220213c2a4" + amd64.url = "https://repo.jellyfin.org/files/ffmpeg/debian/latest-6.x/amd64/jellyfin-ffmpeg6_6.0.1-7-bookworm_amd64.deb" + amd64.sha256 = "0773fda9111e03394e088790eabc99dbb0291d107a4950bdcbfafd94c5d0652e" + format = "whatever" extract = false + rename = "jellyfin-ffmpeg6.deb" [resources.sources.plugin_ldap] - url = "https://repo.jellyfin.org/files/plugin/ldap-authentication/ldap-authentication_17.0.0.0.zip" - sha256 = "042bdd16950c7569c154311cc64af49c7d6096e9b0a7184287707d5ee317ecf5" + url = "https://repo.jellyfin.org/files/plugin/ldap-authentication/ldap-authentication_19.0.0.0.zip" + sha256 = "3b8366f670484c9ab1ece826667754b69736d910d9ccde90c105a67ba441ead9" in_subdir = false @@ -144,8 +147,16 @@ ram.runtime = "100M" admin.protected = true admin.auth_header = false + admin.show_tile = false [resources.ports] main.default = 8095 + # If we ever want to automatically expose the discovery ports without a setting + # servicediscovery.default = 1900 + # servicediscovery.exposed = "UDP" + # servicediscovery.fixed = true + # clientdiscovery.default = 7359 + # clientdiscovery.exposed = "UDP" + # clientdiscovery.fixed = true [resources.apt] diff --git a/scripts/_common.sh b/scripts/_common.sh index dd8980d..818ba16 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,11 +5,15 @@ #================================================= debian=$(lsb_release --codename --short) -pkg_version="10.8.13-1" +debian_number=$(lsb_release --release --short) +pkg_version="10.9.7" version=$(echo "$pkg_version" | cut -d '-' -f 1) -ffmpeg_pkg_version="6.0.1-3" -ldap_pkg_version="17.0.0.0" +ffmpeg_pkg_version="6.0.1-7" + +# "targetAbi" line in plugin's meta.json, to check for outdated plugins +plugin_abi="10.9.0.0" +ldap_pkg_version="19.0.0.0" discovery_service_port=1900 discovery_client_port=7359 @@ -30,9 +34,10 @@ install_jellyfin_packages() { tempdir="$(mktemp -d)" # Download the deb files - ynh_setup_source --dest_dir="$tempdir" --source_id="web" + ynh_setup_source --dest_dir="$tempdir" --source_id="web_$debian" ynh_setup_source --dest_dir="$tempdir" --source_id="ffmpeg_$debian" - ynh_setup_source --dest_dir="$tempdir" --source_id="server" + ynh_setup_source --dest_dir="$tempdir" --source_id="server_$debian" + # Install the packages ynh_package_install \ @@ -43,26 +48,56 @@ install_jellyfin_packages() { if ynh_package_is_installed "jellyfin-ffmpeg5"; then ynh_package_remove "jellyfin-ffmpeg5" fi + + # Install the packages ynh_package_install \ - "$tempdir/jellyfin-ffmpeg6.deb" + "${tempdir}/jellyfin-ffmpeg6.deb" # The doc says it should be called only once, # but the code says multiple calls are supported. # Also, they're already installed so that should be quasi instantaneous. ynh_install_app_dependencies \ - jellyfin-web="$pkg_version" \ + jellyfin-web="$pkg_version+deb$debian_number" \ jellyfin-ffmpeg6="$ffmpeg_pkg_version-$debian" \ - jellyfin-server="$pkg_version" + jellyfin-server="$pkg_version+deb$debian_number" # Mark packages as dependencies, to allow automatic removal apt-mark auto jellyfin-server jellyfin-web jellyfin-ffmpeg6 } -open_jellyfin_discovery_ports() { +configure_jellyfin_discovery_ports() { + case $1 in + "install") + install_jellyfin_discovery_ports + ;; + "remove") + remove_jellyfin_discovery_ports + ;; + *) + ynh_print_warn --message="Invalid script calling configure_jellyfin_discovery_ports with args (should be install|remove): $@" + ;; + esac +} + +remove_jellyfin_discovery_ports() { + if [[ $discovery_service -eq 1 ]] && yunohost firewall list | grep -q "\- $discovery_service_port$" +then + ynh_exec_warn_less yunohost firewall disallow UDP $discovery_service_port +fi + +if [[ $discovery_client -eq 1 ]] && yunohost firewall list | grep -q "\- $discovery_client_port$" +then + ynh_exec_warn_less yunohost firewall disallow UDP $discovery_client_port +fi + +} + +install_jellyfin_discovery_ports() { discovery_service=$discovery discovery_client=$discovery if [ "$discovery" -eq 1 ]; then + opened_ports=($discovery_service_port $discovery_client_port) # Open port $discovery_service_port for service auto-discovery if ynh_port_available --port=$discovery_service_port; then diff --git a/scripts/install b/scripts/install index d0c1c48..9cb6105 100644 --- a/scripts/install +++ b/scripts/install @@ -23,10 +23,8 @@ ynh_app_setting_set --app="$app" --key=config_path --value="$config_path" #================================================= # OPEN PORTS #================================================= - -ynh_script_progression --message="Configuring firewall..." --weight=1 - -open_jellyfin_discovery_ports +ynh_script_progression --message="Checking whether to open ports..." --weight=1 +configure_jellyfin_discovery_ports install #================================================= # INSTALL PACKAGES @@ -69,6 +67,7 @@ ynh_add_config --template="logging.json" --destination="$config_path/logging.jso ynh_script_progression --message="Installing LDAP plugin..." --weight=2 ynh_setup_source --dest_dir="/var/lib/jellyfin/plugins/LDAP Authentication" --source_id=plugin_ldap + mkdir -p /var/lib/jellyfin/plugins/configurations/ ynh_add_config --template="LDAP-Auth.xml" --destination="/var/lib/jellyfin/plugins/configurations/LDAP-Auth.xml" @@ -106,10 +105,19 @@ ynh_use_logrotate #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add "$app" --description="Jellyfin media center" +ports_args=() +if [[ "${opened_ports:-__NOTHING__}" != "__NOTHING__" ]]; then + ports_args+=('--needs_exposed_ports') + ports_args+=(${opened_ports}) +fi -# Only the admin can access the admin panel of the app (if the app has an admin panel) -ynh_permission_update --permission="admin" --add="$admin" +yunohost service add "$app" --description="Jellyfin media center" ${ports_args[@]} + +#================================================= +# EDIT SYSTEMD ENVIRONMENT VARIABLE FOR AUTO-DISCOVERY +#================================================= +ynh_add_config --template="systemd.service" --destination="/etc/systemd/system/jellyfin.service.d/baseurl.service.conf" +systemctl daemon-reload #================================================= # START SYSTEMD SERVICE diff --git a/scripts/remove b/scripts/remove index 40fb648..df96e13 100644 --- a/scripts/remove +++ b/scripts/remove @@ -41,18 +41,8 @@ ynh_remove_app_dependencies #================================================= # CLOSE A PORT #================================================= - -if [[ $discovery_service -eq 1 ]] && yunohost firewall list | grep -q "\- $discovery_service_port$" -then - ynh_script_progression --message="Closing port $discovery_service_port..." --weight=1 - ynh_exec_warn_less yunohost firewall disallow UDP $discovery_service_port -fi - -if [[ $discovery_client -eq 1 ]] && yunohost firewall list | grep -q "\- $discovery_client_port$" -then - ynh_script_progression --message="Closing port $discovery_client_port..." --weight=1 - ynh_exec_warn_less yunohost firewall disallow UDP $discovery_client_port -fi +ynh_script_progression --message="Checking whether to open ports..." --weight=1 +configure_jellyfin_discovery_ports remove #================================================= # SPECIFIC REMOVE @@ -65,9 +55,6 @@ ynh_secure_remove --file="$config_path" ynh_secure_remove --file="/etc/systemd/system/jellyfin.service.d" ynh_secure_remove --file="/etc/sudoers.d/jellyfin-sudoers" -# Remove the log files -ynh_secure_remove --file="/var/log/$app" - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 45c8098..92cd497 100644 --- a/scripts/restore +++ b/scripts/restore @@ -18,7 +18,6 @@ source /usr/share/yunohost/helpers ynh_script_progression --message="Reconfiguring the dedicated system user..." --weight=1 # It could be created later by the deb, but it's cleaner here -ynh_system_user_create --username=$app if getent group render && ! id -Gn "$app" | grep -qw "\brender\b" >/dev/null; then # Add user to render group adduser $app render @@ -27,9 +26,8 @@ fi #================================================= # OPEN PORTS #================================================= -ynh_script_progression --message="Configuring firewall..." --weight=1 - -open_jellyfin_discovery_ports +ynh_script_progression --message="Checking whether to open ports..." --weight=1 +configure_jellyfin_discovery_ports install #================================================= # RESTORE THE APP MAIN DIR @@ -93,7 +91,15 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add $app --description="Jellyfin media center" +ports_args=() +if [[ "${opened_ports:-__NOTHING__}" = "__NOTHING__" ]]; then + ports_args+=('--open-ports') + ports_args+=(${ports}) +fi + +yunohost service add "$app" --description="Jellyfin media center" "${ports_args[@]}" + + #================================================= # START SYSTEMD SERVICE diff --git a/scripts/update_version.py b/scripts/update_version.py index 00052e9..9672210 100755 --- a/scripts/update_version.py +++ b/scripts/update_version.py @@ -1,14 +1,15 @@ #!/usr/bin/env python3 -from typing import Any +from typing import Any, Tuple, Dict, Optional, List from pathlib import Path +import hashlib import tomlkit import requests import hashlib REPO_ROOT = Path(__file__).parent.parent -JELLYFIN_REPO = "https://repo.jellyfin.org/files" +JELLYFIN_REPO = "https://repo.jellyfin.org" ARCHS = [ "armhf", @@ -16,44 +17,95 @@ ARCHS = [ "amd64", ] -DEBS = [ - "buster", - "bullseye", - "bookworm", -] +DEBS = { + "bullseye": "11", + "bookworm": "12", +} +class JellyfinDistro: + def __init__(self, debian_number: str, debian_name: str, arch: List[str]): + self.debian_number = debian_number + self.debian_name = debian_name + self.arch = arch + + # Version in form of 10.9.0-2 + def server_url(self, version: str, arch: str) -> str: + return f"{JELLYFIN_REPO}/files/server/debian/stable/v{version}/{arch}/jellyfin-server_{version}+deb{self.debian_number}_{arch}.deb" + + def web_url(self, version: str) -> str: + return f"{JELLYFIN_REPO}/files/server/debian/stable/v{version}/amd64/jellyfin-web_{version}+deb{self.debian_number}_all.deb" + + def ffmpeg_url(self, version: str, arch: str) -> str: + return f"{JELLYFIN_REPO}/files/ffmpeg/debian/latest-6.x/{arch}/jellyfin-ffmpeg6_{version}-{self.debian_name}_{arch}.deb" + + def ldap_url(self, version: str) -> str: + return f"{JELLYFIN_REPO}/files/plugin/ldap-authentication/ldap-authentication_{version}.zip" + + def update_package(self, manifest: Dict, package: str, version: str): + url = None + urls = {} + if package == "server": + for arch in self.arch: urls[arch] = self.server_url(version, arch) + key = f"server_{self.debian_name}" + extra = { "format": "whatever", "extract": False, "rename": "jellyfin-server.deb" } + elif package == "web": + url = self.web_url(version) + key = f"web_{self.debian_name}" + extra = { "format": "whatever", "extract": False, "rename": "jellyfin-web.deb" } + elif package == "ffmpeg": + for arch in self.arch: urls[arch] = self.ffmpeg_url(version, arch) + key = f"ffmpeg_{self.debian_name}" + extra = { "format": "whatever", "extract": False, "rename": "jellyfin-ffmpeg6.deb" } + elif package == "ldap": + url = self.ldap_url(version) + key = "plugin_ldap" + extra = {"in_subdir": False} + else: raise Exception(f"Wrong jellyfin package: {package}") + + if key not in manifest["resources"]["sources"]: + manifest["resources"]["sources"][key] = {} + + # Single URL, not per arch + if url: + print(f"Checking for updates for Jellyfin's {package} (distro={self.debian_name}) to version {version}") + self.update_package_helper(manifest["resources"]["sources"][key], package, version, url) + else: + # Different URL per architecture + for arch, url in urls.items(): + if arch not in manifest["resources"]["sources"][key]: + manifest["resources"]["sources"][key][arch] = {} + print(f"Checking for updates for Jellyfin's {package} (arch={arch},distro={self.debian_name}) to version {version}") + self.update_package_helper(manifest["resources"]["sources"][key][arch], package, version, url) + + # Add extra settings + for k, v in extra.items(): + manifest["resources"]["sources"][key][k] = v + + def update_package_helper(self, entry: Dict, package: str, version: str, url: str): + # Assume version changed only if URL changed + if "url" in entry and entry["url"] == url: + print(f" Already at version {version} in manifest.toml.") + return + + sha = sha256sum_of(url) + entry["url"] = url + entry["sha256"] = sha + print(f" Updated to version {version}.") def version_from__common_sh(name: str) -> str: content = (REPO_ROOT/"scripts"/"_common.sh").open(encoding="utf-8").readlines() result = next(filter(lambda line: line.startswith(f"{name}="), content)) return result.split('"')[1] - -def server_url(arch: str, version: str) -> str: - version_simple = version.split("-")[0] - return f"{JELLYFIN_REPO}/server/debian/stable/{version_simple}/{arch}/jellyfin-server_{version}_{arch}.deb" - - -def web_url(arch: str, version: str) -> str: - version_simple = version.split("-")[0] - return f"{JELLYFIN_REPO}/server/debian/stable/{version_simple}/amd64/jellyfin-web_{version}_all.deb" - - -def ffmpeg_url(arch: str, deb: str, version: str) -> str: - major = version.split(".")[0] - return f"{JELLYFIN_REPO}/ffmpeg/debian/6.x/{version}/{arch}/jellyfin-ffmpeg{major}_{version}-{deb}_{arch}.deb" - -def ldap_url(arch: str, version: str) -> str: - major = version.split(".")[0] - return f"{JELLYFIN_REPO}/plugin/ldap-authentication/ldap-authentication_{version}.zip" - - def sha256sum_of(url: str) -> str: - result = requests.get(f"{url}", timeout=10) - - sha256sum = hashlib.sha256(result.content) - return sha256sum.hexdigest() + # No more sha256sum files provided on release repo? + result = requests.get(url, timeout=10) + if result.status_code != 200 and not (result.status_code > 300 and result.status_code < 400): + raise Exception(f"Wrong status code on URL {url}: {result.status_code}") + hasher = hashlib.sha256() + hasher.update(result.content) + return hasher.hexdigest() def main() -> None: manifest_file = REPO_ROOT/"manifest.toml" @@ -63,27 +115,14 @@ def main() -> None: ffmpeg_version = version_from__common_sh("ffmpeg_pkg_version") ldap_version = version_from__common_sh("ldap_pkg_version") - for arch in ARCHS: - url = server_url(arch, jellyfin_version) - manifest["resources"]["sources"]["server"][arch]["url"] = url - manifest["resources"]["sources"]["server"][arch]["sha256"] = sha256sum_of(url) - - url = web_url(arch, jellyfin_version) - manifest["resources"]["sources"]["web"]["url"] = url - manifest["resources"]["sources"]["web"]["sha256"] = sha256sum_of(url) - - for arch in ARCHS: - for deb in DEBS: - url = ffmpeg_url(arch, deb, ffmpeg_version) - manifest["resources"]["sources"][f"ffmpeg_{deb}"][arch]["url"] = url - manifest["resources"]["sources"][f"ffmpeg_{deb}"][arch]["sha256"] = sha256sum_of(url) - - url = ldap_url(arch, ldap_version) - manifest["resources"]["sources"]["plugin_ldap"]["url"] = url - manifest["resources"]["sources"]["plugin_ldap"]["sha256"] = sha256sum_of(url) + for debian_name, debian_number in DEBS.items(): + jellyfin = JellyfinDistro(debian_number, debian_name, ARCHS) + jellyfin.update_package(manifest, "server", jellyfin_version) + jellyfin.update_package(manifest, "web", jellyfin_version) + jellyfin.update_package(manifest, "ffmpeg", ffmpeg_version) + jellyfin.update_package(manifest, "ldap", ldap_version) manifest_file.open("w", encoding="utf-8").write(tomlkit.dumps(manifest)) - if __name__ == "__main__": main() diff --git a/scripts/upgrade b/scripts/upgrade index 9e30bb0..a0fc1f8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -55,31 +55,11 @@ if [ ! -f "/etc/logrotate.d/$app" ]; then ynh_use_logrotate fi -discovery_service=$discovery -discovery_client=$discovery - -if [ $discovery -eq 1 ]; then - ynh_script_progression --message="Configuring firewall..." --weight=1 - - # Open port $discovery_service_port for service auto-discovery - if ynh_port_available --port=$discovery_service_port; then - ynh_exec_warn_less yunohost firewall allow UDP $discovery_service_port - else - discovery_service=0 - ynh_print_warn --message="Port $discovery_service_port (for service auto-discovery) is not available. Continuing nonetheless." - fi - - # Open port $discovery_client_port for client auto-discovery - if ynh_port_available --port=$discovery_client_port; then - ynh_exec_warn_less yunohost firewall allow UDP $discovery_client_port - else - discovery_client=0 - ynh_print_warn --message="Port $discovery_client_port (for client auto-discovery) is not available. Continuing nonetheless." - fi -fi - -ynh_app_setting_set --app=$app --key=discovery_service --value=$discovery_service -ynh_app_setting_set --app=$app --key=discovery_client --value=$discovery_client +#================================================= +# OPEN PORTS +#================================================= +ynh_script_progression --message="Checking whether to open ports..." --weight=1 +configure_jellyfin_discovery_ports install #================================================= # UPGRADE PACKAGES @@ -92,14 +72,6 @@ for name in system.xml network.xml logging.json; do cp "$config_path/$name" "$bakdir/$name" done -# ynh_package_install passes --no-remove so the ffmpeg5 -> ffmpeg6 migration is blocked. -# So we remove the packages before installing the new ones. -if ynh_package_is_installed "jellyfin-ffmpeg5"; then - # Previous versions of the package did not do that so remove_app_dependencies doesn't do its job - apt-mark auto jellyfin-server jellyfin-web jellyfin-ffmpeg5 - # ynh_remove_app_dependencies -fi - install_jellyfin_packages #================================================= @@ -123,17 +95,44 @@ for name in system.xml network.xml logging.json; do done ynh_secure_remove "$bakdir" -# TODO: investigate if we can avoid overriding system.xml -#ynh_add_config --template="system.xml" --destination="$config_path/system.xml" ynh_add_config --template="network.xml" --destination="$config_path/network.xml" ynh_add_config --template="logging.json" --destination="$config_path/logging.json" +#================================================= +# ENSURE NO OLD/INCOMPATIBLE PLUGINS ARE LEFT +#================================================= +shopt -s nullglob +mkdir -p /var/lib/jellyfin/plugins-backup + +if [ -d /var/lib/jellyfin/plugins ]; then + for directory in /var/lib/jellyfin/plugins/*; do + if [[ "$(basename "$directory")" = "configurations" ]]; then + # Kepe plugin config + continue + fi + + if [ ! -f "$directory"/meta.json ]; then + mv "$directory" /var/lib/jellyfin/plugins-backup/ + fi + + # Jellyfin doesn't refuse to start with old plugins. It just does weird + # things such as https://github.com/jellyfin/jellyfin-plugin-ldapauth/issues/161 + # As a precaution, move older ABI plugins to another folder so things don't break + abi="$(jq -r '.targetAbi' "$directory"/meta.json)" + if [[ "$abi" != "$plugin_abi" ]]; then + name="$(basename "$directory")" + ynh_print_warn --message="Jellyfin plugin '$name' has different ABI version $abi than expected $plugin_abi. Moving to /var/lib/jellyfin/plugins-backup." + mv "$directory" /var/lib/jellyfin/plugins-backup/ + fi + done +fi + #================================================= # INSTALL LDAP PLUGIN #================================================= ynh_script_progression --message="Installing LDAP plugin..." --weight=2 -ynh_setup_source --dest_dir="/var/lib/jellyfin/plugins/LDAP Authentication" --source_id=plugin_ldap +ynh_setup_source --full_replace=1 --dest_dir="/var/lib/jellyfin/plugins/LDAP Authentication" --source_id=plugin_ldap mkdir -p /var/lib/jellyfin/plugins/configurations/ ynh_add_config --template="LDAP-Auth.xml" --destination="/var/lib/jellyfin/plugins/configurations/LDAP-Auth.xml" @@ -163,21 +162,33 @@ ynh_multimedia_addaccess $app ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 # Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --non-append +ynh_use_logrotate #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add $app --description="Jellyfin media center" +ports_args=() +if [[ "${opened_ports:-__NOTHING__}" = "__NOTHING__" ]]; then + ports_args+=('--open-ports') + ports_args+=(${ports}) +fi + +yunohost service add "$app" --description="Jellyfin media center" "${ports_args[@]}" + +#================================================= +# EDIT SYSTEMD ENVIRONMENT VARIABLE FOR AUTO-DISCOVERY +#================================================= +ynh_add_config --template="systemd.service" --destination="/etc/systemd/system/jellyfin.service.d/baseurl.service.conf" +systemctl daemon-reload #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --timeout=15 +ynh_systemd_action --service_name=$app --action="restart" --log_path="systemd" --timeout=15 #================================================= # END OF SCRIPT diff --git a/tests.toml b/tests.toml index f2ab19f..c093236 100644 --- a/tests.toml +++ b/tests.toml @@ -8,8 +8,9 @@ test_format = 1.0 sudo apt update >/dev/null """ - args.admin = "john" + args.admin = "package_checker" + args.init_admin_permission="package_checker" - test_upgrade_from.384dcd2ff1dbf4b0085edb7f12e4d15f00508e2b.name = "10.8.0_ynh1" - test_upgrade_from.384dcd2ff1dbf4b0085edb7f12e4d15f00508e2b.args.domain = "domain.tld" - test_upgrade_from.384dcd2ff1dbf4b0085edb7f12e4d15f00508e2b.args.admin = "john" + test_upgrade_from.c78bd4fc24803f23b1d243f397f3128d8fe663d8.name = "10.8.13_ynh1" + test_upgrade_from.c78bd4fc24803f23b1d243f397f3128d8fe663d8.args.domain = "domain.tld" + test_upgrade_from.c78bd4fc24803f23b1d243f397f3128d8fe663d8.args.admin = "package_checker"