From 748a3288f4eae8ad9888f58e4f2fc729a04b9912 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 19 Feb 2020 22:38:00 +0100 Subject: [PATCH] Upgrade script cleanup --- scripts/upgrade | 94 ++++++++++--------------------------------------- 1 file changed, 18 insertions(+), 76 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 81c0f89..e4c05a1 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -28,6 +28,7 @@ port=$(ynh_app_setting_get --app=$app --key=port) #================================================= # CHECK VERSION #================================================= +ynh_print_info --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) @@ -83,21 +84,6 @@ if ynh_version_gt "0.45-3" "${previous_version}" ; then yunohost service add $app fi -if ynh_version_gt "0.77-2" "${previous_version}" ; then - ynh_print_info --message="Upgrading to 0.77-2..." - ynh_install_nodejs --nodejs_version="8.9.3" - ynh_use_nodejs - - # Create a dedicated systemd config - ynh_replace_string --match_string="__NODEJS__" --replace_string="$nodejs_use_version" --target_file="../conf/systemd.service" - ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" - ynh_replace_string --match_string="__DB_NAME__" --replace_string="$app" --target_file="../conf/systemd.service" - ynh_replace_string --match_string="__URI__" --replace_string="$path_url/" --target_file="../conf/systemd.service" - ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/systemd.service" - ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="../conf/systemd.service" - ynh_add_systemd_config -fi - if ynh_version_gt "1.07~ynh2" "${previous_version}" ; then ynh_print_info --message="Upgrading to 1.07~ynh2..." @@ -108,67 +94,6 @@ if ynh_version_gt "1.07~ynh2" "${previous_version}" ; then ynh_install_app_dependencies "mongodb mongodb-server" yunohost service remove mongod yunohost service add mongodb --log "/var/log/mongodb/mongodb.log" - - # Gotta regen the systemd config because mongodb service name changed - ynh_use_nodejs - ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" - ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="../conf/systemd.service" - ynh_replace_string --match_string="__DOMAIN_URI__" --replace_string="$domain$path_url" --target_file="../conf/systemd.service" - ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/systemd.service" - ynh_add_systemd_config -fi - -if ynh_version_gt "2.48~ynh1" "${previous_version}" ; then - ynh_print_info --message="Upgrading to 2.48~ynh1..." - # Install dependencies - ynh_remove_nodejs - ynh_install_nodejs --nodejs_version="8.16.0" - ynh_use_nodejs - - # Create a dedicated systemd config - ynh_replace_string --match_string="__NODEJS_PATH__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" - ynh_add_systemd_config - - # Create a dedicated .env config - config_file="$final_path/.env" - ynh_backup_if_checksum_is_different --file="$config_file" - cp "../conf/.env" "$config_file" - ynh_replace_string --match_string="__NODEJS_PATH__" --replace_string="$nodejs_path" --target_file="$config_file" - ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$config_file" - ynh_replace_string --match_string="__DOMAIN_URI__" --replace_string="$domain$path_url" --target_file="$config_file" - ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config_file" - ynh_store_file_checksum "$config_file" -fi - -if ynh_version_gt "3.55~ynh1" "${previous_version}" ; then - ynh_print_info --message="Upgrading to 3.55~ynh1..." - # Install dependencies - ynh_remove_nodejs - ynh_install_nodejs --nodejs_version=$nodejsversion - ynh_use_nodejs - - # Create a dedicated systemd config - ynh_replace_string --match_string="__NODEJS_PATH__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" - ynh_add_systemd_config - - # Create a dedicated .env config - config_file="$final_path/.env" - ynh_backup_if_checksum_is_different --file="$config_file" - cp "../conf/.env" "$config_file" - ynh_replace_string --match_string="__NODEJS_PATH__" --replace_string="$nodejs_path" --target_file="$config_file" - ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$config_file" - ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$config_file" - ynh_replace_string --match_string="__DOMAIN_URI__" --replace_string="$domain$path_url" --target_file="$config_file" - ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config_file" - ynh_store_file_checksum "$config_file" -fi - -if ynh_version_gt "3.79~ynh1" "${previous_version}" ; then - ynh_print_info --message="Upgrading to 3.79~ynh1..." - # Install dependencies - ynh_remove_nodejs - ynh_install_nodejs --nodejs_version=$nodejsversion - ynh_use_nodejs fi #================================================= @@ -228,6 +153,7 @@ ynh_add_nginx_config #================================================= ynh_print_info --message="Upgrading dependencies..." +ynh_remove_nodejs ynh_install_nodejs --nodejs_version=$nodejsversion ynh_use_nodejs @@ -241,6 +167,22 @@ ynh_print_info --message="Making sure dedicated system user exists..." # Create a dedicated user (if not existing) ynh_system_user_create --username=$app --home_dir="$final_path" +#================================================= +# MODIFY A CONFIG FILE +#================================================= +ynh_print_info --message="Modifying a config file..." + +# Create a dedicated .env config +config_file="$final_path/.env" +ynh_backup_if_checksum_is_different --file="$config_file" +cp "../conf/.env" "$config_file" +ynh_replace_string --match_string="__NODEJS_PATH__" --replace_string="$nodejs_path" --target_file="$config_file" +ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$config_file" +ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$config_file" +ynh_replace_string --match_string="__DOMAIN_URI__" --replace_string="$domain$path_url" --target_file="$config_file" +ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config_file" +ynh_store_file_checksum "$config_file" + #================================================= # SETUP SYSTEMD #=================================================