From d02d6841b6ad01008e30a37b9eab441364625c7b Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Tue, 12 Jan 2021 09:29:18 +0100 Subject: [PATCH] Update change_url --- scripts/change_url | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 1cea7e4..7c7cd57 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -31,9 +31,9 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) port=$(ynh_app_setting_get --app=$app --key=port) # Add settings here as needed by your application -#db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#db_user=$db_name -#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) +db_user=$db_name +db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP @@ -106,6 +106,27 @@ then ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" fi +#================================================= +# MODIFY A CONFIG FILE +#================================================= +ynh_script_progression --message="Modifying a config file..." --weight=3 + +cp ../conf/config.json $final_path/config/config.json + +# Main config File +ynh_replace_string --match_string="__URL__" --replace_string="https://$new_domain$new_path" --target_file="$final_path/config/config.json" +ynh_replace_string --match_string="__PORT__" --replace_string="127.0.0.1:$port" --target_file="$final_path/config/config.json" +ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/config/config.json" +ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$final_path/config/config.json" +ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="$final_path/config/config.json" +ynh_replace_string --match_string="__DATA__" --replace_string="$data_path" --target_file="$final_path/config/config.json" +ynh_replace_string --match_string="__FEEDBACK__" --replace_string="no-reply@${new_domain}" --target_file="$final_path/config/config.json" +ynh_replace_string --match_string="__USER_PW__" --replace_string="$(ynh_string_random --length=24)" --target_file="$final_path/config/config.json" +ynh_replace_string --match_string="__LOG__" --replace_string="$logs_path" --target_file="$final_path/config/config.json" +ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$final_path/config/config.json" + +ynh_store_file_checksum --file="$final_path/config/config.json" + #================================================= # GENERIC FINALISATION #================================================= @@ -113,7 +134,7 @@ fi #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=3 -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started Mattermost" +ynh_systemd_action --service_name=$app --action=start --log_path="systemd" --line_match="Started Mattermost" #================================================= # RELOAD NGINX