From dc5ab412fe599ce6d558c2f55fe53d2c21956c08 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89ric=20Gaspar?=
<46165813+ericgaspar@users.noreply.github.com>
Date: Fri, 13 Nov 2020 21:14:44 +0100
Subject: [PATCH 1/9] Testing (#39)
* Fixing and overhaul of the app
* Relying on the repository instead of deb sources
* Overhaul to meet packaging standards
* Removal of helpers that have been integrated in YunoHost
---
README.md | 69 +++++++++---
check_process | 38 ++++---
conf/jellyfin-ffmpeg-amd64.src | 7 --
conf/jellyfin-ffmpeg-arm64.src | 7 --
conf/jellyfin-ffmpeg-armhf.src | 7 --
conf/jellyfin-server-amd64.src | 7 --
conf/jellyfin-server-arm64.src | 7 --
conf/jellyfin-server-armhf.src | 7 --
conf/jellyfin-web.src | 7 --
conf/nginx.conf | 37 +++----
manifest.json | 26 ++---
scripts/_common.sh | 119 +++-----------------
scripts/backup | 32 +++---
scripts/change_url | 142 ++++++++++++++++++++++++
scripts/install | 191 +++++++++++++--------------------
scripts/remove | 73 ++++---------
scripts/restore | 49 ++++++---
scripts/upgrade | 150 ++++++++++++++++----------
18 files changed, 496 insertions(+), 479 deletions(-)
delete mode 100644 conf/jellyfin-ffmpeg-amd64.src
delete mode 100644 conf/jellyfin-ffmpeg-arm64.src
delete mode 100644 conf/jellyfin-ffmpeg-armhf.src
delete mode 100644 conf/jellyfin-server-amd64.src
delete mode 100644 conf/jellyfin-server-arm64.src
delete mode 100644 conf/jellyfin-server-armhf.src
delete mode 100644 conf/jellyfin-web.src
create mode 100644 scripts/change_url
diff --git a/README.md b/README.md
index 1fb072b..820524b 100644
--- a/README.md
+++ b/README.md
@@ -1,24 +1,69 @@
-# Jellyfin app for YunoHost
-Jellyfin Server
+# Jellyfin for YunoHost
+
+[](https://dash.yunohost.org/appci/app/jellyfin)  
+[](https://install-app.yunohost.org/?app=jellyfin)
+
+> *This package allows you to install REPLACEBYYOURAPP quickly and simply on a YunoHost server.
+If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
+
+## Overview
+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.6.4
-- [Yunohost project](https://yunohost.org)
-- [Jellyfin website](https://github.com/jellyfin/jellyfin)
+## Screenshots
-
+
+## Demo
-[](https://install-app.yunohost.org/?app=jellyfin)
+* [Official demo](Link to a demo site for this app.)
+## Configuration
-### Installing guide
+How to configure this app: From an admin panel, a plain file with SSH, or any other way.
- App can be installed by YunoHost **admin web-interface** or by **running following command**:
+## Documentation
- $ sudo yunohost app install https://github.com/YunoHost-Apps/jellyfin_ynh
+ * Official documentation: Link to the official documentation of this app
+ * YunoHost documentation: If specific documentation is needed, feel free to contribute.
-
-### Upgrade this package:
+## YunoHost specific features
- $ sudo yunohost app upgrade jellyfin -u https://github.com/YunoHost-Apps/jellyfin_ynh
+#### Multi-user support
+
+ * Are LDAP and HTTP auth supported? **No**
+ * Can the app be used by multiple users? **Yes**
+
+#### Supported architectures
+
+* x86-64 - [](https://ci-apps.yunohost.org/ci/apps/jellyfin/)
+* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/jellyfin/)
+
+## Limitations
+
+* Any known limitations.
+
+## Additional information
+
+* Other info you would like to add about this app.
+
+## Links
+
+ * Report a bug: https://github.com/YunoHost-Apps/jellyfin_ynh/issues
+ * App website: https://jellyfin.org/
+ * Upstream app repository: https://github.com/jellyfin/jellyfin
+ * YunoHost website: https://yunohost.org/
+
+---
+
+## Developer info
+
+Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/jellyfin_ynh/tree/testing).
+
+To try the testing branch, please proceed like that.
+```
+sudo yunohost app install https://github.com/YunoHost-Apps/jellyfin_ynh/tree/testing --debug
+or
+sudo yunohost app upgrade jellyfin -u https://github.com/YunoHost-Apps/jellyfin_ynh/tree/testing --debug
+```
diff --git a/check_process b/check_process
index 0cbeae3..9263eba 100644
--- a/check_process
+++ b/check_process
@@ -1,4 +1,4 @@
-# See here for more informations
+# See here for more information
# https://github.com/YunoHost/package_check#syntax-check_process-file
# Move this file from check_process.default to check_process when you have filled it.
@@ -6,37 +6,35 @@
;; Test complet
; Manifest
domain="domain.tld" (DOMAIN)
- path="/" (PATH)
+ path="/path" (PATH)
+ admin="john" (USER)
+# language="fr"
is_public=1 (PUBLIC|public=1|private=0)
# password="pass"
-# nextclouddomain="domain.tld"
- port="9980" (PORT)
+ port="666" (PORT)
; Checks
pkg_linter=1
- setup_sub_dir=0
+ setup_sub_dir=1
setup_root=1
setup_nourl=0
- setup_private=0
+ setup_private=1
setup_public=1
upgrade=1
+ upgrade=1 from_commit=3e38d2ec954f6b333c3c2ed95e0e75c0df2fe966
backup_restore=1
- multi_instance=1
- incorrect_path=1
+ multi_instance=0
+ # This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version.
+ # incorrect_path=1
port_already_use=0
- change_url=0
+ change_url=1
;;; Levels
- Level 1=auto
- Level 2=auto
- Level 3=auto
-# Level 4:
- Level 4=1 (This app supports the Nextcloud LDAP auth)
-# Level 5:
+ # If the level 5 (Package linter) is forced to 1. Please add justifications here.
Level 5=auto
- Level 6=auto
- Level 7=auto
- Level 8=0
- Level 9=0
- Level 10=0
;;; Options
Email=
Notification=none
+;;; Upgrade options
+ ; commit=3e38d2ec954f6b333c3c2ed95e0e75c0df2fe966
+ name=2020-09-07 commit
+# manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666&
+ manifest_arg=domain=DOMAIN&path=PATH&admin=USER&is_public=1&port=666&
diff --git a/conf/jellyfin-ffmpeg-amd64.src b/conf/jellyfin-ffmpeg-amd64.src
deleted file mode 100644
index da5090c..0000000
--- a/conf/jellyfin-ffmpeg-amd64.src
+++ /dev/null
@@ -1,7 +0,0 @@
-SOURCE_URL=https://github.com/jellyfin/jellyfin-ffmpeg/releases/download/v4.2.1-7/jellyfin-ffmpeg_4.2.1-7-stretch_amd64.deb
-SOURCE_SUM=04ed00a1121832fe7c32f78fe9cbbebb0a36ef37c9e2689a75b55efa31ec2b73d670ddcb613d01b14721f3db98e409eca208ee425f4853b343155f06906e6e08
-SOURCE_SUM_PRG=sha512sum
-SOURCE_FORMAT=deb
-SOURCE_IN_SUBDIR=false
-SOURCE_EXTRACT=false
-SOURCE_FILENAME=jellyfin-ffmpeg.deb
diff --git a/conf/jellyfin-ffmpeg-arm64.src b/conf/jellyfin-ffmpeg-arm64.src
deleted file mode 100644
index 0b25190..0000000
--- a/conf/jellyfin-ffmpeg-arm64.src
+++ /dev/null
@@ -1,7 +0,0 @@
-SOURCE_URL=https://github.com/YunoHost-Apps/jellyfin_ynh/releases/download/10.6.0/jellyfin-ffmpeg_4.3.1-1-stretch_arm64.deb
-SOURCE_SUM=17ca53a20ab0668f2d5762f0a183c6bcf192cc901e3223e670d7f5c9d7d0c6c7da432f0cdb2fe98108f84d4cb3ac775f84cf5816b8d43d2080a280dab8ba6c32
-SOURCE_SUM_PRG=sha512sum
-SOURCE_FORMAT=deb
-SOURCE_IN_SUBDIR=false
-SOURCE_EXTRACT=false
-SOURCE_FILENAME=jellyfin-ffmpeg.deb
diff --git a/conf/jellyfin-ffmpeg-armhf.src b/conf/jellyfin-ffmpeg-armhf.src
deleted file mode 100644
index d2d00a5..0000000
--- a/conf/jellyfin-ffmpeg-armhf.src
+++ /dev/null
@@ -1,7 +0,0 @@
-SOURCE_URL=https://repo.jellyfin.org/releases/server/debian/versions/jellyfin-ffmpeg/4.2.1-2/jellyfin-ffmpeg_4.2.1-2-stretch_armhf.deb
-SOURCE_SUM=a08a4e0db96e05e4382c5c9bba435d658ba4a8a368dba9c06e816bf7ce4bbeee01481aa92919aceaf1f0c1a337356c8c1e1136c8f5b04e05edbe1a9e883df88c
-SOURCE_SUM_PRG=sha512sum
-SOURCE_FORMAT=deb
-SOURCE_IN_SUBDIR=false
-SOURCE_EXTRACT=false
-SOURCE_FILENAME=jellyfin-ffmpeg.deb
diff --git a/conf/jellyfin-server-amd64.src b/conf/jellyfin-server-amd64.src
deleted file mode 100644
index 7c909a6..0000000
--- a/conf/jellyfin-server-amd64.src
+++ /dev/null
@@ -1,7 +0,0 @@
-SOURCE_URL=https://github.com/YunoHost-Apps/jellyfin_ynh/releases/download/10.6.4/jellyfin-server_10.6.4-1_amd64.deb
-SOURCE_SUM=0600b2f3434db5397f95ed560e9d28a3a69515c7039ccda1066c86ea5a3f6e8dbbc3ecc67584d58193535d009c6c8f66da06515b78cd50ae0c0061dd265f188d
-SOURCE_SUM_PRG=sha512sum
-SOURCE_FORMAT=deb
-SOURCE_IN_SUBDIR=false
-SOURCE_EXTRACT=false
-SOURCE_FILENAME=jellyfin-server.deb
diff --git a/conf/jellyfin-server-arm64.src b/conf/jellyfin-server-arm64.src
deleted file mode 100644
index 179d372..0000000
--- a/conf/jellyfin-server-arm64.src
+++ /dev/null
@@ -1,7 +0,0 @@
-SOURCE_URL=https://github.com/YunoHost-Apps/jellyfin_ynh/releases/download/10.6.4/jellyfin-server_10.6.4-1_arm64.deb
-SOURCE_SUM=cc3889a8ed6928f27fd09013db781007ffe73a04120101ce0d21d223ebae4f61cb2524723b9c54a04dbf8e421f60c0f89d43aaf4b97eec042d7f4e0ca76f3db4
-SOURCE_SUM_PRG=sha512sum
-SOURCE_FORMAT=deb
-SOURCE_IN_SUBDIR=false
-SOURCE_EXTRACT=false
-SOURCE_FILENAME=jellyfin-server.deb
diff --git a/conf/jellyfin-server-armhf.src b/conf/jellyfin-server-armhf.src
deleted file mode 100644
index 1c9df65..0000000
--- a/conf/jellyfin-server-armhf.src
+++ /dev/null
@@ -1,7 +0,0 @@
-SOURCE_URL=https://github.com/YunoHost-Apps/jellyfin_ynh/releases/download/10.6.4/jellyfin-server_10.6.4-1_armhf.deb
-SOURCE_SUM=ab3ca726582101094cfc3e770c5281aa7f64396bdf86ac8ae2ce7cfa7fcc30e3ec8f6b46c9852bdd51450722638c2846d584d21dc3ee9abd512b0101b44c514d
-SOURCE_SUM_PRG=sha512sum
-SOURCE_FORMAT=deb
-SOURCE_IN_SUBDIR=false
-SOURCE_EXTRACT=false
-SOURCE_FILENAME=jellyfin-server.deb
diff --git a/conf/jellyfin-web.src b/conf/jellyfin-web.src
deleted file mode 100644
index ea4b101..0000000
--- a/conf/jellyfin-web.src
+++ /dev/null
@@ -1,7 +0,0 @@
-SOURCE_URL=https://github.com/YunoHost-Apps/jellyfin_ynh/releases/download/10.6.4/jellyfin-web_10.6.4-1_all.deb
-SOURCE_SUM=834368480c942f32171967b0895972f75aa3d77c2a2fb131f67b81fd8dee438b8a00c48dd0901aa3e12d0fa369176e06f9a8662046086f43b94ff6c7ef41a591
-SOURCE_SUM_PRG=sha512sum
-SOURCE_FORMAT=deb
-SOURCE_IN_SUBDIR=false
-SOURCE_EXTRACT=false
-SOURCE_FILENAME=jellyfin-web.deb
diff --git a/conf/nginx.conf b/conf/nginx.conf
index 53e98bb..b1f2ab0 100644
--- a/conf/nginx.conf
+++ b/conf/nginx.conf
@@ -1,26 +1,21 @@
-########
-## Jellyfin
+#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
+location __PATH__/ {
- location /jellyfin {
- return 302 $scheme://$host/jellyfin/;
- }
-
- location __PATH__/ {
- # Proxy main Jellyfin traffic
- # The / at the end is significant.
- proxy_pass http://127.0.0.1:__PORT____PATH__/;
- proxy_pass_request_headers on;
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_set_header X-Forwarded-Proto $scheme;
- proxy_set_header X-Forwarded-Host $http_host;
-
- proxy_set_header Upgrade $http_upgrade;
- proxy_set_header Connection $http_connection;
-
# Force usage of https
if ($scheme = http) {
- rewrite ^ https://$server_name$request_uri? permanent;
+ rewrite ^ https://$server_name$request_uri? permanent;
}
+
+ proxy_pass http://127.0.0.1:__PORT____PATH__/;
+ proxy_pass_request_headers on;
+ proxy_set_header Host $host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header X-Forwarded-Proto $scheme;
+ proxy_set_header X-Forwarded-Host $http_host;
+ proxy_set_header Upgrade $http_upgrade;
+ proxy_set_header Connection $http_connection;
+
+ # Include SSOWAT user panel.
+ include conf.d/yunohost_panel.conf.inc;
}
diff --git a/manifest.json b/manifest.json
index bf09819..1292ae0 100644
--- a/manifest.json
+++ b/manifest.json
@@ -3,18 +3,18 @@
"id": "jellyfin",
"packaging_format": 1,
"description": {
- "en": "The free software media system that puts you in control of managing and streaming your media.",
- "fr": "Le système multimédia libre qui vous donne le contrôle pour gérer et diffuser vos médias."
+ "en": "Media System that manage and stream your media.",
+ "fr": "Système multimédia qui gère et diffuse vos médias."
},
- "version": "10.6.4",
+ "version": "10.6.4~ynh1",
"url": "https://github.com/jellyfin/jellyfin",
- "license": "GPL-2.0",
+ "license": "GPL-2.0-only",
"maintainer": {
"name": "liberodark",
"email": "liberodark@gmail.com"
},
"requirements": {
- "yunohost": ">= 2.7.2"
+ "yunohost": ">= 3.8.1"
},
"multi_instance": false,
"services": [
@@ -30,26 +30,28 @@
},
"example": "example.com"
},
-
{
"name": "path",
"type": "path",
"ask": {
- "en": "Choose a path for Jellyfin /jellyfin is accepted",
- "fr": "Choisissez un chemin pour Jellyfin /jellyfin est accepté"
+ "en": "Choose a path for Jellyfin",
+ "fr": "Choisissez un chemin pour Jellyfin"
},
"example": "/jellyfin",
"default": "/jellyfin"
},
-
{
"name": "is_public",
"type": "boolean",
"ask": {
- "en": "Is it a public site ?",
- "fr": "Est-ce un site public ?"
+ "en": "Is it a public application?",
+ "fr": "Est-ce une application publique ?"
},
- "default": "true"
+ "default": true,
+ "help": {
+ "en": "Jellyfin has its own login system, you should make it public to let external clients access it (mobile app, etc.).",
+ "fr": "Jellyfin a son propre système de connexion, vous devriez la laisser publique pour permettre la connexion de clients externes (app mobile, etc.)."
+ }
}
]
}
diff --git a/scripts/_common.sh b/scripts/_common.sh
index 0f53f77..0e17ea6 100644
--- a/scripts/_common.sh
+++ b/scripts/_common.sh
@@ -1,112 +1,19 @@
#!/bin/bash
-# =============================================================================
-# YUNOHOST 2.7 FORTHCOMING HELPERS
-# =============================================================================
+#=================================================
+# COMMON VARIABLES
+#=================================================
-# Create a dedicated nginx config
-#
-# usage: ynh_add_nginx_config
-ynh_add_nginx_config () {
- finalnginxconf="/etc/nginx/conf.d/$domain.d/$app.conf"
- ynh_backup_if_checksum_is_different "$finalnginxconf"
- sudo cp ../conf/nginx.conf "$finalnginxconf"
+pkg_version="10.6.4-1"
- # To avoid a break by set -u, use a void substitution ${var:-}. If the variable is not set, it's simply set with an empty variable.
- # Substitute in a nginx config file only if the variable is not empty
- if test -n "${path_url:-}"; then
- ynh_replace_string "__PATH__" "$path_url" "$finalnginxconf"
- fi
- if test -n "${domain:-}"; then
- ynh_replace_string "__DOMAIN__" "$domain" "$finalnginxconf"
- fi
- if test -n "${port:-}"; then
- ynh_replace_string "__PORT__" "$port" "$finalnginxconf"
- fi
- if test -n "${app:-}"; then
- ynh_replace_string "__NAME__" "$app" "$finalnginxconf"
- fi
- if test -n "${final_path:-}"; then
- ynh_replace_string "__FINALPATH__" "$final_path" "$finalnginxconf"
- fi
- ynh_store_file_checksum "$finalnginxconf"
+#=================================================
+# PERSONAL HELPERS
+#=================================================
- sudo systemctl reload nginx
-}
+#=================================================
+# EXPERIMENTAL HELPERS
+#=================================================
-# Remove the dedicated nginx config
-#
-# usage: ynh_remove_nginx_config
-ynh_remove_nginx_config () {
- ynh_secure_remove "/etc/nginx/conf.d/$domain.d/$app.conf"
- sudo systemctl reload nginx
-}
-
-# Create a dedicated php-fpm config
-#
-# usage: ynh_add_fpm_config
-ynh_add_fpm_config () {
- finalphpconf="/etc/php5/fpm/pool.d/$app.conf"
- ynh_backup_if_checksum_is_different "$finalphpconf"
- sudo cp ../conf/php-fpm.conf "$finalphpconf"
- ynh_replace_string "__NAMETOCHANGE__" "$app" "$finalphpconf"
- ynh_replace_string "__FINALPATH__" "$final_path" "$finalphpconf"
- ynh_replace_string "__USER__" "$app" "$finalphpconf"
- sudo chown root: "$finalphpconf"
- ynh_store_file_checksum "$finalphpconf"
-
- if [ -e "../conf/php-fpm.ini" ]
- then
- finalphpini="/etc/php5/fpm/conf.d/20-$app.ini"
- ynh_backup_if_checksum_is_different "$finalphpini"
- sudo cp ../conf/php-fpm.ini "$finalphpini"
- sudo chown root: "$finalphpini"
- ynh_store_file_checksum "$finalphpini"
- fi
-
- sudo systemctl reload php5-fpm
-}
-
-# Remove the dedicated php-fpm config
-#
-# usage: ynh_remove_fpm_config
-ynh_remove_fpm_config () {
- ynh_secure_remove "/etc/php5/fpm/pool.d/$app.conf"
- ynh_secure_remove "/etc/php5/fpm/conf.d/20-$app.ini" 2>&1
- sudo systemctl reload php5-fpm
-}
-
-# Create a dedicated systemd config
-#
-# usage: ynh_add_systemd_config
-ynh_add_systemd_config () {
- finalsystemdconf="/etc/systemd/system/$app.service"
- ynh_backup_if_checksum_is_different "$finalsystemdconf"
- sudo cp ../conf/systemd.service "$finalsystemdconf"
-
- # To avoid a break by set -u, use a void substitution ${var:-}. If the variable is not set, it's simply set with an empty variable.
- # Substitute in a nginx config file only if the variable is not empty
- if test -n "${final_path:-}"; then
- ynh_replace_string "__FINALPATH__" "$final_path" "$finalsystemdconf"
- fi
- if test -n "${app:-}"; then
- ynh_replace_string "__APP__" "$app" "$finalsystemdconf"
- fi
- ynh_store_file_checksum "$finalsystemdconf"
-
- sudo chown root: "$finalsystemdconf"
- sudo systemctl enable $app
- sudo systemctl daemon-reload
-}
-
-# Remove the dedicated systemd config
-#
-# usage: ynh_remove_systemd_config
-ynh_remove_systemd_config () {
- finalsystemdconf="/etc/systemd/system/$app.service"
- if [ -e "$finalsystemdconf" ]; then
- sudo systemctl stop $app
- sudo systemctl disable $app
- ynh_secure_remove "$finalsystemdconf"
- fi
-}
+#=================================================
+# FUTURE OFFICIAL HELPERS
+#=================================================
diff --git a/scripts/backup b/scripts/backup
index 13ce93d..2b24fb0 100644
--- a/scripts/backup
+++ b/scripts/backup
@@ -24,7 +24,7 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
-ynh_script_progression --message="Loading installation settings..." --time --weight=1
+ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
@@ -32,46 +32,40 @@ final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
domain=$(ynh_app_setting_get --app="$app" --key=domain)
#=================================================
-# STANDARD BACKUP STEPS
+# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
-# STOP SYSTEMD SERVICE
-#=================================================
-ynh_script_progression --message="Stopping a systemd service..." --time --weight=1
-
-ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log"
+ynh_print_info --message="Declaring files to be backed up..."
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
-ynh_script_progression --message="Backing up the main app directory..." --time --weight=1
ynh_backup --src_path="$final_path"
+ynh_backup --src_path="/var/lib/jellyfin"
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
-ynh_script_progression --message="Backing up nginx web server configuration..." --time --weight=1
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# SPECIFIC BACKUP
+#=================================================
+# BACKUP LOGROTATE
+#=================================================
+
+ynh_backup --src_path="/etc/logrotate.d/$app"
+
#=================================================
# BACKUP SYSTEMD
#=================================================
-ynh_script_progression --message="Backing up systemd configuration..." --time --weight=1
-ynh_backup --src_path="/etc/systemd/system/$app.service"
-
-#=================================================
-# START SYSTEMD SERVICE
-#=================================================
-ynh_script_progression --message="Starting a systemd service..." --time --weight=1
-
-ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
+ynh_backup --src_path="/lib/systemd/system/jellyfin.service"
+ynh_backup --src_path="/etc/systemd/system/jellyfin.service.d"
#=================================================
# END OF SCRIPT
#=================================================
-ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --time --last
+ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
diff --git a/scripts/change_url b/scripts/change_url
new file mode 100644
index 0000000..03e8e62
--- /dev/null
+++ b/scripts/change_url
@@ -0,0 +1,142 @@
+#!/bin/bash
+
+#=================================================
+# GENERIC STARTING
+#=================================================
+# IMPORT GENERIC HELPERS
+#=================================================
+
+source _common.sh
+source /usr/share/yunohost/helpers
+
+#=================================================
+# RETRIEVE ARGUMENTS
+#=================================================
+
+old_domain=$YNH_APP_OLD_DOMAIN
+old_path=$YNH_APP_OLD_PATH
+
+new_domain=$YNH_APP_NEW_DOMAIN
+new_path=$YNH_APP_NEW_PATH
+
+app=$YNH_APP_INSTANCE_NAME
+
+port=$(ynh_app_setting_get --app="$app" --key=port)
+
+#=================================================
+# LOAD SETTINGS
+#=================================================
+ynh_script_progression --message="Loading installation settings..." --weight=1
+
+# Needed for helper "ynh_add_nginx_config"
+final_path=$(ynh_app_setting_get --app=$app --key=final_path)
+
+#=================================================
+# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
+#=================================================
+ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=10
+
+# Backup the current version of the app
+ynh_backup_before_upgrade
+ynh_clean_setup () {
+ # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
+ ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
+
+ # restore it if the upgrade fails
+ ynh_restore_upgradebackup
+}
+# Exit if an error occurs during the execution of the script
+ynh_abort_if_errors
+
+#=================================================
+# CHECK WHICH PARTS SHOULD BE CHANGED
+#=================================================
+
+change_domain=0
+if [ "$old_domain" != "$new_domain" ]
+then
+ change_domain=1
+fi
+
+change_path=0
+if [ "$old_path" != "$new_path" ]
+then
+ change_path=1
+fi
+
+#=================================================
+# STANDARD MODIFICATIONS
+#=================================================
+# STOP SYSTEMD SERVICE
+#=================================================
+ynh_script_progression --message="Stopping a systemd service..." --weight=2
+
+ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
+
+#=================================================
+# MODIFY URL IN NGINX CONF
+#=================================================
+ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
+
+nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
+
+# Change the path in the NGINX config file
+if [ $change_path -eq 1 ]
+then
+ # Make a backup of the original NGINX config file if modified
+ ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
+ # Set global variables for NGINX helper
+ domain="$old_domain"
+ path_url="$new_path"
+ # Create a dedicated NGINX config
+ ynh_add_nginx_config
+fi
+
+# Change the domain for NGINX
+if [ $change_domain -eq 1 ]
+then
+ # Delete file checksum for the old conf file location
+ ynh_delete_file_checksum --file="$nginx_conf_path"
+ mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
+ # Store file checksum for the new config file location
+ ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
+fi
+
+#=================================================
+# SPECIFIC MODIFICATIONS
+#=================================================
+# BASE URL
+#=================================================
+
+# Change the path in system.xml config file
+if [ $change_path -eq 1 ]
+then
+ # If somehow was not replaced during install
+ if grep -q "" "/etc/jellyfin/system.xml"; then
+ ynh_replace_string --match_string="" --replace_string="$new_path" --target_file="/etc/jellyfin/system.xml"
+ else
+ ynh_replace_string --match_string="$old_path" --replace_string="$new_path" --target_file="/etc/jellyfin/system.xml"
+ fi
+fi
+
+#=================================================
+# GENERIC FINALISATION
+#=================================================
+# START SYSTEMD SERVICE
+#=================================================
+ynh_script_progression --message="Starting a systemd service..." --weight=2
+
+ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Startup complete"
+
+#=================================================
+# RELOAD NGINX
+#=================================================
+ynh_script_progression --message="Reloading NGINX web server..." --weight=1
+
+ynh_systemd_action --service_name=nginx --action=reload
+
+#=================================================
+# END OF SCRIPT
+#=================================================
+
+ynh_script_progression --message="Change of URL completed for $app" --last
diff --git a/scripts/install b/scripts/install
index 56a164c..82a5492 100644
--- a/scripts/install
+++ b/scripts/install
@@ -15,7 +15,7 @@ source /usr/share/yunohost/helpers
ynh_clean_setup () {
### Remove this function if there's nothing to clean before calling the remove script.
- true
+ ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
@@ -24,130 +24,67 @@ ynh_abort_if_errors
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
-# Retrieve arguments
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC
-### If it's a multi-instance app, meaning it can be installed several times independently
-### The id of the app as stated in the manifest is available as $YNH_APP_ID
-### The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
-### The app instance name is available as $YNH_APP_INSTANCE_NAME
-### - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
-### - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
-### - ynhexample__{N} for the subsequent installations, with N=3,4, ...
-### The app instance name is probably what interests you most, since this is
-### guaranteed to be unique. This is a good unique identifier to define installation path,
-### db names, ...
app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
+ynh_script_progression --message="Validating installation parameters..." --weight=1
-### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app".
-### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app"
-final_path=/opt/yunohost/$app
-test ! -e "$final_path" || ynh_die "This path already contains a folder"
+final_path=/etc/jellyfin
+test ! -e "$final_path" || ynh_die --message="There is already a directory: $final_path "
+test ! -e "/var/lib/jellyfin" || ynh_die --message="There is already a directory: /var/lib/jellyfin "
-# Normalize the url path syntax
-path_url=$(ynh_normalize_url_path "$path_url")
-
-# Check web path availability
-ynh_webpath_available "$domain" "$path_url"
# Register (book) web path
-ynh_webpath_register "$app" "$domain" "$path_url"
+ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
+ynh_script_progression --message="Storing installation settings..." --weight=2
-ynh_app_setting_set "$app" domain "$domain"
-ynh_app_setting_set "$app" path "$path_url"
-ynh_app_setting_set "$app" is_public "$is_public"
+ynh_app_setting_set --app=$app --key=domain --value=$domain
+ynh_app_setting_set --app=$app --key=path --value=$path_url
+ynh_app_setting_set --app=$app --key=final_path --value=$final_path
+ynh_app_setting_set --app=$app --key=is_public --value=$is_public
+
+#=================================================
+# STANDARD MODIFICATIONS
+#=================================================
+# FIND AND OPEN A PORT
+#=================================================
+ynh_script_progression --message="Configuring firewall..." --weight=1
+
+# Find an available port
+port=$(ynh_find_port --port=8095)
+ynh_app_setting_set --app=$app --key=port --value=$port
#=================================================
# INSTALL DEPENDENCIES
#=================================================
+ynh_script_progression --message="Installing dependencies..." --weight=1
-ynh_print_info "Installing dependencies..."
-
-### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package.
-### Those deb packages will be installed as dependencies of this package.
-### If you're not using this helper:
-### - Remove the section "REMOVE DEPENDENCIES" in the remove script
-### - As well as the section "REINSTALL DEPENDENCIES" in the restore script
-### - And the section "UPGRADE DEPENDENCIES" in the upgrade script
-
-ynh_install_app_dependencies at libass5 libbluray1 libdrm2 libmp3lame0 libopus0 libtheora0 libva-drm1 libva-x11-1 libva1 libvdpau1 libvorbis0a libvorbisenc2 libx264-148 libx265-95 libzvbi0 libwebpmux2
-
-#=================================================
-# FIND AND OPEN A PORT
-#=================================================
-
-### Use these lines if you have to open a port for the application
-### `ynh_find_port` will find the first available port starting from the given port.
-### If you're not using these lines:
-### - Remove the section "CLOSE A PORT" in the remove script
-
-# Find a free port
-port=$(ynh_find_port 8096)
-# Open this port
-yunohost firewall allow --no-upnp TCP "$port" 2>&1
-ynh_app_setting_set "$app" port "$port"
-
-#=================================================
-# DOWNLOAD, CHECK AND UNPACK SOURCE
-#=================================================
-
-ynh_app_setting_set "$app" final_path "$final_path"
-
-# Download, check integrity, uncompress and patch the source from jellyfin-ffmpeg-[arch].src
-case $(uname -m) in
- x86_64) ynh_setup_source "$final_path" "jellyfin-ffmpeg-amd64" ;;
- aarch64) ynh_setup_source "$final_path" "jellyfin-ffmpeg-arm64" ;;
- armv7l) ynh_setup_source "$final_path" "jellyfin-ffmpeg-armhf" ;;
- *) ynh_die "Unknown arch" ;;
-esac
-
-# Download, check integrity, uncompress and patch the source from jellyfin-server-[arch].src
-case $(uname -m) in
- x86_64) ynh_setup_source "$final_path" "jellyfin-server-amd64" ;;
- aarch64) ynh_setup_source "$final_path" "jellyfin-server-arm64" ;;
- armv7l) ynh_setup_source "$final_path" "jellyfin-server-armhf" ;;
- *) ynh_die "Unknown arch" ;;
-esac
-
-# Download, check integrity, uncompress and patch the source from jellyfin-web.src
-case $(uname -m) in
- x86_64) ynh_setup_source "$final_path" "jellyfin-web" ;;
- aarch64) ynh_setup_source "$final_path" "jellyfin-web" ;;
- armv7l) ynh_setup_source "$final_path" "jellyfin-web" ;;
- *) ynh_die "Unknown arch" ;;
-esac
-
-#==============================================
-# INSTALL JELLYFIN
-#==============================================
-
-dpkg --install "$final_path"/jellyfin-ffmpeg.deb
-dpkg --install "$final_path"/jellyfin-server.deb
-dpkg --install "$final_path"/jellyfin-web.deb
-rm "$final_path"/*.deb
+ynh_install_extra_app_dependencies --repo="https://repo.jellyfin.org/$( awk -F'=' '/^ID=/{ print $NF }' /etc/os-release ) $( awk -F'=' '/^VERSION_CODENAME=/{ print $NF }' /etc/os-release ) main" --key="https://repo.jellyfin.org/jellyfin_team.gpg.key" --package="jellyfin=$pkg_version"
#=================================================
# NGINX CONFIGURATION
#=================================================
+ynh_script_progression --message="Configuring NGINX web server..." --weight=6
-# Create a dedicated nginx config
+# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
+ynh_script_progression --message="Configuring system user..." --weight=2
# Create a system user
-ynh_system_user_create "$app"
+ynh_system_user_create --username=$app
#=================================================
# MODIFY A CONFIG FILE
@@ -162,46 +99,64 @@ systemctl stop jellyfin
# Port config
ynh_replace_string --match_string="8096" --replace_string="$port" --target_file="/etc/jellyfin/system.xml"
-# BaseUrl
+# BaseUrl config
ynh_replace_string --match_string="" --replace_string="$path_url" --target_file="/etc/jellyfin/system.xml"
-# Port config
-ynh_replace_string --match_string="8096" --replace_string="$port" --target_file="/etc/jellyfin/system.xml"
-
-#=================================================
-# STORE THE CONFIG FILE CHECKSUM
-#=================================================
-
-### `ynh_store_file_checksum` is used to store the checksum of a file.
-### That way, during the upgrade script, by using `ynh_backup_if_checksum_is_different`,
-### you can make a backup of this file before modifying it again if the admin had modified it.
-
-# Calculate and store the config file checksum into the app settings
-#ynh_store_file_checksum "$plugins_conf_file"
-
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
-### For security reason, any app should set the permissions to root: before anything else.
-### Then, if write authorization is needed, any access should be given only to directories
-### that really need such authorization.
-
# Set permissions to app files
-#chown -R root: /etc/loolwsd
+chown -R $app: $final_path
+chown -R $app: /var/lib/jellyfin
+
+#=================================================
+# SETUP LOGROTATE
+#=================================================
+ynh_script_progression --message="Configuring log rotation..." --weight=2
+
+# Use logrotate to manage application logfile(s)
+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" --log "/var/log/$app/$app.log"
+
+#=================================================
+# START SYSTEMD SERVICE
+#=================================================
+ynh_script_progression --message="Starting a systemd service..." --weight=1
+
+# Start a systemd service
+ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Startup complete"
#=================================================
# SETUP SSOWAT
#=================================================
+ynh_script_progression --message="Configuring SSOwat..." --weight=2
-# If app is public, add url to SSOWat conf as skipped_uris
-if [ "$is_public" -eq 1 ]; then
- # unprotected_uris allows SSO credentials to be passed anyway.
- ynh_app_setting_set "$app" unprotected_uris "/"
+# Make app public if necessary or protect it
+if [ $is_public -eq 1 ]
+then
+ # Everyone can access the app.
+ # The "main" permission is automatically created before the install script.
+ ynh_permission_update --permission "main" --add "visitors"
fi
-# Reload services
-systemctl start jellyfin
-systemctl reload nginx
+#=================================================
+# RELOAD NGINX
+#=================================================
+ynh_script_progression --message="Reloading NGINX web server..." --weight=2
+
+ynh_systemd_action --service_name=nginx --action=reload
+
+#=================================================
+# END OF SCRIPT
+#=================================================
+
+ynh_script_progression --message="Installation of $app completed" --last
diff --git a/scripts/remove b/scripts/remove
index 6a482b9..2fefac4 100644
--- a/scripts/remove
+++ b/scripts/remove
@@ -12,31 +12,31 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
-ynh_print_info "Loading installation settings..."
+ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
-domain=$(ynh_app_setting_get "$app" domain)
-port=$(ynh_app_setting_get "$app" port)
-final_path=$(ynh_app_setting_get "$app" final_path)
+domain=$(ynh_app_setting_get --app=$app --key=domain)
+port=$(ynh_app_setting_get --app=$app --key=port)
+final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# STANDARD REMOVE
#=================================================
-# REMOVE SERVICE FROM ADMIN PANEL
+# REMOVE SERVICE INTEGRATION IN YUNOHOST
#=================================================
-# Remove a service from the admin panel, added by `yunohost service add`
-if yunohost service status "$app" >/dev/null 2>&1
+# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
+if ynh_exec_warn_less yunohost service status $app >/dev/null
then
- ynh_print_info "Removing $app service"
- yunohost service remove "$app"
+ ynh_script_progression --message="Removing $app service integration..." --weight=3
+ yunohost service remove $app
fi
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
-ynh_print_info "Stopping and removing the systemd service"
+ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
# Remove the dedicated systemd config
ynh_remove_systemd_config
@@ -44,74 +44,41 @@ ynh_remove_systemd_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
-ynh_print_info "Removing dependencies"
+ynh_script_progression --message="Removing dependencies..." --weight=1
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
-apt-get remove -y jellyfin-web jellyfin-server jellyfin-ffmpeg
+
#=================================================
# REMOVE APP MAIN DIR
#=================================================
-ynh_print_info "Removing app main directory"
+ynh_script_progression --message="Removing app main directory..." --weight=12
# Remove the app directory securely
-ynh_secure_remove "$final_path"
-ynh_secure_remove "/etc/jellyfin"
-ynh_secure_remove "/var/lib/jellyfin"
+ynh_secure_remove --file="$final_path"
+ynh_secure_remove --file="/etc/jellyfin"
+ynh_secure_remove --file="/var/lib/jellyfin"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
-ynh_print_info "Removing nginx web server configuration"
+ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
# Remove the dedicated nginx config
ynh_remove_nginx_config
-#=================================================
-# REMOVE LOGROTATE CONFIGURATION
-#=================================================
-ynh_print_info "Removing logrotate configuration"
-
-# Remove the app-specific logrotate config
-ynh_remove_logrotate
-
-#=================================================
-# CLOSE A PORT
-#=================================================
-
-if yunohost firewall list | grep -q "\- $port$"
-then
- ynh_print_info "Closing port $port"
- ynh_exec_warn_less yunohost firewall disallow TCP "$port"
-fi
-
-#=================================================
-# SPECIFIC REMOVE
-#=================================================
-# REMOVE THE CRON FILE
-#=================================================
-
-# Remove a cron file
-ynh_secure_remove "/etc/cron.d/$app"
-
-# Remove a directory securely
-ynh_secure_remove "/etc/$app/"
-
-# Remove the log files
-ynh_secure_remove "/var/log/$app/"
-
#=================================================
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
-ynh_print_info "Removing the dedicated system user"
+ynh_script_progression --message="Removing the dedicated system user..." --weight=2
# Delete a system user
-ynh_system_user_delete "$app"
+ynh_system_user_delete --username=$app
#=================================================
# END OF SCRIPT
#=================================================
-ynh_print_info "Removal of $app completed"
+ynh_script_progression --message="Removal of $app completed" --last
diff --git a/scripts/restore b/scripts/restore
index 824ea41..9f061d1 100644
--- a/scripts/restore
+++ b/scripts/restore
@@ -16,7 +16,7 @@ source /usr/share/yunohost/helpers
ynh_clean_setup () {
#### Remove this function if there's nothing to clean before calling the remove script.
- true
+ ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
@@ -24,7 +24,7 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
-ynh_script_progression --message="Loading settings..." --time --weight=1
+ynh_script_progression --message="Loading settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
@@ -35,12 +35,14 @@ final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
-ynh_script_progression --message="Validating restoration parameters..." --time --weight=1
+ynh_script_progression --message="Validating restoration parameters..." --weight=2
ynh_webpath_available --domain="$domain" --path_url="$path_url" \
|| ynh_die --message="Path not available: ${domain}${path_url}"
test ! -d "$final_path" \
|| ynh_die --message="There is already a directory: $final_path "
+test ! -d "/var/lib/jellyfin" \
+ || ynh_die --message="There is already a directory: /var/lib/jellyfin "
#=================================================
# STANDARD RESTORATION STEPS
@@ -53,14 +55,15 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
-ynh_script_progression --message="Restoring the app main directory..." --time --weight=1
+ynh_script_progression --message="Restoring the app main directory..." --weight=2
ynh_restore_file --origin_path="$final_path"
+ynh_restore_file --origin_path="/var/lib/jellyfin"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
-ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1
+ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing)
ynh_system_user_create --username="$app"
@@ -70,38 +73,54 @@ ynh_system_user_create --username="$app"
#=================================================
# Restore permissions on app files
-#chown -R root: $final_path
-chown -R jellyfin:jellyfin "$plugins_path"
+chown -R $app: $final_path
+chown -R $app: /var/lib/jellyfin
#=================================================
# SPECIFIC RESTORATION
+#=================================================
+# REINSTALL DEPENDENCIES
+#=================================================
+ynh_script_progression --message="Reinstalling dependencies..." --weight=7
+
+# Define and install dependencies
+ynh_install_extra_app_dependencies --repo="https://repo.jellyfin.org/debian $( lsb_release -c -s ) main" --package="jellyfin" --key="https://repo.jellyfin.org/debian/jellyfin_team.gpg.key"
+
#=================================================
# RESTORE SYSTEMD
#=================================================
-ynh_script_progression --message="Restoring the systemd configuration..." --time --weight=1
+ynh_script_progression --message="Restoring the systemd configuration..." --weight=2
-ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
-systemctl enable "$app".service
+ynh_restore_file --origin_path="/lib/systemd/system/jellyfin.service" 2>/dev/null
+ynh_restore_file --origin_path="/etc/systemd/system/jellyfin.service.d" 2>/dev/null
+systemctl enable $app.service
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
+ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
-yunohost service add "$app" --description "Jellyfin media system" --log "/var/log/$app/$app.log"
+yunohost service add $app --description "Jellyfin media center" --log "/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
-ynh_script_progression --message="Starting a systemd service..." --time --weight=1
+ynh_script_progression --message="Starting a systemd service..." --weight=1
-ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log"
+ynh_systemd_action --service_name=$app --action="restart" --log_path="systemd" --line_match="Startup complete"
+
+#=================================================
+# RESTORE THE LOGROTATE CONFIGURATION
+#=================================================
+
+ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
-ynh_script_progression --message="Reloading nginx web server and php-fpm..." --time --weight=1
+ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
@@ -109,4 +128,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT
#=================================================
-ynh_script_progression --message="Restoration completed for $app" --time --last
+ynh_script_progression --message="Restoration completed for $app" --last
diff --git a/scripts/upgrade b/scripts/upgrade
index 807c15a..01d1fc4 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -1,77 +1,119 @@
#!/bin/bash
-# Exit on command errors and treat unset variables as an error
-set -eu
+#=================================================
+# GENERIC START
+#=================================================
+# IMPORT GENERIC HELPERS
+#=================================================
-# See comments in install script
-app=$YNH_APP_INSTANCE_NAME
-final_path=/opt/yunohost/$app
-
-# Source YunoHost helpers
+source _common.sh
source /usr/share/yunohost/helpers
-# Stop jellyfin service
-systemctl stop jellyfin
+#=================================================
+# LOAD SETTINGS
+#=================================================
+ynh_script_progression --message="Loading installation settings..." --weight=1
+
+app=$YNH_APP_INSTANCE_NAME
+domain=$(ynh_app_setting_get --app=$app --key=domain)
+path_url=$(ynh_app_setting_get --app=$app --key=path)
+is_public=$(ynh_app_setting_get --app=$app --key=is_public)
+final_path=$(ynh_app_setting_get --app=$app --key=final_path)
+port=$(ynh_app_setting_get --app=$app --key=port)
#=================================================
-# DOWNLOAD, CHECK AND UNPACK SOURCE
+# CHECK VERSION
#=================================================
-ynh_app_setting_set "$app" final_path "$final_path"
+upgrade_type=$(ynh_check_app_version_changed)
-# Download, check integrity, uncompress and patch the source from jellyfin-ffmpeg-[arch].src
-case $(uname -m) in
- x86_64) ynh_setup_source "$final_path" "jellyfin-ffmpeg-amd64" ;;
- aarch64) ynh_setup_source "$final_path" "jellyfin-ffmpeg-arm64" ;;
- armv7l) ynh_setup_source "$final_path" "jellyfin-ffmpeg-armhf" ;;
- *) ynh_die "Unknown arch" ;;
-esac
+#=================================================
+# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
+#=================================================
+ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=3
-# Download, check integrity, uncompress and patch the source from jellyfin-server-[arch].src
-case $(uname -m) in
- x86_64) ynh_setup_source "$final_path" "jellyfin-server-amd64" ;;
- aarch64) ynh_setup_source "$final_path" "jellyfin-server-arm64" ;;
- armv7l) ynh_setup_source "$final_path" "jellyfin-server-armhf" ;;
- *) ynh_die "Unknown arch" ;;
-esac
+# Backup the current version of the app
+ynh_backup_before_upgrade
+ynh_clean_setup () {
+ # restore it if the upgrade fails
+ ynh_restore_upgradebackup
+}
+# Exit if an error occurs during the execution of the script
+ynh_abort_if_errors
-# Download, check integrity, uncompress and patch the source from jellyfin-web.src
-case $(uname -m) in
- x86_64) ynh_setup_source "$final_path" "jellyfin-web" ;;
- aarch64) ynh_setup_source "$final_path" "jellyfin-web" ;;
- armv7l) ynh_setup_source "$final_path" "jellyfin-web" ;;
- *) ynh_die "Unknown arch" ;;
-esac
+#=================================================
+# STANDARD UPGRADE STEPS
+#=================================================
+# STOP SYSTEMD SERVICE
+#=================================================
+ynh_script_progression --message="Stopping a systemd service..." --weight=1
-#==============================================
-# INSTALL JELLYFIN
-#==============================================
-
-dpkg --install "$final_path"/jellyfin-ffmpeg.deb
-dpkg --install "$final_path"/jellyfin-server.deb
-dpkg --install "$final_path"/jellyfin-web.deb
-rm "$final_path"/*.deb
+ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
#=================================================
# NGINX CONFIGURATION
#=================================================
+ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
-# Create a dedicated nginx config
-#ynh_add_nginx_config
+# Create a dedicated NGINX config
+ynh_add_nginx_config
#=================================================
-# UPGRADE CONFIG
+# UPGRADE DEPENDENCIES
#=================================================
-#cp -a ../conf/loolwsd.xml /etc/loolwsd
-#ynh_replace_string "__NEXTCLOUDDOMAIN__" "$nextcloud_domain" "/etc/loolwsd/loolwsd.xml"
-#ynh_replace_string "__PASSWORD__" "$password" "/etc/loolwsd/loolwsd.xml"
-#systemctl restart loolwsd
+ynh_script_progression --message="Upgrading dependencies..." --weight=3
-# If app is public, add url to SSOWat conf as skipped_uris
-#if [[ $is_public -eq 1 ]]; then
- # See install script
-# ynh_app_setting_set "$app" unprotected_uris "/"
-#fi
+ynh_install_extra_app_dependencies --repo="https://repo.jellyfin.org/$( awk -F'=' '/^ID=/{ print $NF }' /etc/os-release ) $( awk -F'=' '/^VERSION_CODENAME=/{ print $NF }' /etc/os-release ) main" --key="https://repo.jellyfin.org/jellyfin_team.gpg.key" --package="jellyfin=$pkg_version"
-# Start jellyfin service
-systemctl start jellyfin
+#=================================================
+# CREATE DEDICATED USER
+#=================================================
+ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
+
+# Create a dedicated user (if not existing)
+ynh_system_user_create --username=$app
+
+#=================================================
+# GENERIC FINALIZATION
+#=================================================
+# SECURE FILES AND DIRECTORIES
+#=================================================
+
+# Set permissions on app files
+chown -R $app: $final_path
+chown -R $app: /var/lib/jellyfin
+
+#=================================================
+# SETUP LOGROTATE
+#=================================================
+ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
+
+# Use logrotate to manage app-specific logfile(s)
+ynh_use_logrotate --non-append
+
+#=================================================
+# INTEGRATE SERVICE IN YUNOHOST
+#=================================================
+ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
+
+yunohost service add $app --description "Jellyfin media center" --log "/var/log/$app/$app.log"
+
+#=================================================
+# START SYSTEMD SERVICE
+#=================================================
+ynh_script_progression --message="Starting a systemd service..." --weight=1
+
+ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Startup complete"
+
+#=================================================
+# RELOAD NGINX
+#=================================================
+ynh_script_progression --message="Reloading NGINX web server..." --weight=1
+
+ynh_systemd_action --service_name=nginx --action=reload
+
+#=================================================
+# END OF SCRIPT
+#=================================================
+
+ynh_script_progression --message="Upgrade of $app completed" --last
From 0a7bc4d1f26777f096e7280bda5f46744af6508b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89ric=20Gaspar?=
<46165813+ericgaspar@users.noreply.github.com>
Date: Fri, 13 Nov 2020 21:16:22 +0100
Subject: [PATCH 2/9] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 820524b..a2b9467 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
[](https://dash.yunohost.org/appci/app/jellyfin)  
[](https://install-app.yunohost.org/?app=jellyfin)
-> *This package allows you to install REPLACEBYYOURAPP quickly and simply on a YunoHost server.
+> *This package allows you to install Jellyfin quickly and simply on a YunoHost server.
If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
## Overview
From 2fc0563d327c76640f8a645b7bab912b57c77986 Mon Sep 17 00:00:00 2001
From: ericgaspar
Date: Fri, 4 Dec 2020 12:15:37 +0100
Subject: [PATCH 3/9] Fix linter warnings
---
check_process | 5 -----
scripts/install | 2 +-
scripts/restore | 4 ++--
scripts/upgrade | 2 +-
4 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/check_process b/check_process
index 9263eba..19f6216 100644
--- a/check_process
+++ b/check_process
@@ -23,13 +23,8 @@
upgrade=1 from_commit=3e38d2ec954f6b333c3c2ed95e0e75c0df2fe966
backup_restore=1
multi_instance=0
- # This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version.
- # incorrect_path=1
port_already_use=0
change_url=1
-;;; Levels
- # If the level 5 (Package linter) is forced to 1. Please add justifications here.
- Level 5=auto
;;; Options
Email=
Notification=none
diff --git a/scripts/install b/scripts/install
index 82a5492..a2c874d 100644
--- a/scripts/install
+++ b/scripts/install
@@ -125,7 +125,7 @@ ynh_use_logrotate
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
-yunohost service add $app --description "Jellyfin media center" --log "/var/log/$app/$app.log"
+yunohost service add $app --description="Jellyfin media center" --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
diff --git a/scripts/restore b/scripts/restore
index 9f061d1..0339296 100644
--- a/scripts/restore
+++ b/scripts/restore
@@ -93,14 +93,14 @@ ynh_script_progression --message="Restoring the systemd configuration..." --weig
ynh_restore_file --origin_path="/lib/systemd/system/jellyfin.service" 2>/dev/null
ynh_restore_file --origin_path="/etc/systemd/system/jellyfin.service.d" 2>/dev/null
-systemctl enable $app.service
+systemctl enable $app.service --quiet
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
-yunohost service add $app --description "Jellyfin media center" --log "/var/log/$app/$app.log"
+yunohost service add $app --description="Jellyfin media center" --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
diff --git a/scripts/upgrade b/scripts/upgrade
index 01d1fc4..2664d0e 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -96,7 +96,7 @@ ynh_use_logrotate --non-append
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
-yunohost service add $app --description "Jellyfin media center" --log "/var/log/$app/$app.log"
+yunohost service add $app --description="Jellyfin media center" --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
From 772060554b31acf27ea1eca59715eacbfe6a9c3e Mon Sep 17 00:00:00 2001
From: ericgaspar
Date: Thu, 10 Dec 2020 20:57:00 +0100
Subject: [PATCH 4/9] fix linter warnings
---
scripts/install | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/install b/scripts/install
index a2c874d..44fb817 100644
--- a/scripts/install
+++ b/scripts/install
@@ -91,7 +91,7 @@ ynh_system_user_create --username=$app
#=================================================
# Load services once to generate system.xml
-systemctl enable jellyfin
+systemctl enable jellyfin --quiet
systemctl start jellyfin
sleep 5
systemctl stop jellyfin
From 2aab8003d64ffabe65bd11ebe5933cfef519b061 Mon Sep 17 00:00:00 2001
From: ericgaspar
Date: Mon, 14 Dec 2020 10:39:22 +0100
Subject: [PATCH 5/9] Fix linter warnings
---
check_process | 5 -----
manifest.json | 2 +-
scripts/install | 2 +-
scripts/restore | 2 +-
4 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/check_process b/check_process
index 9263eba..19f6216 100644
--- a/check_process
+++ b/check_process
@@ -23,13 +23,8 @@
upgrade=1 from_commit=3e38d2ec954f6b333c3c2ed95e0e75c0df2fe966
backup_restore=1
multi_instance=0
- # This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version.
- # incorrect_path=1
port_already_use=0
change_url=1
-;;; Levels
- # If the level 5 (Package linter) is forced to 1. Please add justifications here.
- Level 5=auto
;;; Options
Email=
Notification=none
diff --git a/manifest.json b/manifest.json
index 1292ae0..43eff57 100644
--- a/manifest.json
+++ b/manifest.json
@@ -6,7 +6,7 @@
"en": "Media System that manage and stream your media.",
"fr": "Système multimédia qui gère et diffuse vos médias."
},
- "version": "10.6.4~ynh1",
+ "version": "10.6.4~ynh2",
"url": "https://github.com/jellyfin/jellyfin",
"license": "GPL-2.0-only",
"maintainer": {
diff --git a/scripts/install b/scripts/install
index 82a5492..7ce6717 100644
--- a/scripts/install
+++ b/scripts/install
@@ -91,7 +91,7 @@ ynh_system_user_create --username=$app
#=================================================
# Load services once to generate system.xml
-systemctl enable jellyfin
+systemctl enable jellyfin --quiet
systemctl start jellyfin
sleep 5
systemctl stop jellyfin
diff --git a/scripts/restore b/scripts/restore
index 9f061d1..12eb480 100644
--- a/scripts/restore
+++ b/scripts/restore
@@ -93,7 +93,7 @@ ynh_script_progression --message="Restoring the systemd configuration..." --weig
ynh_restore_file --origin_path="/lib/systemd/system/jellyfin.service" 2>/dev/null
ynh_restore_file --origin_path="/etc/systemd/system/jellyfin.service.d" 2>/dev/null
-systemctl enable $app.service
+systemctl enable $app.service --quiet
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
From 076fe34f3752f294ce99d8599b4734a8287a8e07 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89ric=20Gaspar?=
<46165813+ericgaspar@users.noreply.github.com>
Date: Sat, 19 Dec 2020 23:03:32 +0100
Subject: [PATCH 6/9] Set badge in SVG
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index a2b9467..f002652 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
# Jellyfin for YunoHost
[](https://dash.yunohost.org/appci/app/jellyfin)  
-[](https://install-app.yunohost.org/?app=jellyfin)
+[](https://install-app.yunohost.org/?app=jellyfin)
> *This package allows you to install Jellyfin quickly and simply on a YunoHost server.
If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
From fa5b1641d4625ec304ea3ead8cc2f5b225129b97 Mon Sep 17 00:00:00 2001
From: Alexandre Aubin
Date: Sat, 9 Jan 2021 22:33:46 +0100
Subject: [PATCH 7/9] Finding an available port
---
scripts/install | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/install b/scripts/install
index 44fb817..95c39f8 100644
--- a/scripts/install
+++ b/scripts/install
@@ -57,7 +57,7 @@ ynh_app_setting_set --app=$app --key=is_public --value=$is_public
#=================================================
# FIND AND OPEN A PORT
#=================================================
-ynh_script_progression --message="Configuring firewall..." --weight=1
+ynh_script_progression --message="Finding an available port..." --weight=1
# Find an available port
port=$(ynh_find_port --port=8095)
From 23e14b606548c204891b4f7a7c3f58bdacd852a1 Mon Sep 17 00:00:00 2001
From: tituspijean
Date: Mon, 11 Jan 2021 08:48:21 +0100
Subject: [PATCH 8/9] Update NGINX conf for proxy bufferring (#50)
* Update NGINX conf for proxy bufferring
* Bump package version
* Fix linter warning
---
conf/nginx.conf | 18 ++++++++++++++++++
manifest.json | 2 +-
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/conf/nginx.conf b/conf/nginx.conf
index b1f2ab0..0e7dfc1 100644
--- a/conf/nginx.conf
+++ b/conf/nginx.conf
@@ -6,6 +6,7 @@ location __PATH__/ {
rewrite ^ https://$server_name$request_uri? permanent;
}
+ # Proxy main Jellyfin traffic
proxy_pass http://127.0.0.1:__PORT____PATH__/;
proxy_pass_request_headers on;
proxy_set_header Host $host;
@@ -16,6 +17,23 @@ location __PATH__/ {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
+ # Disable buffering when the nginx proxy gets very resource heavy upon streaming
+ proxy_buffering off;
+
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
}
+
+location __PATH__/socket {
+ # Proxy Jellyfin Websockets traffic
+ proxy_pass http://127.0.0.1:__PORT____PATH__/;
+ proxy_http_version 1.1;
+ proxy_set_header Upgrade $http_upgrade;
+ proxy_set_header Connection "upgrade";
+ proxy_set_header Host $host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header X-Forwarded-Proto $scheme;
+ proxy_set_header X-Forwarded-Protocol $scheme;
+ proxy_set_header X-Forwarded-Host $http_host;
+}
diff --git a/manifest.json b/manifest.json
index 43eff57..53a5b7f 100644
--- a/manifest.json
+++ b/manifest.json
@@ -6,7 +6,7 @@
"en": "Media System that manage and stream your media.",
"fr": "Système multimédia qui gère et diffuse vos médias."
},
- "version": "10.6.4~ynh2",
+ "version": "10.6.4~ynh3",
"url": "https://github.com/jellyfin/jellyfin",
"license": "GPL-2.0-only",
"maintainer": {
From 5478712c0ca7683503bc1b50cfafe81ea508065e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89ric=20Gaspar?=
<46165813+ericgaspar@users.noreply.github.com>
Date: Fri, 15 Jan 2021 15:32:36 +0100
Subject: [PATCH 9/9] Testing (#51)
* Update NGINX conf for proxy bufferring (#50)
* Fix linter warning
---
README.md | 2 +-
conf/nginx.conf | 18 ++++++++++++++++++
manifest.json | 2 +-
scripts/install | 4 ++--
scripts/restore | 2 +-
scripts/upgrade | 2 +-
6 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/README.md b/README.md
index a2b9467..f002652 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
# Jellyfin for YunoHost
[](https://dash.yunohost.org/appci/app/jellyfin)  
-[](https://install-app.yunohost.org/?app=jellyfin)
+[](https://install-app.yunohost.org/?app=jellyfin)
> *This package allows you to install Jellyfin quickly and simply on a YunoHost server.
If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
diff --git a/conf/nginx.conf b/conf/nginx.conf
index b1f2ab0..0e7dfc1 100644
--- a/conf/nginx.conf
+++ b/conf/nginx.conf
@@ -6,6 +6,7 @@ location __PATH__/ {
rewrite ^ https://$server_name$request_uri? permanent;
}
+ # Proxy main Jellyfin traffic
proxy_pass http://127.0.0.1:__PORT____PATH__/;
proxy_pass_request_headers on;
proxy_set_header Host $host;
@@ -16,6 +17,23 @@ location __PATH__/ {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
+ # Disable buffering when the nginx proxy gets very resource heavy upon streaming
+ proxy_buffering off;
+
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
}
+
+location __PATH__/socket {
+ # Proxy Jellyfin Websockets traffic
+ proxy_pass http://127.0.0.1:__PORT____PATH__/;
+ proxy_http_version 1.1;
+ proxy_set_header Upgrade $http_upgrade;
+ proxy_set_header Connection "upgrade";
+ proxy_set_header Host $host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header X-Forwarded-Proto $scheme;
+ proxy_set_header X-Forwarded-Protocol $scheme;
+ proxy_set_header X-Forwarded-Host $http_host;
+}
diff --git a/manifest.json b/manifest.json
index 43eff57..53a5b7f 100644
--- a/manifest.json
+++ b/manifest.json
@@ -6,7 +6,7 @@
"en": "Media System that manage and stream your media.",
"fr": "Système multimédia qui gère et diffuse vos médias."
},
- "version": "10.6.4~ynh2",
+ "version": "10.6.4~ynh3",
"url": "https://github.com/jellyfin/jellyfin",
"license": "GPL-2.0-only",
"maintainer": {
diff --git a/scripts/install b/scripts/install
index 7ce6717..95c39f8 100644
--- a/scripts/install
+++ b/scripts/install
@@ -57,7 +57,7 @@ ynh_app_setting_set --app=$app --key=is_public --value=$is_public
#=================================================
# FIND AND OPEN A PORT
#=================================================
-ynh_script_progression --message="Configuring firewall..." --weight=1
+ynh_script_progression --message="Finding an available port..." --weight=1
# Find an available port
port=$(ynh_find_port --port=8095)
@@ -125,7 +125,7 @@ ynh_use_logrotate
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
-yunohost service add $app --description "Jellyfin media center" --log "/var/log/$app/$app.log"
+yunohost service add $app --description="Jellyfin media center" --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
diff --git a/scripts/restore b/scripts/restore
index 12eb480..0339296 100644
--- a/scripts/restore
+++ b/scripts/restore
@@ -100,7 +100,7 @@ systemctl enable $app.service --quiet
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
-yunohost service add $app --description "Jellyfin media center" --log "/var/log/$app/$app.log"
+yunohost service add $app --description="Jellyfin media center" --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
diff --git a/scripts/upgrade b/scripts/upgrade
index 01d1fc4..2664d0e 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -96,7 +96,7 @@ ynh_use_logrotate --non-append
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
-yunohost service add $app --description "Jellyfin media center" --log "/var/log/$app/$app.log"
+yunohost service add $app --description="Jellyfin media center" --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE