diff --git a/scripts/install b/scripts/install index b97aaa4c..9e670425 100644 --- a/scripts/install +++ b/scripts/install @@ -97,7 +97,7 @@ ynh_setup_source --dest_dir="$final_path" chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R root:$app "$final_path" +chown -R $app:$app "$final_path" #================================================= # NGINX CONFIGURATION @@ -132,15 +132,7 @@ ynh_script_progression --message="Creating log file..." mkdir -p "/var/log/$app/" touch "/var/log/$app/${app}-horizon.log" -chown -R root: "/var/log/$app/" - -#================================================= -# SETUP SUPERVISOR -#================================================= -ynh_script_progression --message="Configuring a supervisor service..." - -# Create a dedicated supervisor config -ynh_add_supervisor_config --service="${app}-horizon" --template=horizon.conf --others_var="phpversion" +chown -R $app: "/var/log/$app/" #================================================= # ADD A CONFIGURATION @@ -152,6 +144,14 @@ ynh_add_config --template="../conf/.env" --destination="$final_path/.env" chmod 400 "$final_path/.env" chown $app:$app "$final_path/.env" +#================================================= +# SETUP SUPERVISOR +#================================================= +ynh_script_progression --message="Configuring a supervisor service..." + +# Create a dedicated supervisor config +ynh_add_supervisor_config --service="${app}-horizon" --template=horizon.conf --others_var="phpversion" + #================================================= # DEPLOY #================================================= diff --git a/scripts/restore b/scripts/restore index 9362db1b..7a928161 100644 --- a/scripts/restore +++ b/scripts/restore @@ -71,7 +71,7 @@ ynh_restore_file --origin_path="$final_path" chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R root:$app "$final_path" +chown -R $app:$app "$final_path" #================================================= # RESTORE THE PHP-FPM CONFIGURATION @@ -86,6 +86,22 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # SPECIFIC RESTORATION +#================================================= +# RESTORE THE CRON FILE +#================================================= +ynh_script_progression --message="Restoring the cron file..." + +ynh_restore_file --origin_path="/etc/cron.d/$app" + +#================================================= +# CREATE LOG FILE +#================================================= +ynh_script_progression --message="Creating log file..." + +mkdir -p "/var/log/$app/" +touch "/var/log/$app/${app}-horizon.log" +chown -R $app: "/var/log/$app/" + #================================================= # REINSTALL DEPENDENCIES #================================================= @@ -101,31 +117,8 @@ ynh_script_progression --message="Restoring the PostgreSQL database..." db_pwd=$(ynh_app_setting_get --app=$app --key=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_execute_file_as_root --file="./db.sql" --database="$db_name" - -#================================================= -# RESTORE THE CRON FILE -#================================================= -ynh_script_progression --message="Restoring the cron file..." - -ynh_restore_file --origin_path="/etc/cron.d/$app" - -#================================================= -# CREATE LOG FILE -#================================================= -ynh_script_progression --message="Creating log file..." - -mkdir -p "/var/log/$app/" -touch "/var/log/$app/${app}-horizon.log" -chown -R root: "/var/log/$app/" - -#================================================= -# RESTORE THE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the logrotate configuration..." - -ynh_restore_file --origin_path="/etc/logrotate.d/$app" +ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd +ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name #================================================= # RESTORE SUPERVISOR CONFIGURATION @@ -149,6 +142,13 @@ ynh_script_progression --message="Starting a supervisor service..." ynh_supervisor_action --service_name="${app}-horizon" --action="reload" --log_path="systemd" --line_match="success: ${app}-horizon" +#================================================= +# RESTORE THE LOGROTATE CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring the logrotate configuration..." + +ynh_restore_file --origin_path="/etc/logrotate.d/$app" + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 409dc33d..4530c849 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -93,7 +93,7 @@ if dpkg --compare-versions "0.10.9~ynh2" gt "$(ynh_read_manifest --manifest="/et ynh_script_progression --message="Creating log file..." mkdir -p "/var/log/$app/" touch "/var/log/$app/${app}-horizon.log" - chown -R root: "/var/log/$app/" + chown -R $app: "/var/log/$app/" ynh_script_progression --message="Configuring a supervisor service..." phpversion=$YNH_PHP_VERSION @@ -147,7 +147,7 @@ fi chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R root:$app "$final_path" +chown -R $app:$app "$final_path" #================================================= # NGINX CONFIGURATION @@ -223,7 +223,7 @@ ynh_script_progression --message="Creating log file..." mkdir -p "/var/log/$app/" touch "/var/log/$app/${app}-horizon.log" -chown -R root: "/var/log/$app/" +chown -R $app: "/var/log/$app/" #================================================= # UPGRADE THE CRON FILE