From 2f366f7cbe0fa99205ba42a9f01c9d46e0de07be Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 3 Mar 2021 21:04:16 +0100 Subject: [PATCH] fix --- conf/config.yml | 2 +- scripts/install | 31 +++++++------------------------ scripts/upgrade | 19 +++++-------------- 3 files changed, 13 insertions(+), 39 deletions(-) diff --git a/conf/config.yml b/conf/config.yml index f24ddda..ba89482 100644 --- a/conf/config.yml +++ b/conf/config.yml @@ -3,7 +3,7 @@ feed_threads: 1 db: user: __DB_NAME__ - password: __DB_PASS__ + password: __DB_PWD__ host: localhost port: 5432 dbname: __DB_NAME__ diff --git a/scripts/install b/scripts/install index c828128..e226f21 100644 --- a/scripts/install +++ b/scripts/install @@ -48,7 +48,6 @@ ynh_script_progression --message="Storing installation settings..." --weight=2 ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url -ynh_app_setting_set --app=$app --key=is_public --value=$is_public ynh_app_setting_set --app=$app --key=language --value=$language #================================================= @@ -79,13 +78,9 @@ ynh_script_progression --message="Creating a PostgreSQL database..." --weight=2 db_name=$(ynh_sanitize_dbid --db_name=$app) db_user=$db_name -db_pwd=$(ynh_string_random --length=30) - ynh_app_setting_set --app=$app --key=db_name --value=$db_name -ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd - ynh_psql_test_if_first_run -ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd +ynh_psql_setup_db --db_user=$db_name --db_name=$db_name #================================================= # CREATE DEDICATED USER @@ -135,15 +130,7 @@ popd || ynh_die #================================================= ynh_script_progression --message="Modifying a config file..." -cp ../conf/config.yml "$final_path/config/config.yml" - -# Main config File -ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/config/config.yml" -ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="$final_path/config/config.yml" -#ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/config/config.yml" -ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/config/config.yml" -ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$final_path/config/config.yml" - +ynh_add_config --template="../conf/config.yml" --destination="$final_path/config/config.yml" ynh_store_file_checksum --file="$final_path/config/config.yml" #================================================= @@ -151,9 +138,6 @@ ynh_store_file_checksum --file="$final_path/config/config.yml" #================================================= ynh_script_progression --message="Configuring a systemd service..." --weight=1 -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__FINAL_PATH__" --replace_string="$final_path" --target_file="../conf/systemd.service" - ynh_add_systemd_config #================================================= @@ -161,8 +145,7 @@ ynh_add_systemd_config #================================================= ynh_script_progression --message="Setuping a cron..." --weight=1 -cp ../conf/cron_invidious /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_invidious" --destination="/etc/cron.d/$app" #================================================= # SETUP LOGROTATE @@ -180,7 +163,7 @@ ynh_use_logrotate ynh_script_progression --message="Securing files and directories..." --weight=1 # Set permissions to app files -chown -R $app: "$final_path" +chown -R $app: $final_path chmod 0644 /etc/logrotate.d/$app #================================================= @@ -196,17 +179,17 @@ yunohost service add $app --description="Invidious is an alternative front-end t ynh_script_progression --message="Starting a systemd service..." --weight=2 # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" +ynh_systemd_action --service_name=$app --action=start --log_path=systemd #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring SSOwat..." --weight=1 +ynh_script_progression --message="Configuring permissions..." --weight=1 # Make app public if necessary or protect it if [ $is_public -eq 1 ] then - ynh_permission_update --permission "main" --add "visitors" + ynh_permission_update --permission="main" --add="visitors" fi #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 775a170..c2c5863 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -18,13 +18,12 @@ app=$YNH_APP_INSTANCE_NAME 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) language=$(ynh_app_setting_get --app=$app --key=language) 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) +db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) #================================================= # CHECK VERSION @@ -54,7 +53,7 @@ ynh_abort_if_errors #================================================= ynh_script_progression --message="Stopping a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" +ynh_systemd_action --service_name=$app --action=stop --log_path=systemd #================================================= # UPGRADE DEPENDENCIES @@ -104,14 +103,9 @@ ynh_system_user_create --username=$app #================================================= ynh_script_progression --message="Modifying a config file..." --weight=3 -cp ../conf/config.yml "$final_path/config/config.yml" +ynh_backup_if_checksum_is_different --file="$final_path/config/config.yml" -# Main config File -ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/config/config.yml" -ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="$final_path/config/config.yml" -#ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/config/config.yml" -ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/config/config.yml" -ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$final_path/config/config.yml" +ynh_add_config --template="../conf/config.yml" --destination="$final_path/config/config.yml" ynh_store_file_checksum --file="$final_path/config/config.yml" @@ -120,9 +114,6 @@ ynh_store_file_checksum --file="$final_path/config/config.yml" #================================================= ynh_script_progression --message="Configuring a systemd service..." --weight=2 -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__FINAL_PATH__" --replace_string="$final_path" --target_file="../conf/systemd.service" - # Create a dedicated systemd config ynh_add_systemd_config @@ -157,7 +148,7 @@ yunohost service add $app --description="Invidious is an alternative front-end t #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="restart" --log_path="systemd" +ynh_systemd_action --service_name=$app --action=restart --log_path=systemd #================================================= # RELOAD NGINX