1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/yunorunner_ynh.git synced 2024-09-03 20:36:13 +02:00

apply example_ynh on restore

This commit is contained in:
yalh76 2019-02-14 19:37:43 +01:00
parent 942f0155c9
commit 499a52b1e0

View file

@ -19,6 +19,7 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_print_info "Loading settings..."
app=$YNH_APP_INSTANCE_NAME 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 # CHECK IF THE APP CAN BE RESTORED
#================================================= #=================================================
ynh_print_info "Validating restoration parameters..."
ynh_webpath_available $domain $path_url \ ynh_webpath_available $domain $path_url \
|| ynh_die "Path not available: ${domain}${path_url}" || ynh_die "Path not available: ${domain}${path_url}"
@ -42,29 +44,33 @@ test ! -d $final_path \
ynh_maintenance_mode_ON 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" 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" 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 USER RIGHTS
#================================================= #=================================================
# Restore permissions on app files
chown -R $app:root $final_path chown -R $app:root $final_path
#================================================= #=================================================
@ -72,28 +78,32 @@ chown -R $app:root $final_path
#================================================= #=================================================
# REINSTALL DEPENDENCIES # REINSTALL DEPENDENCIES
#================================================= #=================================================
ynh_print_info "Reinstall dependencies..."
# Define and install dependencies
ynh_install_app_dependencies python-virtualenv sqlite3 zlib1g-dev ynh_install_app_dependencies python-virtualenv sqlite3 zlib1g-dev
#=================================================
# ENABLE SERVICE IN ADMIN PANEL
#=================================================
yunohost service add $app.service
#================================================= #=================================================
# RESTORE SYSTEMD # RESTORE SYSTEMD
#================================================= #=================================================
ynh_print_info "Restoring the systemd configuration..."
ynh_restore_file "/etc/systemd/system/$app.service" ynh_restore_file "/etc/systemd/system/$app.service"
## Démarrage auto du service
systemctl enable $app.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 # RELOAD NGINX
#================================================= #=================================================
ynh_print_info "Reloading nginx"
ynh_system_reload --service_name=nginx ynh_system_reload --service_name=nginx
@ -108,3 +118,9 @@ ynh_system_reload --service_name=$app --action=start
#================================================= #=================================================
ynh_maintenance_mode_OFF ynh_maintenance_mode_OFF
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Restoration completed for $app"