From 499a52b1e0334e151141eea632e9bf4c2142e64f Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 14 Feb 2019 19:37:43 +0100 Subject: [PATCH] apply example_ynh on restore --- scripts/restore | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/scripts/restore b/scripts/restore index 388aad6..b52ca8b 100644 --- a/scripts/restore +++ b/scripts/restore @@ -19,6 +19,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= +ynh_print_info "Loading settings..." app=$YNH_APP_INSTANCE_NAME @@ -29,6 +30,7 @@ final_path=$(ynh_app_setting_get $app final_path) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= +ynh_print_info "Validating restoration parameters..." ynh_webpath_available $domain $path_url \ || ynh_die "Path not available: ${domain}${path_url}" @@ -42,29 +44,33 @@ test ! -d $final_path \ ynh_maintenance_mode_ON #================================================= -# STANDARD RESTORE STEPS +# STANDARD RESTORATION STEPS #================================================= -# RESTORE OF THE NGINX CONFIGURATION +# RESTORE THE NGINX CONFIGURATION #================================================= ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= -# RESTORE OF THE MAIN DIR OF THE APP +# RESTORE THE APP MAIN DIR #================================================= +ynh_print_info "Restore the app main directory..." ynh_restore_file "$final_path" #================================================= -# RECREATE OF THE DEDICATED USER +# RECREATE THE DEDICATED USER #================================================= +ynh_print_info "Recreate the dedicated systen user..." -ynh_system_user_create $app # Recreate the dedicated user, if not exist +# Create the dedicated user (if not existing) +ynh_system_user_create $app #================================================= # RESTORE USER RIGHTS #================================================= +# Restore permissions on app files chown -R $app:root $final_path #================================================= @@ -72,28 +78,32 @@ chown -R $app:root $final_path #================================================= # REINSTALL DEPENDENCIES #================================================= +ynh_print_info "Reinstall dependencies..." +# Define and install dependencies ynh_install_app_dependencies python-virtualenv sqlite3 zlib1g-dev -#================================================= -# ENABLE SERVICE IN ADMIN PANEL -#================================================= - -yunohost service add $app.service #================================================= # RESTORE SYSTEMD #================================================= +ynh_print_info "Restoring the systemd configuration..." ynh_restore_file "/etc/systemd/system/$app.service" -## Démarrage auto du service systemctl enable $app.service #================================================= -# GENERIC FINALISATION +# ADVERTISE SERVICE IN ADMIN PANEL +#================================================= + +yunohost service add $app --description "$app daemon for YunoRunner" + +#================================================= +# GENERIC FINALIZATION #================================================= # RELOAD NGINX #================================================= +ynh_print_info "Reloading nginx" ynh_system_reload --service_name=nginx @@ -108,3 +118,9 @@ ynh_system_reload --service_name=$app --action=start #================================================= ynh_maintenance_mode_OFF + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Restoration completed for $app"