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/manifest.json b/manifest.json
index bf09819..a65e76c 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,27 +30,29 @@
},
"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.)."
+ }
}
]
}
-}
+}
\ No newline at end of file
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..6330461 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
@@ -28,43 +28,41 @@ ynh_abort_if_errors
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
#=================================================
-### 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"
+ynh_script_progression --message="Validating installation parameters..." --weight=1
-# Normalize the url path syntax
-path_url=$(ynh_normalize_url_path "$path_url")
+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 "
-# 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
@@ -72,30 +70,8 @@ ynh_app_setting_set "$app" is_public "$is_public"
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
#=================================================
@@ -138,16 +114,18 @@ rm "$final_path"/*.deb
#=================================================
# 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 +140,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
\ No newline at end of file
diff --git a/scripts/remove b/scripts/remove
index 6a482b9..4956c18 100644
--- a/scripts/remove
+++ b/scripts/remove
@@ -12,31 +12,30 @@ 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)
#=================================================
# 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"
+ 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,25 +43,25 @@ 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
@@ -85,33 +84,18 @@ then
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..60bf206 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -1,21 +1,57 @@
#!/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
+final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
#=================================================
-# DOWNLOAD, CHECK AND UNPACK SOURCE
+# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
+ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=3
+
+# 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
+
+#=================================================
+# STANDARD UPGRADE STEPS
+#=================================================
+# STOP SYSTEMD SERVICE
+#=================================================
+ynh_script_progression --message="Stopping a systemd service..." --weight=1
+
+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
+
+#=================================================
+# UPGRADE DEPENDENCIES
+#=================================================
+ynh_script_progression --message="Upgrading dependencies..." --weight=3
ynh_app_setting_set "$app" final_path "$final_path"
@@ -53,25 +89,54 @@ dpkg --install "$final_path"/jellyfin-web.deb
rm "$final_path"/*.deb
#=================================================
-# NGINX CONFIGURATION
+# CREATE DEDICATED USER
#=================================================
+ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
-# Create a dedicated nginx config
-#ynh_add_nginx_config
+# Create a dedicated user (if not existing)
+ynh_system_user_create --username="$app"
#=================================================
-# UPGRADE CONFIG
+# GENERIC FINALIZATION
+#=================================================
+# SECURE FILES AND DIRECTORIES
#=================================================
-#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
-# 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
+# Set permissions on app files
+chown -R "$app": "$final_path"
+chown -R "$app": /var/lib/jellyfin
-# Start jellyfin service
-systemctl start 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