From 0f074c1f07ca5d1cc20a6ccee6dc9e9284223609 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 9 Mar 2021 15:38:39 +0100 Subject: [PATCH] Testing (#20) * Preserve config file on upgrade --- README.md | 2 +- README_fr.md | 2 +- manifest.json | 2 +- scripts/install | 7 ++----- scripts/upgrade | 31 ++++++++++++------------------- 5 files changed, 17 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 87b1b10..895209d 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ You can also configure Simple Torrent by editing this file `/var/www/simple-torr ## Documentation * Official documentation: https://github.com/boypt/simple-torrent/wiki - * YunoHost documentation: https://yunohost.org/#/app_simple-torrent + * YunoHost documentation: https://yunohost.org/en/app_simple-torrent ## YunoHost specific features diff --git a/README_fr.md b/README_fr.md index 1ec3c80..a486232 100644 --- a/README_fr.md +++ b/README_fr.md @@ -27,7 +27,7 @@ Vous pouvez configurer Simple Torrent en modifiant le fichier `/var/www/simple-t ## Documentation * Documentation officielle : https://github.com/boypt/simple-torrent/wiki - * Documentation YunoHost : https://yunohost.org/#/app_simple-torrent_fr + * Documentation YunoHost : https://yunohost.org/fr/app_simple-torrent ## Caractéristiques spécifiques YunoHost diff --git a/manifest.json b/manifest.json index 3d8326e..74b6383 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Self-hosted remote torrent client", "fr": "Client torrent distant auto-hébergé" }, - "version": "1.2.15~ynh1", + "version": "1.2.15~ynh2", "url": "https://github.com/boypt/simple-torrent", "license": "AGPL-3.0-only", "maintainer": { diff --git a/scripts/install b/scripts/install index 325f2ce..e5730cd 100644 --- a/scripts/install +++ b/scripts/install @@ -43,9 +43,8 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= 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 -ynh_app_setting_set --app=$app --key=is_public --value=$is_public +ynh_app_setting_set --app=$app --key=domain --value=$domain +ynh_app_setting_set --app=$app --key=path --value=$path_url #================================================= # STANDARD MODIFICATIONS @@ -119,8 +118,6 @@ ynh_store_file_checksum --file="$final_path/config.json" #================================================= ynh_script_progression --message="Configuring a systemd service..." --weight=1 -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="../conf/systemd.service" ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/systemd.service" ynh_add_systemd_config diff --git a/scripts/upgrade b/scripts/upgrade index 549a8dc..546983a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -18,7 +18,6 @@ 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) peer_port=$(ynh_app_setting_get --app=$app --key=peer_port) @@ -52,7 +51,7 @@ ynh_abort_if_errors #================================================= ynh_script_progression --message="Stopping a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" +ynh_systemd_action --service_name=$app --action=stop --log_path=systemd #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -61,7 +60,12 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." --weight=5 + + tmpdir="$(mktemp -d)" + # Backup the config file in the temp dir + cp -a "$final_path/config.json" "$tmpdir/config.json" + # Remove the app directory securely ynh_secure_remove --file=$final_path @@ -71,6 +75,12 @@ then gzip --decompress $(ynh_detect_arch).gz mv $(ynh_detect_arch) $app popd + + # Copy the admin saved settings from tmp directory to final path + cp -a "$tmpdir/config.json" "$final_path/config.json" + + # Remove the tmp directory securely + ynh_secure_remove --file="$tmpdir" fi #================================================= @@ -89,28 +99,11 @@ 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 -#================================================= -ynh_script_progression --message="Modifying a config file..." --weight=1 - -ynh_backup_if_checksum_is_different --file="$final_path/config.json" - -cp ../conf/config.default.json "$final_path/config.json" - -# Main config File -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$final_path/config.json" -ynh_replace_string --match_string="__PEER_PORT__" --replace_string="$peer_port" --target_file="$final_path/config.json" - -ynh_store_file_checksum --file="$final_path/config.json" - #================================================= # SETUP SYSTEMD #================================================= ynh_script_progression --message="Configuring a systemd service..." --weight=2 -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="../conf/systemd.service" ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/systemd.service" ynh_add_systemd_config