From d3cbffb86c88c8706c6c9e51f103421aa891a103 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sun, 24 May 2020 22:50:23 +0200 Subject: [PATCH] checksum if the config has been modified --- scripts/install | 7 +++++-- scripts/upgrade | 24 +++++++++++++++++++++++- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index e1ef0e3..144104d 100644 --- a/scripts/install +++ b/scripts/install @@ -116,14 +116,17 @@ ynh_replace_string --match_string="__PATH__" --replace_string="${path_url:1 ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="../conf/config.json.example" ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="../conf/config.json.example" ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="../conf/config.json.example" -cp ../conf/config.json.example "$final_path"/config.json + +cp ../conf/config.json.example "$final_path/config.json" + ynh_store_file_checksum "$final_path/config.json" # DB Config File ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="../conf/.sequelizerc.example" ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="../conf/.sequelizerc.example" ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="../conf/.sequelizerc.example" -cp ../conf/.sequelizerc.example "$final_path"/.sequelizerc + +cp ../conf/.sequelizerc.example "$final_path/.sequelizerc" #============================================== # INSTALL CODIMD diff --git a/scripts/upgrade b/scripts/upgrade index 1787967..5861b01 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -80,6 +80,28 @@ then fi +#================================================= +# SPECIFIC UPGRADE +#================================================= +# MODIFY A CONFIG FILE +#================================================= +ynh_script_progression --message="Modifying a config file..." --weight=2 + +ynh_backup_if_checksum_is_different --file="$final_path/config.json" + +# Main config File +ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__PATH__" --replace_string="${path_url:1}" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="../conf/config.json.example" + +cp ../conf/config.json.example "$final_path/config.json" + +# Recalculate and store the checksum of the file for the next upgrade. +ynh_store_file_checksum --file="$final_path/config.json" + #================================================= # NGINX CONFIGURATION #================================================= @@ -96,7 +118,7 @@ ynh_script_progression --message="Upgrading dependencies..." --weight=18 # Install Yarn ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" -ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version +ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version" ynh_install_app_dependencies $pkg_dependencies