1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/simple-torrent_ynh.git synced 2024-09-03 20:26:18 +02:00

Preserver config file (#19)

* Preserve config file on upgrade
This commit is contained in:
Éric Gaspar 2021-03-09 12:18:12 +01:00 committed by GitHub
parent 9d0c48e947
commit f96151b260
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 27 deletions

View file

@ -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

View file

@ -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

View file

@ -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": {

View file

@ -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

View file

@ -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