1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/searx_ynh.git synced 2024-09-03 20:16:30 +02:00
searx_ynh/scripts/restore

110 lines
3.5 KiB
Text
Raw Normal View History

2016-05-07 18:21:06 +02:00
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
2016-07-04 21:16:34 +02:00
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
2016-05-07 18:21:06 +02:00
2018-05-28 00:30:42 +02:00
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
2019-03-03 20:32:26 +01:00
ynh_clean_setup () {
ynh_clean_check_starting
}
2018-05-28 00:30:42 +02:00
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
2016-05-07 18:21:06 +02:00
app=$YNH_APP_INSTANCE_NAME
2016-05-07 18:21:06 +02:00
domain=$(ynh_app_setting_get $app domain)
path_url=$(ynh_app_setting_get $app path)
2019-03-03 20:32:26 +01:00
final_path=$(ynh_app_setting_get $app final_path)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
2019-03-03 20:33:02 +01:00
ynh_print_info "Validating restoration parameters..."
2016-05-07 18:21:06 +02:00
2017-08-28 03:03:36 +02:00
ynh_webpath_available $domain $path_url \
|| ynh_die "Path not available: ${domain}${path_url}"
test ! -d $final_path \
|| ynh_die "There is already a directory: $final_path "
2016-05-07 18:21:06 +02:00
#=================================================
# STANDARD RESTORE STEPS
#=================================================
# RESTORE OF THE NGINX CONFIGURATION
#=================================================
2016-05-07 18:21:06 +02:00
2017-06-13 15:47:47 +02:00
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
2016-05-07 18:21:06 +02:00
#=================================================
# RESTORE OF THE MAIN DIR OF THE APP
#=================================================
2019-03-03 20:33:02 +01:00
ynh_print_info "Restoring the app main directory..."
2016-05-07 18:21:06 +02:00
2019-03-03 20:32:26 +01:00
mkdir -p "$(dirname "$final_path")"
2017-06-13 15:47:47 +02:00
ynh_restore_file "$final_path"
2016-05-07 18:21:06 +02:00
#=================================================
# INSTALL DEPENDENCIES
#=================================================
2019-03-03 20:33:02 +01:00
ynh_print_info "Reinstalling dependencies..."
2016-05-07 18:21:06 +02:00
2018-06-28 18:20:07 +02:00
ynh_install_app_dependencies git build-essential libxslt-dev python-dev python-virtualenv virtualenv python-babel zlib1g-dev libffi-dev libssl-dev python-lxml uwsgi uwsgi-plugin-python
2016-05-07 18:21:06 +02:00
#=================================================
# RECREATE OF THE DEDICATED USER
#=================================================
2019-03-03 20:33:02 +01:00
ynh_print_info "Recreating the dedicated system user..."
2017-08-28 03:03:36 +02:00
# Create the dedicated user (if not existing)
ynh_system_user_create $app
#=================================================
# SPECIFIC RESTORE
#=================================================
# RESTORE USER RIGHTS
#=================================================
2017-08-28 03:03:36 +02:00
chown $app: --recursive "$final_path"
#=================================================
# RESTORE THE UWSGI CONFIG
#=================================================
2017-06-13 15:47:47 +02:00
ynh_restore_file "/etc/uwsgi/apps-available/$app.ini"
2017-08-28 03:03:36 +02:00
ln -s /etc/uwsgi/apps-available/$app.ini /etc/uwsgi/apps-enabled/$app.ini
2016-07-04 21:16:34 +02:00
#=================================================
# GENERIC FINALISATION
#=================================================
2018-05-11 22:59:18 +02:00
# RELOAD NGINX
#=================================================
2019-03-03 20:33:02 +01:00
ynh_print_info "Reloading nginx web server..."
2016-05-07 18:21:06 +02:00
2017-08-28 03:03:36 +02:00
systemctl reload nginx
2018-05-11 22:59:18 +02:00
#=================================================
# CHECK SEARX STARTING
#=================================================
2019-03-03 20:33:02 +01:00
ynh_print_info "Starting Searx..."
2018-05-11 22:59:18 +02:00
# Wait for searx to be fully started
2019-03-03 20:32:26 +01:00
ynh_systemd_action --service_name=uwsgi --action=restart --line_match="spawned uWSGI master process" --log_path="/var/log/uwsgi/app/$app.log"
2019-03-03 20:33:02 +01:00
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Restoration completed for $app"