searx_ynh/scripts/restore

94 lines
2.9 KiB
Plaintext
Raw Normal View History

2016-05-07 18:21:06 +02:00
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# MANAGE FAILURE OF THE SCRIPT
#=================================================
2016-05-07 18:21:06 +02:00
# Exit on command errors and treat unset variables as an error
set -eu
2016-05-07 18:21:06 +02:00
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
2016-07-04 21:16:34 +02:00
2017-08-28 03:03:36 +02:00
# if [ ! -e _common.sh ]; then
# # Rapatrie le fichier de fonctions si il n'est pas dans le dossier courant
# cp ../settings/scripts/_common.sh ./_common.sh
# chmod a+rx _common.sh
# fi
# source _common.sh
source /usr/share/yunohost/helpers
2016-05-07 18:21:06 +02:00
#=================================================
# LOAD SETTINGS
#=================================================
2016-05-07 18:21:06 +02:00
app=$YNH_APP_INSTANCE_NAME
2016-05-07 18:21:06 +02:00
final_path=$(ynh_app_setting_get $app final_path)
domain=$(ynh_app_setting_get $app domain)
path_url=$(ynh_app_setting_get $app path)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
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
#=================================================
2016-05-07 18:21:06 +02:00
2017-08-28 03:03:36 +02:00
mkdir -p /opt/yunohost
2017-06-13 15:47:47 +02:00
ynh_restore_file "$final_path"
2016-05-07 18:21:06 +02:00
#=================================================
# INSTALL DEPENDENCIES
#=================================================
2016-05-07 18:21:06 +02:00
2018-03-08 17:10:43 +01:00
ynh_install_app_dependencies libxslt-dev 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
#=================================================
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
#=================================================
# RELOAD NGINX AND UWSGI
#=================================================
2016-05-07 18:21:06 +02:00
2017-08-28 03:03:36 +02:00
systemctl restart uwsgi
systemctl reload nginx