From b6eb640e489d228ce828e6a167859f4bef07608d Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 11 Dec 2021 10:17:19 +0100 Subject: [PATCH] Fix --- scripts/change_url | 10 +++++----- scripts/install | 22 ++++++++-------------- scripts/restore | 6 ++++-- scripts/upgrade | 4 +++- 4 files changed, 20 insertions(+), 22 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 0fa1db68..a2666e11 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -64,9 +64,9 @@ fi #================================================= # STOP SUPERVISOR SERVICE #================================================= -ynh_script_progression --message="Stopping a supervisor service..." +ynh_script_progression --message="Stopping a systemd service..." -ynh_supervisor_action --service_name="${app}-horizon" --action="stop" --log_path="/var/log/$app/${app}-horizon.log" +ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" #================================================= # MODIFY URL IN NGINX CONF @@ -118,11 +118,11 @@ popd #================================================= # GENERIC FINALISATION #================================================= -# START SUPERVISOR SERVICE +# START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a supervisor service..." +ynh_script_progression --message="Starting a systemd service..." -ynh_supervisor_action --service_name="${app}-horizon" --action="start" --log_path="systemd" --line_match="success: ${app}-horizon" +ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" #================================================= # RELOAD NGINX diff --git a/scripts/install b/scripts/install index d0bc8ac9..1f1a056f 100644 --- a/scripts/install +++ b/scripts/install @@ -26,8 +26,7 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url="/" is_public=$YNH_APP_ARG_IS_PUBLIC -app_key=$(ynh_string_random --length=32 | base64) -app_key="base64:$app_key" +app_key="base64:$(ynh_string_random --length=32 | base64)" app=$YNH_APP_INSTANCE_NAME @@ -73,22 +72,17 @@ ynh_system_user_create --username=$app --home_dir=$final_path #================================================= ynh_script_progression --message="Creating a PostgreSQL database..." -ynh_psql_test_if_first_run - db_name=$(ynh_sanitize_dbid --db_name=$app) db_user=$db_name -db_pwd=$(ynh_string_random --length=32) ynh_app_setting_set --app=$app --key=db_name --value=$db_name -ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd - -# Initialize database and store postgres password for upgrade -ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd +ynh_psql_test_if_first_run +ynh_psql_setup_db --db_user=$db_name --db_name=$db_name #================================================= # CONFIGURE REDIS DATABASE #================================================= +ynh_script_progression --message="Creating a Redis database..." -# Configure redis redis_db=$(ynh_redis_get_free_db) ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db" @@ -187,6 +181,8 @@ popd ynh_script_progression --message="Installing the cron file..." ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app" +chown root: "/etc/cron.d/$app" +chmod 644 "/etc/cron.d/$app" #================================================= # GENERIC FINALIZATION @@ -206,9 +202,9 @@ ynh_script_progression --message="Integrating service in YunoHost..." yunohost service add $app --description="Ethical photo sharing platform" --log="/var/log/$app/$app.log" #================================================= -# START SUPERVISOR SERVICE +# START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting $app service..." +ynh_script_progression --message="Starting systemd service..." # Start a supervisor service ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" @@ -221,8 +217,6 @@ ynh_script_progression --message="Configuring permissions..." # Make app public if necessary if [ $is_public -eq 1 ] then - # Everyone can access the app. - # The "main" permission is automatically created before the install script. ynh_permission_update --permission="main" --add="visitors" fi diff --git a/scripts/restore b/scripts/restore index 5bf4110d..05f6220e 100644 --- a/scripts/restore +++ b/scripts/restore @@ -134,9 +134,9 @@ ynh_script_progression --message="Integrating service in YunoHost..." yunohost service add $app --description="Ethical photo sharing platform" --log="/var/log/$app/$app.log" #================================================= -# START SUPERVISOR SERVICE +# START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a supervisor service..." +ynh_script_progression --message="Starting a systemd service..." ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" @@ -146,6 +146,8 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" ynh_script_progression --message="Restoring the logrotate configuration..." ynh_restore_file --origin_path="/etc/logrotate.d/$app" +chown root: "/etc/cron.d/$app" +chmod 644 "/etc/cron.d/$app" #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index 3b098dab..61c10556 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -201,6 +201,8 @@ chown -R $app: "/var/log/$app/" ynh_script_progression --message="Upgrading cron file..." ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app" +chown root: "/etc/cron.d/$app" +chmod 644 "/etc/cron.d/$app" #================================================= # SETUP SUPERVISOR @@ -228,7 +230,7 @@ ynh_script_progression --message="Integrating service in YunoHost..." yunohost service add $app --description="Ethical photo sharing platform" --log="/var/log/$app/$app.log" #================================================= -# START SUPERVISOR SERVICE +# START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..."