From 502bb5e56882cfb2c9f1b20d6b0183212854a36e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 26 Feb 2021 01:34:32 +0100 Subject: [PATCH] ynh_add_config --- scripts/install | 23 +++-------------------- scripts/upgrade | 17 ++--------------- 2 files changed, 5 insertions(+), 35 deletions(-) diff --git a/scripts/install b/scripts/install index 4d50535..fb6832a 100644 --- a/scripts/install +++ b/scripts/install @@ -135,20 +135,7 @@ ynh_add_systemd_config --others_var="ynh_node ynh_node_load_PATH" #================================================= ynh_script_progression --message="Modifying a config file..." -config_file="$final_path/config.yml" -cp -f ../conf/config.sample.yml $config_file - -ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config_file" -ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$config_file" -ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$config_file" - -#================================================= -# STORE THE CONFIG FILE CHECKSUM -#================================================= -ynh_script_progression --message="Storing the config file checksum..." - -# Calculate and store the config file checksum into the app settings -ynh_store_file_checksum --file="$config_file" +ynh_add_config --template="../conf/config.sample.yml" --destination="$final_path/config.yml" #================================================= # GENERIC FINALIZATION @@ -200,12 +187,8 @@ ynh_systemd_action --service_name=nginx --action=reload #================================================= ynh_script_progression --message="Sending ReadMe to admin..." -ynh_replace_string --match_string="__LDAP_USER__" --replace_string="$ldap_user" --target_file="../conf/ldap_message" -ynh_replace_string --match_string="__LDAP_PASSWORD__" --replace_string="$ldap_password" --target_file="../conf/ldap_message" -ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="../conf/ldap_message" -ynh_replace_string --match_string="__PATH_URL__" --replace_string="$path_url" --target_file="../conf/ldap_message" - -ynh_send_readme_to_admin --app_message="../conf/ldap_message" --recipients="root" --type='install' +ynh_add_config --template="../conf/ldap_message" --destination="../conf/install" +ynh_send_readme_to_admin --app_message="../conf/install" --recipients="root" --type='install' #================================================= # END OF SCRIPT diff --git a/scripts/upgrade b/scripts/upgrade index 85c09d5..7a2fff6 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -154,16 +154,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= ynh_script_progression --message="Modifying a config file..." -config_file="$final_path/config.yml" -ynh_backup_if_checksum_is_different --file=$config_file -cp -f ../conf/config.sample.yml $config_file - -ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config_file" -ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$config_file" -ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$config_file" - -# Recalculate and store the checksum of the file for the next upgrade. -ynh_store_file_checksum --file="$config_file" +ynh_add_config --template="../conf/config.sample.yml" --destination="$final_path/config.yml" #================================================= # SETUP SYSTEMD @@ -209,11 +200,7 @@ ynh_systemd_action --service_name=nginx --action=reload #================================================= ynh_script_progression --message="Sending ReadMe to admin..." -ynh_replace_string --match_string="__LDAP_USER__" --replace_string="$ldap_user" --target_file="../conf/ldap_message" -ynh_replace_string --match_string="__LDAP_PASSWORD__" --replace_string="$ldap_password" --target_file="../conf/ldap_message" -ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="../conf/ldap_message" -ynh_replace_string --match_string="__PATH_URL__" --replace_string="$path_url" --target_file="../conf/ldap_message" - +ynh_add_config --template="../conf/ldap_message" --destination="../conf/upgrade" ynh_send_readme_to_admin --app_message="../conf/ldap_message" --recipients="root" --type='upgrade' #=================================================