searx_ynh/scripts/restore

94 lines
2.9 KiB
Bash
Executable File

#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# MANAGE FAILURE OF THE SCRIPT
#=================================================
# Exit on command errors and treat unset variables as an error
set -eu
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# 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
#=================================================
# LOAD SETTINGS
#=================================================
app=$YNH_APP_INSTANCE_NAME
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
#=================================================
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 "
#=================================================
# STANDARD RESTORE STEPS
#=================================================
# RESTORE OF THE NGINX CONFIGURATION
#=================================================
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE OF THE MAIN DIR OF THE APP
#=================================================
mkdir -p /opt/yunohost
ynh_restore_file "$final_path"
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_install_app_dependencies libxslt-dev virtualenv python-babel zlib1g-dev libffi-dev libssl-dev python-lxml uwsgi uwsgi-plugin-python
#=================================================
# RECREATE OF THE DEDICATED USER
#=================================================
# Create the dedicated user (if not existing)
ynh_system_user_create $app
#=================================================
# SPECIFIC RESTORE
#=================================================
# RESTORE USER RIGHTS
#=================================================
chown $app: --recursive "$final_path"
#=================================================
# RESTORE THE UWSGI CONFIG
#=================================================
ynh_restore_file "/etc/uwsgi/apps-available/$app.ini"
ln -s /etc/uwsgi/apps-available/$app.ini /etc/uwsgi/apps-enabled/$app.ini
#=================================================
# GENERIC FINALISATION
#=================================================
# RELOAD NGINX AND UWSGI
#=================================================
systemctl restart uwsgi
systemctl reload nginx