From 38c348291df5dff79415395991844b59a0388439 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 18 Aug 2021 19:20:42 +0200 Subject: [PATCH] Revert "Add_config" This reverts commit 51efcc260400b42b2ec5c98e616cc73bd5c71315. --- scripts/install | 16 ++++++++++++---- scripts/upgrade | 19 +++++++++++++++---- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/scripts/install b/scripts/install index df52b9d..d32dc12 100644 --- a/scripts/install +++ b/scripts/install @@ -124,11 +124,16 @@ ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name #================================================= # CONFIGURE ROUNDCUBE #================================================= -ynh_script_progression --message="Configuring Roundcube..." --weight=2 +ynh_script_progression --message="Configuring Roundcube..." -file="__FILE__" -deskey=$(ynh_string_random --length=24) -ynh_add_config --template="../conf/config.inc.php" --destination="$final_path/config/config.inc.php" +rc_conf="$final_path/config/config.inc.php" + +cp ../conf/config.inc.php "$rc_conf" + +ynh_replace_string --match_string="__DESKEY__" --replace_string="$(ynh_string_random --length=24)" --target_file="$rc_conf" +ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$rc_conf" +ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$rc_conf" +ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$rc_conf" #================================================= # INSTALL ADDITIONAL PLUGINS @@ -209,6 +214,9 @@ ynh_replace_string --match_string="^\s*// installed plugins" --replace_string="& (cd "$final_path" /usr/bin/php$phpversion -q ./bin/install-jsdeps.sh) +# Store the config file checksum into the app settings +ynh_store_file_checksum --file="$final_path/config/config.inc.php" + chmod 400 "$final_path/config/config.inc.php" chown $app:$app "$final_path/config/config.inc.php" diff --git a/scripts/upgrade b/scripts/upgrade index 93a7935..cd16af4 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -152,11 +152,19 @@ ynh_add_fpm_config --package="$extra_php_dependencies" if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Reconfiguring Roundcube..." --weight=3 + ynh_script_progression --message="Reconfiguring Roundcube..." - file="__FILE__" - deskey=$(ynh_string_random --length=24) - ynh_add_config --template="../conf/config.inc.php" --destination="$final_path/config/config.inc.php" + rc_conf="$final_path/config/config.inc.php" + + # Verify the checksum and backup the file if it's different + ynh_backup_if_checksum_is_different "$rc_conf" + + cp ../conf/config.inc.php "$rc_conf" + + ynh_replace_string --match_string="__DESKEY__" --replace_string="$(ynh_string_random --length=24)" --target_file="$rc_conf" + ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$rc_conf" + ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$rc_conf" + ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$rc_conf" #================================================= # UPDATE DEPENDENCIES WITH COMPOSER @@ -254,6 +262,9 @@ then (cd "$final_path" /usr/bin/php$phpversion -q ./bin/install-jsdeps.sh) + # Store the config file checksum into the app settings + ynh_store_file_checksum --file="$final_path/config/config.inc.php" + chmod 400 "$final_path/config/config.inc.php" chown $app:$app "$final_path/config/config.inc.php"