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

113 lines
3.9 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
2019-05-18 20:15:36 +02:00
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
2019-05-18 20:15:36 +02:00
ynh_script_progression --message="Validating restoration parameters..." --weight=2
2016-05-07 18:21:06 +02:00
2019-05-18 20:15:36 +02:00
ynh_webpath_available --domain=$domain --path_url=$path_url \
|| ynh_die --message="Path not available: ${domain}${path_url}"
test ! -d $final_path \
2019-05-18 20:15:36 +02:00
|| ynh_die --message="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
2019-05-18 20:15:36 +02:00
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
2016-05-07 18:21:06 +02:00
2021-03-21 23:13:21 +01:00
#=================================================
# RECREATE OF THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=3
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app
#=================================================
# RESTORE OF THE MAIN DIR OF THE APP
#=================================================
2020-12-19 23:34:40 +01:00
ynh_script_progression --message="Restoring the app main directory..." --weight=2
2016-05-07 18:21:06 +02:00
2019-03-03 20:32:26 +01:00
mkdir -p "$(dirname "$final_path")"
2019-05-18 20:15:36 +02:00
ynh_restore_file --origin_path="$final_path"
2016-05-07 18:21:06 +02:00
#=================================================
# INSTALL DEPENDENCIES
#=================================================
2019-05-18 20:15:36 +02:00
ynh_script_progression --message="Reinstalling dependencies..." --weight=35
2016-05-07 18:21:06 +02:00
2019-04-13 00:38:47 +02:00
ynh_install_app_dependencies $pkg_dependencies
2016-05-07 18:21:06 +02:00
#=================================================
# SPECIFIC RESTORE
#=================================================
# RESTORE USER RIGHTS
#=================================================
2020-09-19 16:47:18 +02:00
chown -R $app: "$final_path"
#=================================================
# RESTORE THE UWSGI CONFIG
#=================================================
2019-05-18 20:15:36 +02:00
ynh_restore_file --origin_path="/etc/uwsgi/apps-available/$app.ini"
2020-04-10 22:02:55 +02:00
ynh_restore_file --origin_path "/var/log/uwsgi/$app"
chown $app:root /var/log/uwsgi/$app
ynh_check_global_uwsgi_config
2020-12-19 19:29:38 +01:00
systemctl enable "uwsgi-app@$app.service" --quiet
2016-07-04 21:16:34 +02:00
#=================================================
# GENERIC FINALISATION
#=================================================
2018-05-11 22:59:18 +02:00
# RELOAD NGINX
#=================================================
2020-12-19 23:34:40 +01:00
ynh_script_progression --message="Reloading NGINX web server..." --weight=2
2016-05-07 18:21:06 +02:00
2019-05-18 20:15:36 +02:00
ynh_systemd_action --service_name=nginx --action=reload
2018-05-11 22:59:18 +02:00
#=================================================
# CHECK SEARX STARTING
#=================================================
2019-05-18 20:15:36 +02:00
ynh_script_progression --message="Starting Searx..." --weight=4
2018-05-11 22:59:18 +02:00
# Wait for searx to be fully started
2020-04-10 22:02:55 +02:00
ynh_systemd_action --service_name=uwsgi-app@$app.service --action=start --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
#=================================================
2020-09-20 18:31:15 +02:00
ynh_script_progression --message="Restoration completed for Searx" --last