Update to last example_ynh

This commit is contained in:
yalh76
2019-02-11 06:05:30 +01:00
parent e4df144713
commit a329419716
11 changed files with 183 additions and 87 deletions

View File

@@ -24,6 +24,7 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info "Load settings"
app=$YNH_APP_INSTANCE_NAME
@@ -53,21 +54,14 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_print_info "Restore the app main directory"
ynh_restore_file "$final_path"
#=================================================
# RESTORE THE POSTGRESQL DATABASE
#=================================================
ynh_install_app_dependencies postgresql postgresql-contrib
ynh_psql_test_if_first_run
ynh_psql_create_db "$db_name" "$db_name" "$db_pwd"
ynh_psql_execute_file_as_root ./db.sql "$db_name"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_print_info "Recreate the dedicated user"
# Create the dedicated user (if not existing)
ynh_system_user_create "$app" "$final_path"
@@ -83,13 +77,14 @@ chown -R "$app":"$app" "$final_path"
# RESTORE THE PHP-FPM CONFIGURATION
#=================================================
#ynh_restore_file "/etc/php5/fpm/pool.d/$app.conf"
#ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf"
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_print_info "Reinstall dependencies"
# Define and install dependencies
@@ -100,9 +95,19 @@ ynh_install_nodejs 10
ynh_install_app_dependencies redis-server postgresql postgresql-contrib yarn
#=================================================
# RESTORE THE POSTGRESQL DATABASE
#=================================================
ynh_print_info "Restore the postgresql database"
ynh_psql_test_if_first_run
ynh_psql_create_db "$db_name" "$db_name" "$db_pwd"
ynh_psql_execute_file_as_root ./db.sql "$db_name"
#=================================================
# RESTORE SYSTEMD
#=================================================
ynh_print_info "Restore the systemd configuration"
ynh_restore_file "/etc/systemd/system/$app.service"
systemctl enable $app.service
@@ -131,8 +136,9 @@ ynh_restore_file "/etc/logrotate.d/$app"
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
ynh_print_info "Reload nginx and php-fpm"
#systemctl reload php5-fpm
#systemctl reload php7.0-fpm
systemctl reload nginx
#=================================================
@@ -147,3 +153,9 @@ chown -R "$app":"$app" "/var/log/$app"
#=================================================
ynh_systemd_action --action=start --service_name=$app --line_match="Redis connection:"
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Restoration completed"