From b390979455db5c2da063007c5563e367f1a225e5 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 28 Feb 2021 10:04:39 +0100 Subject: [PATCH] ynh_add_config --- scripts/change_url | 10 +++------- scripts/install | 17 +++-------------- scripts/upgrade | 7 +------ 3 files changed, 7 insertions(+), 27 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index f1f3711..75b45a9 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -96,6 +96,8 @@ then mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf # Store file checksum for the new config file location ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" + domain="$new_domain" + path_url="$new_path" fi #================================================= @@ -105,13 +107,7 @@ fi #================================================= ynh_script_progression --message="Updating Drush alias..." -drush_aliasconfig="$final_path/drush/sites/$app.site.yml" -cp -f "../conf/example.site.yml" "$drush_aliasconfig" - -ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$drush_aliasconfig" -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$drush_aliasconfig" -ynh_replace_string --match_string="__DOMAIN__" --replace_string="$new_domain" --target_file="$drush_aliasconfig" -ynh_replace_string --match_string="__PATH_URL__" --replace_string="$new_path" --target_file="$drush_aliasconfig" +ynh_add_config --template="../conf/example.site.yml" --destination="$final_path/drush/sites/$app.site.yml" #================================================= # GENERIC FINALISATION diff --git a/scripts/install b/scripts/install index b969e7c..735d63c 100644 --- a/scripts/install +++ b/scripts/install @@ -128,13 +128,7 @@ ynh_add_swap --size=$swap_needed ynh_script_progression --message="Creating Drush alias..." mkdir -p "$final_path/drush/sites/" -drush_aliasconfig="$final_path/drush/sites/$app.site.yml" -cp -f "../conf/example.site.yml" "$drush_aliasconfig" - -ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$drush_aliasconfig" -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$drush_aliasconfig" -ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$drush_aliasconfig" -ynh_replace_string --match_string="__PATH_URL__" --replace_string="$path_url" --target_file="$drush_aliasconfig" +ynh_add_config --template="../conf/example.site.yml" --destination="$final_path/drush/sites/$app.site.yml" #================================================= # INSTALL COMPOSER @@ -142,9 +136,7 @@ ynh_replace_string --match_string="__PATH_URL__" --replace_string="$path_url" -- ynh_script_progression --message="Installing Composer..." mkdir -p "$final_path/.composer" - -cp -f "../conf/composer.json" "$final_path/composer.json" -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$final_path/composer.json" +ynh_add_config --template="../conf/composer.json" --destination="$final_path/composer.json" ynh_install_composer --phpversion="$phpversion" --workdir="$final_path" @@ -170,10 +162,7 @@ update-alternatives --set php /usr/bin/php${YNH_DEFAULT_PHP_VERSION} #================================================= ynh_script_progression --message="Setuping the cron file..." -cp ../conf/cron /etc/cron.d/$app - -ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="/etc/cron.d/$app" -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="/etc/cron.d/$app" +ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app" #================================================= # STORE THE CONFIG FILE CHECKSUM diff --git a/scripts/upgrade b/scripts/upgrade index 0a96646..8ab49fe 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -144,12 +144,7 @@ ynh_store_file_checksum --file="$final_path/$app/sites/default/settings.php" #================================================= ynh_script_progression --message="Setuping the cron file" -cp -f ../conf/cron /etc/cron.d/$app - -ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="/etc/cron.d/$app" -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="/etc/cron.d/$app" - -ynh_systemd_action --service_name=cron --action=restart +ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app" #================================================= # GENERIC FINALIZATION