From 2c3a176a501b22027716fca693cd430420401e25 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Mon, 19 Oct 2020 23:06:48 +0200 Subject: [PATCH 01/38] 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 --- 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 +++---- scripts/_common.sh | 111 -------------------- scripts/backup | 30 +++--- scripts/install | 172 +++++++++++++++++-------------- scripts/remove | 67 ++++-------- scripts/restore | 30 ++++-- scripts/upgrade | 183 +++++++++++++++++++++++---------- 14 files changed, 299 insertions(+), 380 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 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/scripts/_common.sh b/scripts/_common.sh index 0f53f77..a9bf588 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,112 +1 @@ #!/bin/bash - -# ============================================================================= -# YUNOHOST 2.7 FORTHCOMING HELPERS -# ============================================================================= - -# 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" - - # 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" - - sudo systemctl reload nginx -} - -# 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 -} diff --git a/scripts/backup b/scripts/backup index 13ce93d..fc5dcba 100644 --- a/scripts/backup +++ b/scripts/backup @@ -32,46 +32,44 @@ 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_print_info --message="Declaring files to be backed up..." -ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log" +### N.B. : the following 'ynh_backup' calls are only a *declaration* of what needs +### to be backuped and not an actual copy of any file. The actual backup that +### creates and fill the archive with the files happens in the core after this +### script is called. Hence ynh_backups calls takes basically 0 seconds to run. #================================================= # 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" - #================================================= # 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/install b/scripts/install index 56a164c..9effa07 100644 --- a/scripts/install +++ b/scripts/install @@ -24,7 +24,6 @@ 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 @@ -44,33 +43,54 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= +### About --weight and --time +### ynh_script_progression will show to your final users the progression of each scripts. +### In order to do that, --weight will represent the relative time of execution compared to the other steps in the script. +### --time is a packager option, it will show you the execution time since the previous call. +### This option should be removed before releasing your app. +### Use the execution time, given by --time, to estimate the weight of a step. +### A common way to do it is to set a weight equal to the execution time in second +1. +### The execution time is given for the duration since the previous call. So the weight should be applied to this previous call. +ynh_script_progression --message="Validating installation parameters..." --time --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="This path already contains a folder" -# 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..." --time --weight=1 + +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=is_public --value=$is_public + +#================================================= +# STANDARD MODIFICATIONS +#================================================= +# FIND AND OPEN A PORT +#================================================= +ynh_script_progression --message="Configuring firewall..." --time --weight=1 + +### 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 an available port +port=$(ynh_find_port --port=8095) +ynh_app_setting_set --app=$app --key=port --value=$port -ynh_app_setting_set "$app" domain "$domain" -ynh_app_setting_set "$app" path "$path_url" -ynh_app_setting_set "$app" is_public "$is_public" #================================================= # INSTALL DEPENDENCIES #================================================= - -ynh_print_info "Installing dependencies..." +ynh_script_progression --message="Installing dependencies..." --time --weight=1 ### `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. @@ -79,75 +99,25 @@ ynh_print_info "Installing dependencies..." ### - 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_add_app_dependencies --package="at libass5 libbluray1 libdrm2 libmp3lame0 libopus0 libtheora0 libva-drm1 libva-x11-1 libva1 libvdpau1 libvorbis0a libvorbisenc2 libx264-148 libx265-95 libzvbi0 libwebpmux2" +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" #================================================= # NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Configuring nginx web server..." --time --weight=1 +### `ynh_add_nginx_config` will use the file conf/nginx.conf # Create a dedicated nginx config ynh_add_nginx_config #================================================= # CREATE DEDICATED USER #================================================= +ynh_script_progression --message="Configuring system user..." --time --weight=1 # Create a system user -ynh_system_user_create "$app" +ynh_system_user_create --username=$app #================================================= # MODIFY A CONFIG FILE @@ -177,7 +147,7 @@ ynh_replace_string --match_string="8096/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..." --time --weight=1 + 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..." --time --weight=1 # Remove the dedicated systemd config ynh_remove_systemd_config @@ -44,74 +44,51 @@ ynh_remove_systemd_config #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_print_info "Removing dependencies" +ynh_script_progression --message="Removing dependencies..." --time --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..." --time --weight=1 # 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..." --time --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" + ynh_script_progression --message="Closing port $port..." --time --weight=1 + 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..." --time --weight=1 # 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" --time --last diff --git a/scripts/restore b/scripts/restore index 824ea41..e6a7127 100644 --- a/scripts/restore +++ b/scripts/restore @@ -41,6 +41,8 @@ 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" \ + 43 || ynh_die --message="There is already a directory: /var/lib/jellyfin " #================================================= # STANDARD RESTORATION STEPS @@ -56,6 +58,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_script_progression --message="Restoring the app main directory..." --time --weight=1 ynh_restore_file --origin_path="$final_path" +ynh_restore_file --origin_path="/var/lib/jellyfin" #================================================= # RECREATE THE DEDICATED USER @@ -70,38 +73,53 @@ 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..." --time --weight=1 + +# 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_restore_file --origin_path="/etc/systemd/system/$app.service" -systemctl enable "$app".service +systemctl enable $app.service #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= +ynh_script_progression --message="Integrating service in YunoHost..." --time --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_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" + +#================================================= +# 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..." --time --weight=1 ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index 807c15a..8d1212a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,77 +1,154 @@ #!/bin/bash -# Exit on command errors and treat unset variables as an error -set -eu +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers + +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading installation settings..." --time --weight=1 -# See comments in install script app=$YNH_APP_INSTANCE_NAME final_path=/opt/yunohost/$app -# Source YunoHost helpers -source /usr/share/yunohost/helpers - -# Stop jellyfin service -systemctl stop jellyfin - #================================================= -# DOWNLOAD, CHECK AND UNPACK SOURCE +# CHECK VERSION #================================================= -ynh_app_setting_set "$app" final_path "$final_path" +### This helper will compare the version of the currently installed app and the version of the upstream package. +### $upgrade_type can have 2 different values +### - UPGRADE_APP if the upstream app version has changed +### - UPGRADE_PACKAGE if only the YunoHost package has changed +### ynh_check_app_version_changed will stop the upgrade if the app is up to date. +### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do. +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)..." --time --weight=1 -# 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..." --time --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..." --time --weight=1 # Create a dedicated nginx config -#ynh_add_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..." --time --weight=1 -# 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/debian $( lsb_release -c -s ) main" --package="jellyfin" --key="https://repo.jellyfin.org/debian/jellyfin_team.gpg.key" -# Start jellyfin service -systemctl start jellyfin +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1 + +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app + +#================================================= +# SETUP SYSTEMD +#================================================= +ynh_script_progression --message="Upgrading systemd configuration..." --time --weight=1 + +# Create a dedicated systemd config +ynh_add_systemd_config + +#================================================= +# MODIFY A CONFIG FILE +#================================================= + +### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. +### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. +#ynh_backup_if_checksum_is_different --file="$final_path/CONFIG_FILE" + +#ynh_replace_string --match_string="match_string" --replace_string="replace_string" --target_file="$final_path/CONFIG_FILE" + +# Recalculate and store the checksum of the file for the next upgrade. +#ynh_store_file_checksum --file="$final_path/CONFIG_FILE" + +#================================================= +# 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..." --time --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..." --time --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..." --time --weight=1 + +ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" + +#================================================= +# SETUP SSOWAT +#================================================= +ynh_script_progression --message="Upgrading SSOwat configuration..." --time --weight=1 + +# Make app public if necessary +if [ $is_public -eq 1 ] +then + # unprotected_uris allows SSO credentials to be passed anyway + ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" +fi + +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Upgrade of $app completed" --time --last From a570cc92503a81dac22b818909eb4a4614a59cc4 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Tue, 20 Oct 2020 15:41:23 +0200 Subject: [PATCH 02/38] [enh] specify version to install --- scripts/_common.sh | 2 ++ scripts/install | 3 +-- scripts/upgrade | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index a9bf588..bd66acb 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1 +1,3 @@ #!/bin/bash + +pkg_version="10.6.4-1" diff --git a/scripts/install b/scripts/install index 9effa07..b333097 100644 --- a/scripts/install +++ b/scripts/install @@ -99,8 +99,7 @@ ynh_script_progression --message="Installing dependencies..." --time --weight=1 ### - As well as the section "REINSTALL DEPENDENCIES" in the restore script ### - And the section "UPGRADE DEPENDENCIES" in the upgrade script -#ynh_add_app_dependencies --package="at libass5 libbluray1 libdrm2 libmp3lame0 libopus0 libtheora0 libva-drm1 libva-x11-1 libva1 libvdpau1 libvorbis0a libvorbisenc2 libx264-148 libx265-95 libzvbi0 libwebpmux2" -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" +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 diff --git a/scripts/upgrade b/scripts/upgrade index 8d1212a..539f202 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -65,7 +65,7 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Upgrading dependencies..." --time --weight=1 -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" +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" #================================================= # CREATE DEDICATED USER From f0e7da167f1c28971b77c3cf2d7ea23db015903e Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Tue, 20 Oct 2020 15:43:04 +0200 Subject: [PATCH 03/38] Fix manifest --- manifest.json | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/manifest.json b/manifest.json index bf09819..7f25ce7 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "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." }, - "version": "10.6.4", + "version": "10.6.4~ynh1", "url": "https://github.com/jellyfin/jellyfin", "license": "GPL-2.0", "maintainer": { @@ -14,7 +14,7 @@ "email": "liberodark@gmail.com" }, "requirements": { - "yunohost": ">= 2.7.2" + "yunohost": ">= 3.8.1" }, "multi_instance": false, "services": [ @@ -30,7 +30,6 @@ }, "example": "example.com" }, - { "name": "path", "type": "path", @@ -41,15 +40,14 @@ "example": "/jellyfin", "default": "/jellyfin" }, - { "name": "is_public", "type": "boolean", "ask": { - "en": "Is it a public site ?", + "en": "Is it a public site?", "fr": "Est-ce un site public ?" }, - "default": "true" + "default": true } ] } From 77737e524a975c5532e249e0fb220433950576bc Mon Sep 17 00:00:00 2001 From: tituspijean Date: Tue, 20 Oct 2020 15:44:09 +0200 Subject: [PATCH 04/38] [fix] multiple install should not be tested --- check_process | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_process b/check_process index 0cbeae3..7a9ead4 100644 --- a/check_process +++ b/check_process @@ -20,7 +20,7 @@ setup_public=1 upgrade=1 backup_restore=1 - multi_instance=1 + multi_instance=0 incorrect_path=1 port_already_use=0 change_url=0 From ebfbffadec3f46aecf9ddd20765970229cb587c0 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Tue, 20 Oct 2020 15:46:56 +0200 Subject: [PATCH 05/38] [fix] missing final_path definition --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index b333097..7a5e505 100644 --- a/scripts/install +++ b/scripts/install @@ -68,6 +68,7 @@ ynh_script_progression --message="Storing installation settings..." --time --wei 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 #================================================= @@ -86,7 +87,6 @@ ynh_script_progression --message="Configuring firewall..." --time --weight=1 port=$(ynh_find_port --port=8095) ynh_app_setting_set --app=$app --key=port --value=$port - #================================================= # INSTALL DEPENDENCIES #================================================= From 77ef3e7dea602354a2d6e403d79a07ba5384d2f8 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Tue, 20 Oct 2020 15:54:54 +0200 Subject: [PATCH 06/38] Update README.md --- README.md | 66 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 54 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 1fb072b..63bd219 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,66 @@ -# Jellyfin app for YunoHost -Jellyfin Server +# Jellyfin for YunoHost + +[![Integration level](https://dash.yunohost.org/integration/jellyfin.svg)](https://dash.yunohost.org/appci/app/jellyfin) ![](https://ci-apps.yunohost.org/ci/badges/jellyfin.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/jellyfin.maintain.svg) +[![Install Jellyfin with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=jellyfin) + +## 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 -![](https://www.ostechnix.com/wp-content/uploads/2019/03/jellyfin-logo-720x340.png) +![](https://jellyfin.org/images/screenshots/movie_full.png) +## Demo -[![Install Jellyfin with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](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? + * Can the app be used by multiple users? + +#### Supported architectures + +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/jellyfin%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/jellyfin/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/jellyfin%20%28Apps%29.svg)](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 +``` From c05a696e448fcb5b00c23cfc5e4ae73379d79265 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Tue, 20 Oct 2020 15:56:19 +0200 Subject: [PATCH 07/38] [fix] retrieve actual final_path --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 539f202..bbfde78 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -15,7 +15,7 @@ source /usr/share/yunohost/helpers ynh_script_progression --message="Loading installation settings..." --time --weight=1 app=$YNH_APP_INSTANCE_NAME -final_path=/opt/yunohost/$app +final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # CHECK VERSION From 7fe8416fefdcf12873036c5aec5b579bf7fb8f2e Mon Sep 17 00:00:00 2001 From: tituspijean Date: Tue, 20 Oct 2020 16:41:39 +0200 Subject: [PATCH 08/38] [fix] install logrotate --- scripts/install | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/scripts/install b/scripts/install index 7a5e505..1c2c6d3 100644 --- a/scripts/install +++ b/scripts/install @@ -162,6 +162,22 @@ ynh_replace_string --match_string="8096 Date: Tue, 20 Oct 2020 17:18:25 +0200 Subject: [PATCH 09/38] [fix] backup of service --- scripts/backup | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/backup b/scripts/backup index fc5dcba..a2f5465 100644 --- a/scripts/backup +++ b/scripts/backup @@ -66,7 +66,8 @@ ynh_backup --src_path="/etc/logrotate.d/$app" # BACKUP SYSTEMD #================================================= -ynh_backup --src_path="/etc/systemd/system/$app.service" +ynh_backup --src_path="/lib/systemd/system/jellyfin.service" +ynh_backup --src_path="/etc/systemd/system/jellyfin.service.d" #================================================= # END OF SCRIPT From 60ea6960f74f52852c93f8ad28235be0eaba7baf Mon Sep 17 00:00:00 2001 From: tituspijean Date: Tue, 20 Oct 2020 17:48:40 +0200 Subject: [PATCH 10/38] [fix] fix upgrade and restore --- scripts/restore | 4 ++-- scripts/upgrade | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/restore b/scripts/restore index e6a7127..57c95b0 100644 --- a/scripts/restore +++ b/scripts/restore @@ -41,8 +41,8 @@ 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" \ - 43 || ynh_die --message="There is already a directory: /var/lib/jellyfin " +test ! -d "/var/lib/jellyfin" \ + || ynh_die --message="There is already a directory: /var/lib/jellyfin " #================================================= # STANDARD RESTORATION STEPS diff --git a/scripts/upgrade b/scripts/upgrade index bbfde78..744dc15 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -15,6 +15,8 @@ source /usr/share/yunohost/helpers ynh_script_progression --message="Loading installation settings..." --time --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) final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= From bc55561049f558cdbc9a75cea1b70eded4e0c8f4 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Tue, 20 Oct 2020 17:58:06 +0200 Subject: [PATCH 11/38] Expand check_process scope --- check_process | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/check_process b/check_process index 7a9ead4..867eda5 100644 --- a/check_process +++ b/check_process @@ -6,14 +6,14 @@ ;; Test complet ; Manifest domain="domain.tld" (DOMAIN) - path="/" (PATH) + path="/path" (PATH) is_public=1 (PUBLIC|public=1|private=0) # password="pass" # nextclouddomain="domain.tld" port="9980" (PORT) ; Checks pkg_linter=1 - setup_sub_dir=0 + setup_sub_dir=1 setup_root=1 setup_nourl=0 setup_private=0 From cedae0e38fe34863507295f3a006f2a8ecf59eea Mon Sep 17 00:00:00 2001 From: tituspijean Date: Tue, 20 Oct 2020 22:24:34 +0200 Subject: [PATCH 12/38] [fix] restore systemd, load port in upgrade --- scripts/restore | 3 ++- scripts/upgrade | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/restore b/scripts/restore index 57c95b0..012a214 100644 --- a/scripts/restore +++ b/scripts/restore @@ -91,7 +91,8 @@ ynh_install_extra_app_dependencies --repo="https://repo.jellyfin.org/debian $( l #================================================= ynh_script_progression --message="Restoring the systemd configuration..." --time --weight=1 -ynh_restore_file --origin_path="/etc/systemd/system/$app.service" +ynh_restore_file --origin_path="/lib/systemd/system/jellyfin.service" +ynh_restore_file --origin_path="/etc/systemd/system/jellyfin.service.d" systemctl enable $app.service #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 744dc15..ee3523c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -18,6 +18,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) +port=$(ynh_app_setting_get --app=$app --key=port) #================================================= # CHECK VERSION From fc68b3455d7ce0a4292951d082d83b7b54acbe9c Mon Sep 17 00:00:00 2001 From: tituspijean Date: Wed, 21 Oct 2020 11:12:20 +0200 Subject: [PATCH 13/38] [fix] no need to upgrade systemd conf --- scripts/upgrade | 8 -------- 1 file changed, 8 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index ee3523c..6fa60d2 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -78,14 +78,6 @@ ynh_script_progression --message="Making sure dedicated system user exists..." - # Create a dedicated user (if not existing) ynh_system_user_create --username=$app -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Upgrading systemd configuration..." --time --weight=1 - -# Create a dedicated systemd config -ynh_add_systemd_config - #================================================= # MODIFY A CONFIG FILE #================================================= From 1f2ef3f92d5f8d45ba413ec0eaab8a0b1b8e2798 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Fri, 23 Oct 2020 11:41:51 +0200 Subject: [PATCH 14/38] [fix] load is_public in upgrade --- scripts/upgrade | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/upgrade b/scripts/upgrade index 6fa60d2..3703bd8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -17,6 +17,7 @@ ynh_script_progression --message="Loading installation settings..." --time --wei 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) From 821d487c6788052f1014d1465b280aa5051f782a Mon Sep 17 00:00:00 2001 From: tituspijean Date: Wed, 28 Oct 2020 19:07:49 +0100 Subject: [PATCH 15/38] [add] sleep time to let the service start --- scripts/install | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/install b/scripts/install index 1c2c6d3..5784f80 100644 --- a/scripts/install +++ b/scripts/install @@ -209,6 +209,7 @@ ynh_script_progression --message="Starting a systemd service..." --time --weight # Start a systemd service ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +sleep 5 #================================================= # SETUP SSOWAT From 66e31179e3187b9a327b14974e63fb8ef5dee058 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Thu, 29 Oct 2020 10:34:27 +0100 Subject: [PATCH 16/38] [enh] check /var/lib availability, comments cleanup --- scripts/install | 21 +++------------------ scripts/upgrade | 13 ------------- 2 files changed, 3 insertions(+), 31 deletions(-) diff --git a/scripts/install b/scripts/install index 5784f80..66eab6f 100644 --- a/scripts/install +++ b/scripts/install @@ -56,7 +56,8 @@ ynh_script_progression --message="Validating installation parameters..." --time ### 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=/etc/jellyfin -test ! -e "$final_path" || ynh_die --message="This path already contains a folder" +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 " # Register (book) web path ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url @@ -78,11 +79,6 @@ ynh_app_setting_set --app=$app --key=is_public --value=$is_public #================================================= ynh_script_progression --message="Configuring firewall..." --time --weight=1 -### 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 an available port port=$(ynh_find_port --port=8095) ynh_app_setting_set --app=$app --key=port --value=$port @@ -131,23 +127,12 @@ 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 "/etc/jellyfin/system.xml" - #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 3703bd8..20c50cd 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -79,19 +79,6 @@ ynh_script_progression --message="Making sure dedicated system user exists..." - # Create a dedicated user (if not existing) ynh_system_user_create --username=$app -#================================================= -# MODIFY A CONFIG FILE -#================================================= - -### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. -### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. -#ynh_backup_if_checksum_is_different --file="$final_path/CONFIG_FILE" - -#ynh_replace_string --match_string="match_string" --replace_string="replace_string" --target_file="$final_path/CONFIG_FILE" - -# Recalculate and store the checksum of the file for the next upgrade. -#ynh_store_file_checksum --file="$final_path/CONFIG_FILE" - #================================================= # GENERIC FINALIZATION #================================================= From e264caff51f34b4e043b76022678e70e31702dd3 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Thu, 29 Oct 2020 11:53:40 +0100 Subject: [PATCH 17/38] [enh] Setting the weights for script progression indicators --- scripts/backup | 2 +- scripts/install | 24 ++++++++++++------------ scripts/remove | 16 ++++++++-------- scripts/restore | 20 ++++++++++---------- scripts/upgrade | 24 ++++++++++++------------ 5 files changed, 43 insertions(+), 43 deletions(-) diff --git a/scripts/backup b/scripts/backup index a2f5465..c0119b2 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 diff --git a/scripts/install b/scripts/install index 66eab6f..0f935d2 100644 --- a/scripts/install +++ b/scripts/install @@ -51,7 +51,7 @@ app=$YNH_APP_INSTANCE_NAME ### Use the execution time, given by --time, to estimate the weight of a step. ### A common way to do it is to set a weight equal to the execution time in second +1. ### The execution time is given for the duration since the previous call. So the weight should be applied to this previous call. -ynh_script_progression --message="Validating installation parameters..." --time --weight=1 +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" @@ -65,7 +65,7 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Storing installation settings..." --time --weight=1 +ynh_script_progression --message="Storing installation settings..." --weight=2 ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url @@ -77,7 +77,7 @@ ynh_app_setting_set --app=$app --key=is_public --value=$is_public #================================================= # FIND AND OPEN A PORT #================================================= -ynh_script_progression --message="Configuring firewall..." --time --weight=1 +ynh_script_progression --message="Configuring firewall..." --weight=1 # Find an available port port=$(ynh_find_port --port=8095) @@ -86,7 +86,7 @@ ynh_app_setting_set --app=$app --key=port --value=$port #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." --time --weight=1 +ynh_script_progression --message="Installing dependencies..." --weight=1 ### `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. @@ -100,7 +100,7 @@ ynh_install_extra_app_dependencies --repo="https://repo.jellyfin.org/$( awk -F'= #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring nginx web server..." --time --weight=1 +ynh_script_progression --message="Configuring nginx web server..." --weight=6 ### `ynh_add_nginx_config` will use the file conf/nginx.conf # Create a dedicated nginx config @@ -109,7 +109,7 @@ ynh_add_nginx_config #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Configuring system user..." --time --weight=1 +ynh_script_progression --message="Configuring system user..." --weight=2 # Create a system user ynh_system_user_create --username=$app @@ -150,7 +150,7 @@ chown -R $app: /var/lib/jellyfin #================================================= # SETUP LOGROTATE #================================================= -ynh_script_progression --message="Configuring log rotation..." --time --weight=1 +ynh_script_progression --message="Configuring log rotation..." --weight=2 ### `ynh_use_logrotate` is used to configure a logrotate configuration for the logs of this app. ### Use this helper only if there is effectively a log file for this app. @@ -166,7 +166,7 @@ ynh_use_logrotate #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1 +ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 ### `yunohost service add` integrates a service in YunoHost. It then gets ### displayed in the admin interface and through the others `yunohost service` commands. @@ -182,7 +182,7 @@ yunohost service add $app --description "Jellyfin media center" --log "/var/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` is used to start a systemd service for an app. ### Only needed if you have configure a systemd service @@ -199,7 +199,7 @@ sleep 5 #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring SSOwat..." --time --weight=1 +ynh_script_progression --message="Configuring SSOwat..." --time --weight=2 # Make app public if necessary if [ $is_public -eq 1 ] @@ -211,7 +211,7 @@ fi #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 +ynh_script_progression --message="Reloading nginx web server..." --weight=2 ynh_systemd_action --service_name=nginx --action=reload @@ -219,4 +219,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" --time --last +ynh_script_progression --message="Installation of $app completed" --last diff --git a/scripts/remove b/scripts/remove index b502cba..aabec9d 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 +ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME @@ -29,14 +29,14 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) # 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_script_progression --message="Removing $app service integration..." --time --weight=1 + ynh_script_progression --message="Removing $app service integration..." --weight=3 yunohost service remove $app fi #================================================= # STOP AND REMOVE SERVICE #================================================= -ynh_script_progression --message="Stopping and removing the systemd service..." --time --weight=1 +ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1 # Remove the dedicated systemd config ynh_remove_systemd_config @@ -44,7 +44,7 @@ ynh_remove_systemd_config #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing dependencies..." --time --weight=1 +ynh_script_progression --message="Removing dependencies..." --weight=1 # Remove metapackage and its dependencies ynh_remove_app_dependencies @@ -52,7 +52,7 @@ ynh_remove_app_dependencies #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing app main directory..." --time --weight=1 +ynh_script_progression --message="Removing app main directory..." --weight=12 # Remove the app directory securely ynh_secure_remove --file="$final_path" @@ -62,7 +62,7 @@ ynh_secure_remove --file="/var/lib/jellyfin" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Removing nginx web server configuration..." --time --weight=1 +ynh_script_progression --message="Removing nginx web server configuration..." --weight=1 # Remove the dedicated nginx config ynh_remove_nginx_config @@ -73,7 +73,7 @@ ynh_remove_nginx_config if yunohost firewall list | grep -q "\- $port$" then - ynh_script_progression --message="Closing port $port..." --time --weight=1 + ynh_script_progression --message="Closing port $port..." --weight=1 ynh_exec_warn_less yunohost firewall disallow TCP $port fi @@ -82,7 +82,7 @@ fi #================================================= # REMOVE DEDICATED USER #================================================= -ynh_script_progression --message="Removing the dedicated system user..." --time --weight=1 +ynh_script_progression --message="Removing the dedicated system user..." --weight=2 # Delete a system user ynh_system_user_delete --username=$app diff --git a/scripts/restore b/scripts/restore index 012a214..e0fee5c 100644 --- a/scripts/restore +++ b/scripts/restore @@ -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,7 +35,7 @@ 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}" @@ -55,7 +55,7 @@ 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" @@ -63,7 +63,7 @@ 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" @@ -81,7 +81,7 @@ chown -R $app: /var/lib/jellyfin #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1 +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" @@ -89,7 +89,7 @@ ynh_install_extra_app_dependencies --repo="https://repo.jellyfin.org/debian $( l #================================================= # 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="/lib/systemd/system/jellyfin.service" ynh_restore_file --origin_path="/etc/systemd/system/jellyfin.service.d" @@ -98,14 +98,14 @@ systemctl enable $app.service #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1 +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..." --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" @@ -120,7 +120,7 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= # RELOAD NGINX AND PHP-FPM #================================================= -ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 +ynh_script_progression --message="Reloading nginx web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload @@ -128,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 20c50cd..af726ee 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 +ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) @@ -36,7 +36,7 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --time --weight=1 +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 @@ -52,14 +52,14 @@ ynh_abort_if_errors #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." --time --weight=1 +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..." --time --weight=1 +ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=1 # Create a dedicated nginx config ynh_add_nginx_config @@ -67,14 +67,14 @@ ynh_add_nginx_config #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_script_progression --message="Upgrading dependencies..." --time --weight=1 +ynh_script_progression --message="Upgrading dependencies..." --weight=3 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" #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1 +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 @@ -92,7 +92,7 @@ chown -R $app: /var/lib/jellyfin #================================================= # SETUP LOGROTATE #================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." --time --weight=1 +ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --non-append @@ -100,21 +100,21 @@ ynh_use_logrotate --non-append #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1 +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..." --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" #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Upgrading SSOwat configuration..." --time --weight=1 +ynh_script_progression --message="Upgrading SSOwat configuration..." --weight=1 # Make app public if necessary if [ $is_public -eq 1 ] @@ -126,7 +126,7 @@ fi #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 +ynh_script_progression --message="Reloading nginx web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload @@ -134,4 +134,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --time --last +ynh_script_progression --message="Upgrade of $app completed" --last From c70b60ece08992c70797bb654527dbb29a735a59 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Thu, 29 Oct 2020 11:59:28 +0100 Subject: [PATCH 18/38] [enh] add publicness explanation --- manifest.json | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/manifest.json b/manifest.json index 7f25ce7..05be5fc 100644 --- a/manifest.json +++ b/manifest.json @@ -44,10 +44,14 @@ "name": "is_public", "type": "boolean", "ask": { - "en": "Is it a public site?", - "fr": "Est-ce un site public ?" + "en": "Is it a public app?", + "fr": "Est-ce une app 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.)." + } } ] } From 63e023d2326e6876af017efc3fdb0d4d354a711d Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sun, 8 Nov 2020 17:04:29 +0100 Subject: [PATCH 19/38] No need to close port since it was never opened --- scripts/remove | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/scripts/remove b/scripts/remove index aabec9d..5ea9661 100644 --- a/scripts/remove +++ b/scripts/remove @@ -67,16 +67,6 @@ ynh_script_progression --message="Removing nginx web server configuration..." -- # Remove the dedicated nginx config ynh_remove_nginx_config -#================================================= -# CLOSE A PORT -#================================================= - -if yunohost firewall list | grep -q "\- $port$" -then - ynh_script_progression --message="Closing port $port..." --weight=1 - ynh_exec_warn_less yunohost firewall disallow TCP $port -fi - #================================================= # GENERIC FINALIZATION #================================================= From dafd95a8b2e5e21a61bd58894d61b6b315e27f57 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sun, 8 Nov 2020 17:07:47 +0100 Subject: [PATCH 20/38] Comments cleanup --- scripts/install | 57 ------------------------------------------------- scripts/upgrade | 6 ------ 2 files changed, 63 deletions(-) diff --git a/scripts/install b/scripts/install index 0f935d2..b6283d6 100644 --- a/scripts/install +++ b/scripts/install @@ -28,33 +28,13 @@ 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 #================================================= -### About --weight and --time -### ynh_script_progression will show to your final users the progression of each scripts. -### In order to do that, --weight will represent the relative time of execution compared to the other steps in the script. -### --time is a packager option, it will show you the execution time since the previous call. -### This option should be removed before releasing your app. -### Use the execution time, given by --time, to estimate the weight of a step. -### A common way to do it is to set a weight equal to the execution time in second +1. -### The execution time is given for the duration since the previous call. So the weight should be applied to this previous call. 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=/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 " @@ -88,13 +68,6 @@ ynh_app_setting_set --app=$app --key=port --value=$port #================================================= ynh_script_progression --message="Installing dependencies..." --weight=1 -### `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_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" #================================================= @@ -102,7 +75,6 @@ ynh_install_extra_app_dependencies --repo="https://repo.jellyfin.org/$( awk -F'= #================================================= ynh_script_progression --message="Configuring nginx web server..." --weight=6 -### `ynh_add_nginx_config` will use the file conf/nginx.conf # Create a dedicated nginx config ynh_add_nginx_config @@ -139,10 +111,6 @@ ynh_replace_string --match_string="8096 Date: Sun, 8 Nov 2020 17:17:44 +0100 Subject: [PATCH 21/38] Remove extra --time --- scripts/install | 2 +- scripts/remove | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index b6283d6..6dd3a56 100644 --- a/scripts/install +++ b/scripts/install @@ -142,7 +142,7 @@ sleep 5 #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring SSOwat..." --time --weight=2 +ynh_script_progression --message="Configuring SSOwat..." --weight=2 # Make app public if necessary if [ $is_public -eq 1 ] diff --git a/scripts/remove b/scripts/remove index 5ea9661..f4aaac5 100644 --- a/scripts/remove +++ b/scripts/remove @@ -81,4 +81,4 @@ ynh_system_user_delete --username=$app # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --time --last +ynh_script_progression --message="Removal of $app completed" --last From 0952eeac47b8e1cbb655023289a288bf1e3409c7 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sun, 8 Nov 2020 17:20:10 +0100 Subject: [PATCH 22/38] Fix license identifier --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 05be5fc..6475faa 100644 --- a/manifest.json +++ b/manifest.json @@ -8,7 +8,7 @@ }, "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" From f4bf6d9fd8685ff7633726353734e99b1631407d Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sun, 8 Nov 2020 17:30:01 +0100 Subject: [PATCH 23/38] No need to alter permissions while upgrading --- scripts/upgrade | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 7485dd8..dd22913 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -105,18 +105,6 @@ 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" -#================================================= -# SETUP SSOWAT -#================================================= -ynh_script_progression --message="Upgrading SSOwat configuration..." --weight=1 - -# Make app public if necessary -if [ $is_public -eq 1 ] -then - # unprotected_uris allows SSO credentials to be passed anyway - ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" -fi - #================================================= # RELOAD NGINX #================================================= From 1232b3bc5a1c7ec9f7933ae2cf50f35b10960505 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sun, 8 Nov 2020 17:34:17 +0100 Subject: [PATCH 24/38] Embracing the future of permissions management MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Éric Gaspar <46165813+ericgaspar@users.noreply.github.com> --- scripts/install | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 6dd3a56..9666a9d 100644 --- a/scripts/install +++ b/scripts/install @@ -144,11 +144,12 @@ sleep 5 #================================================= ynh_script_progression --message="Configuring SSOwat..." --weight=2 -# Make app public if necessary +# Make app public if necessary or protect it if [ $is_public -eq 1 ] then - # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" + # Everyone can access the app. + # The "main" permission is automatically created before the install script. + ynh_permission_update --permission "main" --add "visitors" fi #================================================= From e0ed7b183ba54ea94700889bc40a4dc4a4015290 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sun, 8 Nov 2020 18:02:32 +0100 Subject: [PATCH 25/38] Silence service restoration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Éric Gaspar <46165813+ericgaspar@users.noreply.github.com> --- scripts/restore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/restore b/scripts/restore index e0fee5c..2943fc3 100644 --- a/scripts/restore +++ b/scripts/restore @@ -91,8 +91,8 @@ ynh_install_extra_app_dependencies --repo="https://repo.jellyfin.org/debian $( l #================================================= ynh_script_progression --message="Restoring the systemd configuration..." --weight=2 -ynh_restore_file --origin_path="/lib/systemd/system/jellyfin.service" -ynh_restore_file --origin_path="/etc/systemd/system/jellyfin.service.d" +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 #================================================= From 0f07898dbbbe9c715525172a3e79e818134066cd Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sun, 8 Nov 2020 18:13:51 +0100 Subject: [PATCH 26/38] Wait for the service starting up --- scripts/install | 8 +++----- scripts/restore | 2 +- scripts/upgrade | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/scripts/install b/scripts/install index 9666a9d..ec69321 100644 --- a/scripts/install +++ b/scripts/install @@ -92,9 +92,8 @@ ynh_system_user_create --username=$app # Load services once to generate system.xml systemctl enable jellyfin -systemctl start jellyfin -sleep 5 -systemctl stop jellyfin +ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app$(date "+%Y%m%d").log" --line_match="Startup complete" +ynh_systemd_action --service_name=$app --action="stop" # Port config ynh_replace_string --match_string="8096" --replace_string="$port" --target_file="/etc/jellyfin/system.xml" @@ -136,8 +135,7 @@ yunohost service add $app --description "Jellyfin media center" --log "/var/log/ ynh_script_progression --message="Starting a systemd service..." --weight=1 # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" -sleep 5 +ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app$(date "+%Y%m%d").log" --line_match="Startup complete" #================================================= # SETUP SSOWAT diff --git a/scripts/restore b/scripts/restore index 2943fc3..2b2ce8f 100644 --- a/scripts/restore +++ b/scripts/restore @@ -107,7 +107,7 @@ yunohost service add $app --description "Jellyfin media center" --log "/var/log/ #================================================= 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="start" --log_path="/var/log/$app/$app$(date "+%Y%m%d").log" --line_match="Startup complete" #================================================= # RESTORE THE LOGROTATE CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index dd22913..ff41401 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -103,7 +103,7 @@ yunohost service add $app --description "Jellyfin media center" --log "/var/log/ #================================================= 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="start" --log_path="/var/log/$app/$app$(date "+%Y%m%d").log" --line_match="Startup complete" #================================================= # RELOAD NGINX From 50a26572eeca592643b0c0bbf6de854dcf83b8c6 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sun, 8 Nov 2020 18:29:39 +0100 Subject: [PATCH 27/38] ynh_clean_check_starting since we monitor the logs Co-authored-by: Eric Gaspar <46165813+ericgaspar@users.noreply.github.com> --- scripts/install | 2 +- scripts/restore | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index ec69321..7fe9a64 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 diff --git a/scripts/restore b/scripts/restore index 2b2ce8f..87c6bcf 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 From 552ee2b03b38820f1bf2ed1cac0cdd3d986ec330 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sun, 8 Nov 2020 18:44:16 +0100 Subject: [PATCH 28/38] Monitor systemd instead of log file --- scripts/install | 4 ++-- scripts/restore | 6 +++--- scripts/upgrade | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/install b/scripts/install index 7fe9a64..004ff25 100644 --- a/scripts/install +++ b/scripts/install @@ -92,7 +92,7 @@ ynh_system_user_create --username=$app # Load services once to generate system.xml systemctl enable jellyfin -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app$(date "+%Y%m%d").log" --line_match="Startup complete" +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Startup complete" ynh_systemd_action --service_name=$app --action="stop" # Port config @@ -135,7 +135,7 @@ yunohost service add $app --description "Jellyfin media center" --log "/var/log/ ynh_script_progression --message="Starting a systemd service..." --weight=1 # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app$(date "+%Y%m%d").log" --line_match="Startup complete" +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Startup complete" #================================================= # SETUP SSOWAT diff --git a/scripts/restore b/scripts/restore index 87c6bcf..2e727af 100644 --- a/scripts/restore +++ b/scripts/restore @@ -91,8 +91,8 @@ ynh_install_extra_app_dependencies --repo="https://repo.jellyfin.org/debian $( l #================================================= ynh_script_progression --message="Restoring the systemd configuration..." --weight=2 -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 +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 #================================================= @@ -107,7 +107,7 @@ yunohost service add $app --description "Jellyfin media center" --log "/var/log/ #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app$(date "+%Y%m%d").log" --line_match="Startup complete" +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Startup complete" #================================================= # RESTORE THE LOGROTATE CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index ff41401..0e1dd4d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -103,7 +103,7 @@ yunohost service add $app --description "Jellyfin media center" --log "/var/log/ #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app$(date "+%Y%m%d").log" --line_match="Startup complete" +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Startup complete" #================================================= # RELOAD NGINX From f09dfe73e77002fb61913037073e691259aa6b5b Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sun, 8 Nov 2020 19:13:35 +0100 Subject: [PATCH 29/38] Reverting to manual startup of the service to init xml setting file --- scripts/install | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 004ff25..ac06e62 100644 --- a/scripts/install +++ b/scripts/install @@ -92,8 +92,9 @@ ynh_system_user_create --username=$app # Load services once to generate system.xml systemctl enable jellyfin -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Startup complete" -ynh_systemd_action --service_name=$app --action="stop" +systemctl start jellyfin +sleep 5 +systemctl stop jellyfin # Port config ynh_replace_string --match_string="8096" --replace_string="$port" --target_file="/etc/jellyfin/system.xml" From ed1cfe27473f7fe3f54e0b739fb7fe07ba8fed8f Mon Sep 17 00:00:00 2001 From: tituspijean Date: Mon, 9 Nov 2020 13:52:14 +0100 Subject: [PATCH 30/38] Restart service after restore --- scripts/restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/restore b/scripts/restore index 2e727af..c4c9987 100644 --- a/scripts/restore +++ b/scripts/restore @@ -107,7 +107,7 @@ yunohost service add $app --description "Jellyfin media center" --log "/var/log/ #================================================= 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" +ynh_systemd_action --service_name=$app --action="restart" --log_path="systemd" --line_match="Startup complete" #================================================= # RESTORE THE LOGROTATE CONFIGURATION From 44e8ff74ead1b58bcacebf091678a69b7467050e Mon Sep 17 00:00:00 2001 From: tituspijean Date: Mon, 9 Nov 2020 14:13:58 +0100 Subject: [PATCH 31/38] Cleanup and enhance check_process --- check_process | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/check_process b/check_process index 867eda5..04cbd6f 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" (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=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=0 - incorrect_path=1 + # 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 ;;; 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& From af595b747982617c2444c2232e8fbb8884af7055 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Mon, 9 Nov 2020 14:19:26 +0100 Subject: [PATCH 32/38] Add change_url --- check_process | 2 +- scripts/change_url | 129 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 scripts/change_url diff --git a/check_process b/check_process index 04cbd6f..9263eba 100644 --- a/check_process +++ b/check_process @@ -26,7 +26,7 @@ # 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 # If the level 5 (Package linter) is forced to 1. Please add justifications here. Level 5=auto diff --git a/scripts/change_url b/scripts/change_url new file mode 100644 index 0000000..28669c4 --- /dev/null +++ b/scripts/change_url @@ -0,0 +1,129 @@ +#!/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 + +#================================================= +# 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 +#================================================= +# ... +#================================================= + +#================================================= +# 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 From 069ae32a83df81323e0ba4695d4736fa76c6badc Mon Sep 17 00:00:00 2001 From: tituspijean Date: Mon, 9 Nov 2020 16:16:58 +0100 Subject: [PATCH 33/38] Load port in change_url --- scripts/change_url | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/change_url b/scripts/change_url index 28669c4..8845046 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -21,6 +21,8 @@ new_path=$YNH_APP_NEW_PATH app=$YNH_APP_INSTANCE_NAME +port=$(ynh_app_setting_get --app="$app" --key=port) + #================================================= # LOAD SETTINGS #================================================= From 5c519ec558ddb58cc7ac1ebf6c0bf98eedc987f1 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Mon, 9 Nov 2020 20:33:27 +0100 Subject: [PATCH 34/38] Change baseurl in change_url --- scripts/change_url | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/change_url b/scripts/change_url index 8845046..f824a53 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -105,9 +105,15 @@ fi #================================================= # SPECIFIC MODIFICATIONS #================================================= -# ... +# BASE URL #================================================= +# Change the path in system.xml config file +if [ $change_path -eq 1 ] +then + ynh_replace_string --match_string="$old_path" --replace_string="$new_path" --target_file="/etc/jellyfin/system.xml" +fi + #================================================= # GENERIC FINALISATION #================================================= From 6e4b91f34d6a1de910141c1718213c0caed7b09d Mon Sep 17 00:00:00 2001 From: tituspijean Date: Mon, 9 Nov 2020 20:34:10 +0100 Subject: [PATCH 35/38] Remove duplicate instruction in install --- scripts/install | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/install b/scripts/install index ac06e62..d1a8c02 100644 --- a/scripts/install +++ b/scripts/install @@ -102,9 +102,6 @@ ynh_replace_string --match_string="8096 Date: Tue, 10 Nov 2020 11:47:17 +0100 Subject: [PATCH 36/38] Fix change_url BaseUrl setting gets reverted to default if the wizard is not completed... --- scripts/change_url | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/change_url b/scripts/change_url index f824a53..845c04d 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -111,7 +111,12 @@ fi # Change the path in system.xml config file if [ $change_path -eq 1 ] then - ynh_replace_string --match_string="$old_path" --replace_string="$new_path" --target_file="/etc/jellyfin/system.xml" + # If the Startup Wizard was not complete, was reverted back to default when stopping the service + if grep -q "false" "/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 #================================================= From 58e8339ca355446116fafd8ac8e97c8ace9e4b8f Mon Sep 17 00:00:00 2001 From: tituspijean Date: Tue, 10 Nov 2020 14:50:59 +0100 Subject: [PATCH 37/38] Fix change_url Simpler is better --- scripts/change_url | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 845c04d..6abc645 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -111,8 +111,8 @@ fi # Change the path in system.xml config file if [ $change_path -eq 1 ] then - # If the Startup Wizard was not complete, was reverted back to default when stopping the service - if grep -q "false" "/etc/jellyfin/system.xml"; 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" From bd4932c47295ddc40b0d6f0c6c20ad6a3d738db8 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Tue, 10 Nov 2020 16:58:19 +0100 Subject: [PATCH 38/38] Small typos --- README.md | 7 +++++-- manifest.json | 12 ++++++------ scripts/_common.sh | 16 ++++++++++++++++ scripts/backup | 5 ----- scripts/change_url | 16 ++++++++-------- scripts/install | 6 +++--- scripts/remove | 4 ++-- scripts/restore | 2 +- scripts/upgrade | 6 +++--- 9 files changed, 44 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 63bd219..820524b 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,9 @@ [![Integration level](https://dash.yunohost.org/integration/jellyfin.svg)](https://dash.yunohost.org/appci/app/jellyfin) ![](https://ci-apps.yunohost.org/ci/badges/jellyfin.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/jellyfin.maintain.svg) [![Install Jellyfin with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](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. @@ -29,8 +32,8 @@ How to configure this app: From an admin panel, a plain file with SSH, or any ot #### Multi-user support - * Are LDAP and HTTP auth supported? - * Can the app be used by multiple users? + * Are LDAP and HTTP auth supported? **No** + * Can the app be used by multiple users? **Yes** #### Supported architectures diff --git a/manifest.json b/manifest.json index 6475faa..1292ae0 100644 --- a/manifest.json +++ b/manifest.json @@ -3,8 +3,8 @@ "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~ynh1", "url": "https://github.com/jellyfin/jellyfin", @@ -34,8 +34,8 @@ "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" @@ -44,8 +44,8 @@ "name": "is_public", "type": "boolean", "ask": { - "en": "Is it a public app?", - "fr": "Est-ce une app publique ?" + "en": "Is it a public application?", + "fr": "Est-ce une application publique ?" }, "default": true, "help": { diff --git a/scripts/_common.sh b/scripts/_common.sh index bd66acb..0e17ea6 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,3 +1,19 @@ #!/bin/bash +#================================================= +# COMMON VARIABLES +#================================================= + pkg_version="10.6.4-1" + +#================================================= +# PERSONAL HELPERS +#================================================= + +#================================================= +# EXPERIMENTAL HELPERS +#================================================= + +#================================================= +# FUTURE OFFICIAL HELPERS +#================================================= diff --git a/scripts/backup b/scripts/backup index c0119b2..2b24fb0 100644 --- a/scripts/backup +++ b/scripts/backup @@ -36,11 +36,6 @@ domain=$(ynh_app_setting_get --app="$app" --key=domain) #================================================= ynh_print_info --message="Declaring files to be backed up..." -### N.B. : the following 'ynh_backup' calls are only a *declaration* of what needs -### to be backuped and not an actual copy of any file. The actual backup that -### creates and fill the archive with the files happens in the core after this -### script is called. Hence ynh_backups calls takes basically 0 seconds to run. - #================================================= # BACKUP THE APP MAIN DIR #================================================= diff --git a/scripts/change_url b/scripts/change_url index 6abc645..03e8e62 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -34,7 +34,7 @@ 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 +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 @@ -76,23 +76,23 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating nginx web server configuration..." --weight=1 +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 +# 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 + # 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 + # Set global variables for NGINX helper domain="$old_domain" path_url="$new_path" - # Create a dedicated nginx config + # Create a dedicated NGINX config ynh_add_nginx_config fi -# Change the domain for nginx +# Change the domain for NGINX if [ $change_domain -eq 1 ] then # Delete file checksum for the old conf file location @@ -131,7 +131,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --l #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --weight=1 +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/install b/scripts/install index d1a8c02..82a5492 100644 --- a/scripts/install +++ b/scripts/install @@ -73,9 +73,9 @@ ynh_install_extra_app_dependencies --repo="https://repo.jellyfin.org/$( awk -F'= #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring nginx web server..." --weight=6 +ynh_script_progression --message="Configuring NGINX web server..." --weight=6 -# Create a dedicated nginx config +# Create a dedicated NGINX config ynh_add_nginx_config #================================================= @@ -151,7 +151,7 @@ fi #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --weight=2 +ynh_script_progression --message="Reloading NGINX web server..." --weight=2 ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/remove b/scripts/remove index f4aaac5..2fefac4 100644 --- a/scripts/remove +++ b/scripts/remove @@ -26,7 +26,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) # REMOVE SERVICE INTEGRATION IN YUNOHOST #================================================= -# Remove the service from the list of services known by Yunohost (added from `yunohost service add`) +# 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_script_progression --message="Removing $app service integration..." --weight=3 @@ -62,7 +62,7 @@ ynh_secure_remove --file="/var/lib/jellyfin" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Removing nginx web server configuration..." --weight=1 +ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 # Remove the dedicated nginx config ynh_remove_nginx_config diff --git a/scripts/restore b/scripts/restore index c4c9987..9f061d1 100644 --- a/scripts/restore +++ b/scripts/restore @@ -120,7 +120,7 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= # RELOAD NGINX AND PHP-FPM #================================================= -ynh_script_progression --message="Reloading nginx web server..." --weight=1 +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index 0e1dd4d..01d1fc4 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -53,9 +53,9 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=1 +ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 -# Create a dedicated nginx config +# Create a dedicated NGINX config ynh_add_nginx_config #================================================= @@ -108,7 +108,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --l #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --weight=1 +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload