From 8a905103f3719336ab67be3510c3de7a37533bfe Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Mon, 10 Jul 2023 08:30:57 +0200 Subject: [PATCH] Update restore --- scripts/restore | 55 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/scripts/restore b/scripts/restore index d2b5d13..3de4d56 100755 --- a/scripts/restore +++ b/scripts/restore @@ -10,6 +10,26 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers +#================================================= +# STANDARD RESTORATION STEPS +#================================================= +# RESTORE LOGROTATE +#================================================= +ynh_script_progression --message="Configuring logrotate to manage application logfiles" --weight=1 + +# Use logrotate to manage application logfile(s) +ynh_use_logrotate --specific_user=$app +touch /var/log/$app/$app.log +chown -R $app:www-data /var/log/$app/ + +#================================================= +# RESTORE THE NGINX CONFIGURATION +#================================================= + +ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1 + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" + #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -17,34 +37,37 @@ ynh_script_progression --message="Restoring the app main directory..." --weight= ynh_restore_file --origin_path="$install_dir" -chmod 750 "$install_dir" -chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" +chown -R $app: "$install_dir" #================================================= -# RESTORE SYSTEM CONFIGURATIONS +# RESTORE SYSTEMD #================================================= -# RESTORE THE PHP-FPM CONFIGURATION +ynh_script_progression --message="Restoring the systemd configuration..." --weight=1 + +ynh_restore_file --origin_path="/etc/systemd/system/${app}.service" + +systemctl enable "${app}.service" --quiet + #================================================= -ynh_script_progression --message="Restoring system configurations related to $app..." --weight=5 +# INTEGRATE SERVICE IN YUNOHOST +#================================================= +ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +yunohost service add "${app}" --description="Fittrackee main service" --log="/var/log/$app/$app.log" -ynh_restore_file --origin_path="/etc/systemd/system/$app.service" -systemctl enable $app.service --quiet +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --weight=1 -yunohost service add $app --description="Machine Translation API" --log="/var/log/$app/$app.log" - -ynh_restore_file --origin_path="/etc/logrotate.d/$app" +ynh_systemd_action --service_name="${app}" --action="start" #================================================= # GENERIC FINALIZATION #================================================= -# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE +# RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 - -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload