diff --git a/scripts/change_url b/scripts/change_url index 5fe0855..cd80a3b 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -27,10 +27,16 @@ app=$YNH_APP_INSTANCE_NAME ynh_script_progression --message="Loading installation settings..." --weight=1 # Needed for helper "ynh_add_nginx_config" -final_path=$(ynh_app_setting_get --app=$app --key=final_path) +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) +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 #================================================= @@ -102,6 +108,22 @@ 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..." + +# 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" +ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/config.json.example" + +cp ../conf/config.json.example "$final_path/config.json" + #================================================= # GENERIC FINALISATION #=================================================