1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/wekan_ynh.git synced 2024-09-03 20:36:09 +02:00

Upgrade script cleanup

This commit is contained in:
yalh76 2020-02-19 22:38:00 +01:00
parent b715bb29e7
commit 748a3288f4

View file

@ -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
#=================================================