From 61ff69efe993e6e2a8eef37b24ad26527bf3146d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 14 Jul 2022 02:14:07 +0200 Subject: [PATCH] Apply example_ynh --- check_process | 10 +-- doc/DESCRIPTION.md | 1 + doc/DESCRIPTION_fr.md | 1 + manifest.json | 18 ++--- scripts/_common.sh | 27 ++++---- scripts/backup | 2 +- scripts/change_url | 10 +-- scripts/install | 50 +++++++------- scripts/remove | 56 +++++++-------- scripts/restore | 141 +++++++++++++++++++------------------- scripts/update_version.sh | 6 +- scripts/upgrade | 89 ++++++++++++------------ 12 files changed, 206 insertions(+), 205 deletions(-) create mode 100644 doc/DESCRIPTION.md create mode 100644 doc/DESCRIPTION_fr.md diff --git a/check_process b/check_process index f2acfeb..4c97cf6 100644 --- a/check_process +++ b/check_process @@ -1,12 +1,9 @@ -# See here for more information -# https://github.com/YunoHost/package_check#syntax-check_process-file - ;; Test complet ; Manifest domain="domain.tld" path="/path" - admin="john" is_public=1 + admin="john" discovery=1 ; Checks pkg_linter=1 @@ -16,6 +13,8 @@ setup_private=1 setup_public=1 upgrade=1 + # 10.8.0~ynh1 + upgrade=1 from_commit=384dcd2ff1dbf4b0085edb7f12e4d15f00508e2b backup_restore=1 multi_instance=0 port_already_use=0 @@ -23,6 +22,3 @@ ;;; Options Email= Notification=none -;;; Upgrade options -# ; commit= -# name= diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md new file mode 100644 index 0000000..4d782e2 --- /dev/null +++ b/doc/DESCRIPTION.md @@ -0,0 +1 @@ +Media System that manage and stream your media. diff --git a/doc/DESCRIPTION_fr.md b/doc/DESCRIPTION_fr.md new file mode 100644 index 0000000..dad30ec --- /dev/null +++ b/doc/DESCRIPTION_fr.md @@ -0,0 +1 @@ +Système multimédia qui gère et diffuse vos médias. diff --git a/manifest.json b/manifest.json index b126c30..3df61dc 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Media System that manage and stream your media.", "fr": "Système multimédia qui gère et diffuse vos médias." }, - "version": "10.8.0~ynh1", + "version": "10.8.0~ynh2", "url": "https://jellyfin.org", "upstream": { "license": "GPL-2.0-only", @@ -17,8 +17,8 @@ }, "license": "GPL-2.0-only", "maintainer": { - "name": "tituspijean", - "email": "tituspijean@outlook.com" + "name": "tituspijean", + "email": "tituspijean@outlook.com" }, "previous_maintainers": [ { @@ -27,14 +27,14 @@ } ], "requirements": { - "yunohost": ">=4.3" + "yunohost": ">= 4.3.0" }, "multi_instance": false, "services": [ "nginx" ], "arguments": { - "install" : [ + "install": [ { "name": "domain", "type": "domain" @@ -45,10 +45,6 @@ "example": "/jellyfin", "default": "/jellyfin" }, - { - "name": "admin", - "type": "user" - }, { "name": "is_public", "type": "boolean", @@ -58,6 +54,10 @@ "fr": "Jellyfin a son propre système de connexion, vous devriez la laisser publique pour permettre la connexion de clients externes (app mobile, etc.)." } }, + { + "name": "admin", + "type": "user" + }, { "name": "discovery", "type": "boolean", diff --git a/scripts/_common.sh b/scripts/_common.sh index ad67e18..0294178 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,15 +4,12 @@ # COMMON VARIABLES #================================================= -debian=$(lsb_release --codename --short) pkg_version="10.8.0-1" version=$(echo "$pkg_version" | cut -d '-' -f 1) ffmpeg_pkg_version="5.0.1-5" ldap_pkg_version="15.0.0.0" -architecture=$(dpkg --print-architecture) - discovery_service_port=1900 discovery_client_port=7359 @@ -43,12 +40,12 @@ ffmpeg_deps=( zlib1g ) -case "$debian" in +case "$(lsb_release --codename --short)" in buster) ffmpeg_deps+=( libvpx5 libx264-155 libx265-165 ) ;; bullseye) ffmpeg_deps+=( libvpx6 libx264-160 libx265-192 ) ;; - *) echo "Unknown release: $debian" >&2; exit 1 ;; + *) echo "Unknown release: $(lsb_release --codename --short)" >&2; exit 1 ;; esac -case "$architecture" in +case "$YNH_ARCH" in arm64) : ;; armhf) : ;; *) ffmpeg_deps+=( libdrm-intel1 libopencl1 ) ;; @@ -64,15 +61,15 @@ pkg_dependencies="${ffmpeg_deps[*]} ${jellyfin_deps[*]}" install_jellyfin_packages() { # In case of a new version, the url change from - # https://repo.jellyfin.org/releases/server/debian/versions/stable/server/X.X.X/jellyfin-server_X.X.X-1_$architecture.deb to - # https://repo.jellyfin.org/archive/debian/stable/X.X.X/server/jellyfin-server_X.X.X-1_$architecture.deb + # https://repo.jellyfin.org/releases/server/debian/versions/stable/server/X.X.X/jellyfin-server_X.X.X-1_$YNH_ARCH.deb to + # https://repo.jellyfin.org/archive/debian/stable/X.X.X/server/jellyfin-server_X.X.X-1_$YNH_ARCH.deb for pkg in web server; do - src_url=$(grep 'SOURCE_URL=' "$YNH_APP_BASEDIR/conf/$pkg.$debian.$architecture.src" | cut -d= -f2-) + src_url=$(grep 'SOURCE_URL=' "$YNH_APP_BASEDIR/conf/$pkg.$(lsb_release --codename --short).$YNH_ARCH.src" | cut -d= -f2-) if ! curl --output /dev/null --silent --head --fail "$src_url"; then ynh_replace_string \ --match_string="releases/server/debian/versions/stable/$pkg/$version/" \ --replace_string="archive/debian/stable/$version/$pkg/" \ - --target_file="$YNH_APP_BASEDIR/conf/$pkg.$debian.$architecture.src" + --target_file="$YNH_APP_BASEDIR/conf/$pkg.$(lsb_release --codename --short).$YNH_ARCH.src" fi done @@ -80,22 +77,22 @@ install_jellyfin_packages() { tempdir="$(mktemp -d)" # Download the deb files - ynh_setup_source --dest_dir=$tempdir --source_id="ffmpeg.$debian.$architecture" - ynh_setup_source --dest_dir=$tempdir --source_id="server.$debian.$architecture" - ynh_setup_source --dest_dir=$tempdir --source_id="web.$debian.$architecture" + ynh_setup_source --dest_dir=$tempdir --source_id="ffmpeg.$(lsb_release --codename --short).$YNH_ARCH" + ynh_setup_source --dest_dir=$tempdir --source_id="server.$(lsb_release --codename --short).$YNH_ARCH" + ynh_setup_source --dest_dir=$tempdir --source_id="web.$(lsb_release --codename --short).$YNH_ARCH" # Install the packages ynh_exec_warn_less dpkg --force-confdef --force-confnew -i $tempdir/jellyfin-ffmpeg5.deb ynh_exec_warn_less dpkg --force-confdef --force-confnew -i $tempdir/jellyfin-server.deb ynh_exec_warn_less dpkg --force-confdef --force-confnew -i $tempdir/jellyfin-web.deb - rm -rf "$tempdir" + ynh_secure_remove --file="$tempdir" # The doc says it should be called only once, # but the code says multiple calls are supported. # Also, they're already installed so that should be quasi instantaneous. ynh_install_app_dependencies \ - jellyfin-ffmpeg5="$ffmpeg_pkg_version-$debian" \ + jellyfin-ffmpeg5="$ffmpeg_pkg_version-$(lsb_release --codename --short)" \ jellyfin-server="$pkg_version" \ jellyfin-web="$pkg_version" } diff --git a/scripts/backup b/scripts/backup index 18038d9..41b31c9 100644 --- a/scripts/backup +++ b/scripts/backup @@ -15,7 +15,7 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - ynh_clean_check_starting + true } # Exit if an error occurs during the execution of the script ynh_abort_if_errors diff --git a/scripts/change_url b/scripts/change_url index b802be2..6f56cec 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -21,9 +21,6 @@ new_path=$YNH_APP_NEW_PATH app=$YNH_APP_INSTANCE_NAME -port=$(ynh_app_setting_get --app="$app" --key=port) -config_path=$(ynh_app_setting_get --app="$app" --key=config_path) - #================================================= # LOAD SETTINGS #================================================= @@ -32,14 +29,19 @@ 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) +# Add settings here as needed by your application +port=$(ynh_app_setting_get --app=$app --key=port) +config_path=$(ynh_app_setting_get --app=$app --key=config_path) + #================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +# BACKUP BEFORE CHANGE URL 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 () { + ynh_clean_check_starting # 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" diff --git a/scripts/install b/scripts/install index f18c9ed..f9a7819 100644 --- a/scripts/install +++ b/scripts/install @@ -25,8 +25,8 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH -admin=$YNH_APP_ARG_ADMIN is_public=$YNH_APP_ARG_IS_PUBLIC +admin=$YNH_APP_ARG_ADMIN discovery=$YNH_APP_ARG_DISCOVERY app=$YNH_APP_INSTANCE_NAME @@ -41,9 +41,8 @@ config_path=/etc/jellyfin test ! -e "$final_path" || ynh_die --message="There is already a directory: $final_path " test ! -e "$config_path" || ynh_die --message="There is already a directory: $config_path " -architecture=$(dpkg --print-architecture) -if [[ ! "$architecture" =~ ^(amd64|arm64|armhf)$ ]]; then - ynh_die "Jellyfin is not compatible with your architecture, $architecture, which is neither amd64, arm64, or armhf." 1 +if [[ ! "$YNH_ARCH" =~ ^(amd64|arm64|armhf)$ ]]; then + ynh_die "Jellyfin is not compatible with your architecture, $YNH_ARCH, which is neither amd64, arm64, or armhf." 1 fi # Register (book) web path @@ -105,21 +104,6 @@ ynh_script_progression --message="Installing dependencies..." --weight=5 ynh_install_app_dependencies $pkg_dependencies -#================================================= -# INSTALL PACKAGES -#================================================= -ynh_script_progression --message="Installing packages..." --weight=1 - -install_jellyfin_packages - -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Configuring NGINX web server..." --weight=6 - -# Create a dedicated NGINX config -ynh_add_nginx_config - #================================================= # CREATE DEDICATED USER #================================================= @@ -134,12 +118,28 @@ if grep -q "^render:" /etc/group; then fi #================================================= -# MODIFY A CONFIG FILE +# NGINX CONFIGURATION #================================================= -ynh_print_info --message="Waiting 30s to let Jellyfin fully start a first time..." -sleep 30 +ynh_script_progression --message="Configuring NGINX web server..." --weight=6 -ynh_script_progression --message="Configuring the settings..." --weight=1 +# Create a dedicated NGINX config +ynh_add_nginx_config + +#================================================= +# SPECIFIC SETUP +#================================================= +# INSTALL PACKAGES +#================================================= +ynh_script_progression --message="Installing packages..." --weight=1 + +install_jellyfin_packages + +#================================================= +# ADD A CONFIGURATION +#================================================= +ynh_script_progression --message="Adding a configuration file..." + +sleep 30 ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped Jellyfin Media Server" --timeout=15 @@ -166,8 +166,6 @@ ynh_multimedia_build_main_dir # Allow Jellyfin to write into these directories ynh_multimedia_addaccess $app -#================================================= -# GENERIC FINALIZATION #================================================= # SECURE FILES AND DIRECTORIES #================================================= @@ -177,6 +175,8 @@ ynh_script_progression --message="Securing files and directories..." chown -R $app: $final_path chown -R $app: $config_path +#================================================= +# GENERIC FINALIZATION #================================================= # SETUP LOGROTATE #================================================= diff --git a/scripts/remove b/scripts/remove index d00068e..aa16511 100644 --- a/scripts/remove +++ b/scripts/remove @@ -17,9 +17,9 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) discovery_client=$(ynh_app_setting_get --app=$app --key=discovery_client) discovery_service=$(ynh_app_setting_get --app=$app --key=discovery_service) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) config_path=$(ynh_app_setting_get --app=$app --key=config_path) #================================================= @@ -35,6 +35,22 @@ then yunohost service remove $app fi +#================================================= +# REMOVE LOGROTATE CONFIGURATION +#================================================= +ynh_script_progression --message="Removing logrotate configuration..." --weight=1 + +# Remove the app-specific logrotate config +ynh_remove_logrotate + +#================================================= +# REMOVE NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 + +# Remove the dedicated NGINX config +ynh_remove_nginx_config + #================================================= # REMOVE DEPENDENCIES #================================================= @@ -51,32 +67,6 @@ dpkg --remove jellyfin-web dpkg --remove jellyfin-server dpkg --remove jellyfin-ffmpeg5 -#================================================= -# REMOVE APP DIRECTORIES -#================================================= -ynh_script_progression --message="Removing app directories..." --weight=1 - -# Remove the app directory securely -ynh_secure_remove --file="$final_path" -ynh_secure_remove --file="$config_path" -ynh_secure_remove --file="/etc/systemd/system/jellyfin.service.d" - -#================================================= -# REMOVE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 - -# Remove the dedicated NGINX config -ynh_remove_nginx_config - -#================================================= -# REMOVE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Removing logrotate configuration..." --weight=1 - -# Remove the app-specific logrotate config -ynh_remove_logrotate - #================================================= # CLOSE A PORT #================================================= @@ -93,6 +83,18 @@ then ynh_exec_warn_less yunohost firewall disallow UDP 7359 fi +#================================================= +# SPECIFIC REMOVE +#================================================= +# REMOVE VARIOUS FILES +#================================================= +ynh_script_progression --message="Removing various files..." --weight=1 + +# Remove the app directory securely +ynh_secure_remove --file="$final_path" +ynh_secure_remove --file="$config_path" +ynh_secure_remove --file="/etc/systemd/system/jellyfin.service.d" + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/restore b/scripts/restore index fc05ad9..362b024 100644 --- a/scripts/restore +++ b/scripts/restore @@ -23,7 +23,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading settings..." --weight=1 +ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME @@ -43,13 +43,72 @@ test ! -d $final_path \ test ! -d $config_path \ || ynh_die --message="There is already a directory: $config_path " -architecture=$(dpkg --print-architecture) -if [[ ! "$architecture" =~ ^(amd64|arm64|armhf)$ ]]; then - ynh_die "Jellyfin is not compatible with your architecture, $architecture, which is neither amd64, arm64, or armhf." 1 +if [[ ! "$YNH_ARCH" =~ ^(amd64|arm64|armhf)$ ]]; then + ynh_die "Jellyfin is not compatible with your architecture, $YNH_ARCH, which is neither amd64, arm64, or armhf." 1 fi #================================================= # STANDARD RESTORATION STEPS +#================================================= +# RECREATE THE DEDICATED USER +#================================================= +ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 + +# Create the dedicated user (if not existing) +ynh_system_user_create --username=$app + +#================================================= +# RESTORE THE APP MAIN DIR +#================================================= +ynh_script_progression --message="Restoring the app main directory..." --weight=2 + +ynh_restore_file --origin_path="$final_path" +ynh_restore_file --origin_path="$config_path" +ynh_restore_file --origin_path="/etc/default/jellyfin" --not_mandatory + +#================================================= +# SPECIFIC RESTORATION +#================================================= +# REINSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Reinstalling dependencies..." --weight=5 + +# Define and install dependencies +ynh_install_app_dependencies $pkg_dependencies + +#================================================= +# REINSTALL PACKAGES +#================================================= +ynh_script_progression --message="Reinstalling packages..." --weight=7 + +install_jellyfin_packages + +#================================================= +# RESTORE THE NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring the NGINX web server configuration..." + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# RESTORE USER RIGHTS +#================================================= +ynh_script_progression --message="Restoring user rights..." + +# Restore permissions on app files +chown -R $app: $final_path +chown -R $app: $config_path + +#================================================= +# YUNOHOST MULTIMEDIA INTEGRATION +#================================================= +ynh_script_progression --message="Adding multimedia directories..." --weight=2 + +# Build YunoHost multimedia directories +ynh_multimedia_build_main_dir +# Allow Jellyfin to write into these directories +ynh_multimedia_addaccess $app + #================================================= # OPEN PORTS #================================================= @@ -80,47 +139,6 @@ fi ynh_app_setting_set --app=$app --key=discovery_service --value=$discovery_service ynh_app_setting_set --app=$app --key=discovery_client --value=$discovery_client -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the NGINX web server configuration..." - -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..." --weight=2 - -ynh_restore_file --origin_path="$final_path" -ynh_restore_file --origin_path="$config_path" -ynh_restore_file --origin_path="/etc/default/jellyfin" --not_mandatory - -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 - -# Create the dedicated user (if not existing) -ynh_system_user_create --username=$app - -#================================================= -# SPECIFIC RESTORATION -#================================================= -# REINSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Reinstalling dependencies..." --weight=5 - -# Define and install dependencies -ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# REINSTALL PACKAGES -#================================================= -ynh_script_progression --message="Reinstalling packages..." --weight=7 - -install_jellyfin_packages - #================================================= # RESTORE SYSTEMD #================================================= @@ -129,6 +147,13 @@ ynh_script_progression --message="Restoring the systemd configuration..." --weig ynh_restore_file --origin_path="/etc/systemd/system/jellyfin.service.d" --not_mandatory systemctl enable jellyfin.service --quiet +#================================================= +# RESTORE THE LOGROTATE CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1 + +ynh_restore_file --origin_path="/etc/logrotate.d/$app" + #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= @@ -142,22 +167,6 @@ needed_ports=() # Integrate service and require to expose the ports if needed yunohost service add $app --description="Jellyfin media center" ${needed_ports:+--needs_exposed_ports} "${needed_ports[@]}" -#================================================= -# RESTORE THE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the logrotate configuration..." --time --weight=1 - -ynh_restore_file --origin_path="/etc/logrotate.d/$app" - -#================================================= -# RESTORE USER RIGHTS -#================================================= -ynh_script_progression --message="Restoring user rights..." - -# Restore permissions on app files -chown -R $app: $final_path -chown -R $app: $config_path - #================================================= # START SYSTEMD SERVICE #================================================= @@ -165,16 +174,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="restart" --log_path="systemd" --line_match="Started Jellyfin Media Server" --timeout=15 -#================================================= -# YUNOHOST MULTIMEDIA INTEGRATION -#================================================= -ynh_script_progression --message="Adding multimedia directories..." --weight=2 - -# Build YunoHost multimedia directories -ynh_multimedia_build_main_dir -# Allow Jellyfin to write into these directories -ynh_multimedia_addaccess $app - #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/update_version.sh b/scripts/update_version.sh index 8b56568..c3a7f90 100755 --- a/scripts/update_version.sh +++ b/scripts/update_version.sh @@ -73,9 +73,9 @@ debians=("buster" "bullseye") architectures=("amd64" "arm64" "armhf") for debian in "${debians[@]}"; do for architecture in "${architectures[@]}"; do - prepare_source --template="../conf/ffmpeg.src.default" --destination="../conf/ffmpeg.$debian.$architecture.src" --architecture="$architecture" - prepare_source --template="../conf/web.src.default" --destination="../conf/web.$debian.$architecture.src" --architecture="$architecture" - prepare_source --template="../conf/server.src.default" --destination="../conf/server.$debian.$architecture.src" --architecture="$architecture" + prepare_source --template="../conf/ffmpeg.src.default" --destination="../conf/ffmpeg.$(lsb_release --codename --short).$YNH_ARCH.src" --architecture="$YNH_ARCH" + prepare_source --template="../conf/web.src.default" --destination="../conf/web.$(lsb_release --codename --short).$YNH_ARCH.src" --architecture="$YNH_ARCH" + prepare_source --template="../conf/server.src.default" --destination="../conf/server.$(lsb_release --codename --short).$YNH_ARCH.src" --architecture="$YNH_ARCH" done done diff --git a/scripts/upgrade b/scripts/upgrade index bf76cb7..a8c9261 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -15,6 +15,7 @@ source /usr/share/yunohost/helpers ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME + domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) admin=$(ynh_app_setting_get --app=$app --key=admin) @@ -30,14 +31,37 @@ ynh_script_progression --message="Checking version..." 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)..." --weight=3 + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + ynh_clean_check_starting + # Restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# STANDARD UPGRADE STEPS +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." --weight=1 + +ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped Jellyfin Media Server" --timeout=15 + #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 -architecture=$(dpkg --print-architecture) -if [[ ! "$architecture" =~ ^(amd64|arm64|armhf)$ ]]; then - ynh_die "Jellyfin is not compatible with your architecture, $architecture, which is neither amd64, arm64, or armhf." 1 +if [[ ! "$YNH_ARCH" =~ ^(amd64|arm64|armhf)$ ]]; then + ynh_die "Jellyfin is not compatible with your architecture, $YNH_ARCH, which is neither amd64, arm64, or armhf." 1 fi # If path keys do not exist, create them @@ -77,22 +101,6 @@ if [ ! -f "/etc/logrotate.d/$app" ]; then ynh_use_logrotate fi -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=3 - -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - # Restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# STANDARD UPGRADE STEPS #================================================= # OPEN PORTS #================================================= @@ -125,11 +133,19 @@ ynh_app_setting_set --app=$app --key=discovery_client --value=$discovery_client #================================================= -# STOP SYSTEMD SERVICE +# CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Stopping a systemd service..." --weight=1 +ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 -ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped Jellyfin Media Server" --timeout=15 +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app + +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_script_progression --message="Upgrading dependencies..." --weight=5 + +ynh_install_app_dependencies $pkg_dependencies #================================================= # NGINX CONFIGURATION @@ -140,31 +156,18 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." - ynh_add_nginx_config #================================================= -# UPGRADE DEPENDENCIES +# SPECIFIC UPGRADE #================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=5 - -ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# UPGRADE packages +# UPGRADE PACKAGES #================================================= ynh_script_progression --message="Upgrading packages..." --weight=3 install_jellyfin_packages #================================================= -# CREATE DEDICATED USER +# UPDATE A CONFIG FILE #================================================= -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 - -#================================================= -# MODIFY A CONFIG FILE -#================================================= -ynh_script_progression --message="Setting up configuration files..." --weight=2 +ynh_script_progression --message="Updating a configuration file..." --weight=2 # TODO: investigate if we can avoid overriding system.xml #ynh_add_config --template="system.xml" --destination="$config_path/system.xml" @@ -190,8 +193,6 @@ ynh_multimedia_build_main_dir # Allow Jellyfin to write into these directories ynh_multimedia_addaccess $app -#================================================= -# GENERIC FINALIZATION #================================================= # SECURE FILES AND DIRECTORIES #================================================= @@ -200,12 +201,14 @@ ynh_multimedia_addaccess $app chown -R $app: $final_path chown -R $app: $config_path +#================================================= +# GENERIC FINALIZATION #================================================= # SETUP LOGROTATE #================================================= -ynh_script_progression --message="Configuring log rotation..." --weight=1 +ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 -# Use logrotate to manage application logfile(s) +# Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --non-append #=================================================