mirror of
https://github.com/YunoHost-Apps/searx_ynh.git
synced 2024-09-03 20:16:30 +02:00
112 lines
3.8 KiB
Bash
Executable file
112 lines
3.8 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC STARTING
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source ../settings/scripts/_common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# MANAGE SCRIPT FAILURE
|
|
#=================================================
|
|
|
|
ynh_clean_setup () {
|
|
ynh_clean_check_starting
|
|
}
|
|
# Exit if an error occurs during the execution of the script
|
|
ynh_abort_if_errors
|
|
|
|
#=================================================
|
|
# LOAD SETTINGS
|
|
#=================================================
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
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
|
|
#=================================================
|
|
ynh_script_progression --message="Validating restoration parameters..." --weight=2
|
|
|
|
ynh_webpath_available --domain=$domain --path_url=$path_url \
|
|
|| ynh_die --message="Path not available: ${domain}${path_url}"
|
|
test ! -d $final_path \
|
|
|| ynh_die --message="There is already a directory: $final_path "
|
|
|
|
#=================================================
|
|
# STANDARD RESTORE STEPS
|
|
#=================================================
|
|
# RESTORE OF THE NGINX CONFIGURATION
|
|
#=================================================
|
|
|
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
|
|
#=================================================
|
|
# RESTORE OF THE MAIN DIR OF THE APP
|
|
#=================================================
|
|
ynh_script_progression --message="Restoring the app main directory..."
|
|
|
|
mkdir -p "$(dirname "$final_path")"
|
|
ynh_restore_file --origin_path="$final_path"
|
|
|
|
#=================================================
|
|
# INSTALL DEPENDENCIES
|
|
#=================================================
|
|
ynh_script_progression --message="Reinstalling dependencies..." --weight=35
|
|
|
|
ynh_install_app_dependencies $pkg_dependencies
|
|
|
|
#=================================================
|
|
# 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
|
|
|
|
#=================================================
|
|
# SPECIFIC RESTORE
|
|
#=================================================
|
|
# RESTORE USER RIGHTS
|
|
#=================================================
|
|
|
|
chown $app: --recursive "$final_path"
|
|
|
|
#=================================================
|
|
# RESTORE THE UWSGI CONFIG
|
|
#=================================================
|
|
|
|
ynh_restore_file --origin_path="/etc/uwsgi/apps-available/$app.ini"
|
|
ynh_restore_file --origin_path "/var/log/uwsgi/$app"
|
|
chown $app:root /var/log/uwsgi/$app
|
|
ynh_check_global_uwsgi_config
|
|
systemctl enable "uwsgi-app@$app.service"
|
|
|
|
#=================================================
|
|
# GENERIC FINALISATION
|
|
#=================================================
|
|
# RELOAD NGINX
|
|
#=================================================
|
|
ynh_script_progression --message="Reloading nginx web server..."
|
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
|
|
|
#=================================================
|
|
# CHECK SEARX STARTING
|
|
#=================================================
|
|
ynh_script_progression --message="Starting Searx..." --weight=4
|
|
|
|
# Wait for searx to be fully started
|
|
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"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Restoration completed for $app" --last
|