From 32ec7d8a7dca13a7347f3d9800704ccac7ab5515 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 8 Mar 2022 02:02:52 +0100 Subject: [PATCH] Apply example_ynh --- .gitignore | 2 -- README.md | 2 +- README_fr.md | 2 +- check_process | 4 ++-- conf/amd64.src | 4 ++-- conf/arm64.src | 4 ++-- conf/armhf.src | 4 ++-- conf/nginx.conf | 6 +++--- manifest.json | 2 +- scripts/backup | 3 --- scripts/change_url | 11 +++++++---- scripts/install | 12 ++++++------ scripts/remove | 16 ++++++++-------- scripts/restore | 23 +++++++++++------------ scripts/upgrade | 9 +++------ sources/extra_files/app/.gitignore | 2 -- sources/patches/.gitignore | 2 -- 17 files changed, 49 insertions(+), 59 deletions(-) delete mode 100644 .gitignore delete mode 100644 sources/extra_files/app/.gitignore delete mode 100644 sources/patches/.gitignore diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 783a4ae..0000000 --- a/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*~ -*.sw[op] diff --git a/README.md b/README.md index 928a26b..8655a3d 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in API support for your favorite torrent trackers -**Shipped version:** 0.20.53~ynh1 +**Shipped version:** 0.20.671~ynh1 **Demo:** https://github.com/Jackett/Jackett diff --git a/README_fr.md b/README_fr.md index 856441b..f0f59d9 100644 --- a/README_fr.md +++ b/README_fr.md @@ -13,7 +13,7 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour API pour vos trackers torrent préférés -**Version incluse :** 0.20.53~ynh1 +**Version incluse :** 0.20.671~ynh1 **Démo :** https://github.com/Jackett/Jackett diff --git a/check_process b/check_process index de4d7c4..e1f84bf 100644 --- a/check_process +++ b/check_process @@ -14,6 +14,7 @@ upgrade=1 from_commit=CommitHash backup_restore=1 multi_instance=1 + port_already_use=0 change_url=1 ;;; Options Email= @@ -21,5 +22,4 @@ Notification=none ;;; Upgrade options ; commit=CommitHash name=Name and date of the commit. - manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666& - + manifest_arg=domain=DOMAIN&path=PATH&is_public=1&language=fr&admin=USER&password=pass&port=666& diff --git a/conf/amd64.src b/conf/amd64.src index 1cdea48..1ce5ba4 100644 --- a/conf/amd64.src +++ b/conf/amd64.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/Jackett/Jackett/releases/download/v0.20.53/Jackett.Binaries.LinuxAMDx64.tar.gz -SOURCE_SUM=ea6283621b5c1a61dc4613b27261d010bf959520db530939767a4be8e925f5dd +SOURCE_URL=https://github.com/Jackett/Jackett/releases/download/v0.20.671/Jackett.Binaries.LinuxAMDx64.tar.gz +SOURCE_SUM=8c8d5f46e62903870170cece561d3961c62a07c0217f47c60f3a189c8849f0c4 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/conf/arm64.src b/conf/arm64.src index 103b3d4..32f77af 100644 --- a/conf/arm64.src +++ b/conf/arm64.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/Jackett/Jackett/releases/download/v0.20.53/Jackett.Binaries.LinuxARM64.tar.gz -SOURCE_SUM=aa51da64c79511901bf40c552c198a3046c61309cc2495795f8b7087893acd52 +SOURCE_URL=https://github.com/Jackett/Jackett/releases/download/v0.20.671/Jackett.Binaries.LinuxARM64.tar.gz +SOURCE_SUM=a4ad6e3f892fa9fdd510c5f34a13ad138fc1a8e470c6eca7b597a2eb814286cd SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/conf/armhf.src b/conf/armhf.src index d2a0697..82836ed 100644 --- a/conf/armhf.src +++ b/conf/armhf.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/Jackett/Jackett/releases/download/v0.20.53/Jackett.Binaries.LinuxARM32.tar.gz -SOURCE_SUM=77197e9a617664a1950534154de3d057c9c9e04bab6ef7f1d1c917c541ed8643 +SOURCE_URL=https://github.com/Jackett/Jackett/releases/download/v0.20.671/Jackett.Binaries.LinuxARM32.tar.gz +SOURCE_SUM=b493d6be6e49698f20a8e6f0a2cf49ce7dfab2340676662781c26dc863bfd0fa SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/conf/nginx.conf b/conf/nginx.conf index 35e5861..44a6625 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,7 +1,7 @@ #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; -location __PATH__ { +location __PATH__/ { - proxy_pass http://127.0.0.1:9117; + proxy_pass http://127.0.0.1:__PORT__; 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; @@ -16,4 +16,4 @@ location __PATH__ { # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; -} \ No newline at end of file +} diff --git a/manifest.json b/manifest.json index 8746673..9d86c9d 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "API support for your favorite torrent trackers", "fr": "API pour vos trackers torrent préférés" }, - "version": "0.20.53~ynh1", + "version": "0.20.671~ynh1", "url": "https://github.com/Jackett/Jackett", "upstream": { "license": "GPL-2.0", diff --git a/scripts/backup b/scripts/backup index 401c0ef..f78c623 100755 --- a/scripts/backup +++ b/scripts/backup @@ -15,7 +15,6 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - ### Remove this function if there's nothing to clean before calling the remove script. true } # Exit if an error occurs during the execution of the script @@ -30,8 +29,6 @@ app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) domain=$(ynh_app_setting_get --app=$app --key=domain) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP diff --git a/scripts/change_url b/scripts/change_url index 6779d86..515e1b4 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -28,7 +28,7 @@ ynh_script_progression --message="Loading installation settings..." # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get --app=$app --key=final_path) -app_port=$()ynh_app_setting_get --app=$app --key=port) +port=$(ynh_app_setting_get --app=$app --key=port) #================================================= # BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP @@ -38,6 +38,7 @@ ynh_script_progression --message="Backing up the app before changing its URL (ma # 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" @@ -87,9 +88,10 @@ then # Set global variables for NGINX helper domain="$old_domain" path_url="$new_path" - port="$app_port" - match_string=$(echo \"BasePathOverride\": \"$old_path\") - target_string=$(echo \"BasePathOverride\": \"$new_path\") + old_path_no_root=${old_path%/} + new_path_no_root=${new_path%/} + match_string=$(echo \"BasePathOverride\": \"$old_path_no_root\") + target_string=$(echo \"BasePathOverride\": \"$new_path_no_root\") sed --in-place "s@${match_string}@${target_string}@g" "$final_path/.config/Jackett/ServerConfig.json" # Create a dedicated NGINX config ynh_add_nginx_config @@ -112,6 +114,7 @@ fi #================================================= ynh_script_progression --message="Starting a systemd service..." +# Start a systemd service ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" #================================================= diff --git a/scripts/install b/scripts/install index fa8292c..1946225 100755 --- a/scripts/install +++ b/scripts/install @@ -13,6 +13,9 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + ynh_clean_check_starting +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -30,7 +33,6 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= - ynh_script_progression --message="Validating installation parameters..." final_path=/opt/yunohost/$app @@ -77,15 +79,13 @@ ynh_setup_source --dest_dir="$final_path" --source_id="$architecture" chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R $app: $final_path +chown -R $app: "$final_path" #================================================= # NGINX CONFIGURATION #================================================= ynh_script_progression --message="Configuring NGINX web server..." -### `ynh_add_nginx_config` will use the file conf/nginx.conf - # Create a dedicated NGINX config ynh_add_nginx_config @@ -95,7 +95,6 @@ ynh_add_nginx_config ynh_script_progression --message="Configuring a systemd service..." # Create a dedicated systemd config -ynh_replace_string --match_string=__PORT__ --replace_string="$port" --target_file="../conf/systemd.service" ynh_add_systemd_config #================================================= @@ -108,7 +107,8 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --l # Start a systemd service ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" -target_string=$(echo \"BasePathOverride\": \"$path_url\") +path_no_root=${path_url%/} +target_string=$(echo \"BasePathOverride\": \"$path_no_root\") sed --in-place "s@\"BasePathOverride\": null@${target_string}@g" "$final_path/.config/Jackett/ServerConfig.json" #================================================= diff --git a/scripts/remove b/scripts/remove index 35a0cb0..634b34f 100755 --- a/scripts/remove +++ b/scripts/remove @@ -41,6 +41,14 @@ ynh_script_progression --message="Stopping and removing the systemd service..." # Remove the dedicated systemd config ynh_remove_systemd_config +#================================================= +# REMOVE LOGROTATE CONFIGURATION +#================================================= +ynh_script_progression --message="Removing logrotate configuration..." + +# Remove the app-specific logrotate config +ynh_remove_logrotate + #================================================= # REMOVE APP MAIN DIR #================================================= @@ -57,14 +65,6 @@ ynh_script_progression --message="Removing NGINX web server configuration..." # Remove the dedicated NGINX config ynh_remove_nginx_config -#================================================= -# REMOVE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Removing logrotate configuration..." - -# Remove the app-specific logrotate config -ynh_remove_logrotate - #================================================= # SPECIFIC REMOVE #================================================= diff --git a/scripts/restore b/scripts/restore index 533d23f..3716a1c 100755 --- a/scripts/restore +++ b/scripts/restore @@ -15,8 +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 @@ -45,7 +44,7 @@ test ! -d $final_path \ #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Restoring 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" @@ -83,6 +82,13 @@ ynh_script_progression --message="Restoring the systemd configuration..." ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service --quiet +#================================================= +# RESTORE THE LOGROTATE CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring the logrotate configuration..." + +ynh_restore_file --origin_path="/etc/logrotate.d/$app" + #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= @@ -97,19 +103,12 @@ ynh_script_progression --message="Starting a systemd service..." ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" -#================================================= -# RESTORE THE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the logrotate configuration..." - -ynh_restore_file --origin_path="/etc/logrotate.d/$app" - #================================================= # GENERIC FINALIZATION #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server" +ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload @@ -117,4 +116,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" --last +ynh_script_progression --message="Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index 2de53f2..53f61a5 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -24,6 +24,7 @@ architecture=$YNH_ARCH #================================================= # CHECK VERSION #================================================= +ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) @@ -35,6 +36,7 @@ ynh_script_progression --message="Backing up the app before upgrading (may take # 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 } @@ -62,11 +64,6 @@ if ynh_legacy_permissions_exists; then ynh_app_setting_delete --app=$app --key=is_public fi -if ! ynh_permission_exists --permission="admin"; then - # Create the required permissions - ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin -fi - # Create a permission if needed if ! ynh_permission_exists --permission="api"; then ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --show_tile="false" --protected="true" @@ -147,4 +144,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" diff --git a/sources/extra_files/app/.gitignore b/sources/extra_files/app/.gitignore deleted file mode 100644 index 783a4ae..0000000 --- a/sources/extra_files/app/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*~ -*.sw[op] diff --git a/sources/patches/.gitignore b/sources/patches/.gitignore deleted file mode 100644 index 783a4ae..0000000 --- a/sources/patches/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*~ -*.sw[op]