mirror of
https://github.com/YunoHost-Apps/searx_ynh.git
synced 2024-09-03 20:16:30 +02:00
95 lines
3.5 KiB
Bash
95 lines
3.5 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# STANDARD UPGRADE STEPS
|
|
#=================================================
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
#=================================================
|
|
ynh_script_progression --message="Ensuring downward compatibility..."
|
|
|
|
if [ -f "$install_dir/setup.py" ]; then
|
|
# Clean up the whole install_dir except settings.yml
|
|
tmpdir="$(mktemp -d)"
|
|
cp "$install_dir/searx/settings.yml" "$tmpdir"
|
|
ynh_secure_remove "$install_dir"
|
|
mkdir -p "$install_dir"
|
|
chmod 750 "$install_dir"
|
|
chown "$app:" "$install_dir"
|
|
mkdir -p "$install_dir/source/searx"
|
|
cp "$tmpdir/settings.yml" "$install_dir/source/searx"
|
|
ynh_secure_remove --file="$tmpdir"
|
|
fi
|
|
|
|
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading source files..." --weight=3
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
|
ynh_setup_source --dest_dir="$install_dir/source" --full_replace=1 --keep="searx/settings.yml"
|
|
|
|
#=================================================
|
|
# REAPPLY SYSTEM CONFIGURATIONS
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
|
|
|
path_no_root=${path%/}
|
|
# Create a dedicated NGINX config
|
|
ynh_add_nginx_config "path_no_root"
|
|
|
|
#=================================================
|
|
# SPECIFIC UPGRADE
|
|
#=================================================
|
|
# UPGRADE SEARX IN ITS VIRTUALENV
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading Searx..." --weight=7
|
|
|
|
_searx_venv_install
|
|
|
|
ynh_add_config --template="requirements-ynh.txt" --destination="$install_dir/requirements-ynh.txt"
|
|
|
|
ynh_exec_as "$app" "$venvpy" -m pip install --requirement "$install_dir/requirements-ynh.txt" --no-cache-dir
|
|
|
|
#=================================================
|
|
# CONFIGURE SEARX
|
|
#=================================================
|
|
# ynh_script_progression --message="Configuring Searx..." --weight=2
|
|
|
|
# secret_key=$(ynh_string_random)
|
|
# ynh_add_config --template="settings.yml" --destination="$install_dir/source/searx/settings.yml"
|
|
|
|
#=================================================
|
|
# CONFIGURE UWSGI FOR SEARX
|
|
#=================================================
|
|
ynh_script_progression --message="Reconfiguring uWSGI for Searx..." --weight=2
|
|
|
|
# Clean old files
|
|
ynh_secure_remove --file="/etc/uwsgi/apps-enabled/$app.ini"
|
|
ynh_secure_remove --file="/etc/uwsgi/apps-available/$app.ini"
|
|
ynh_add_uwsgi_service
|
|
|
|
#=================================================
|
|
# GENERIC FINALISATION
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=3
|
|
|
|
# Wait for searx to be fully started
|
|
ynh_systemd_action --service_name="uwsgi-app@$app.service" --action=restart --line_match="spawned uWSGI master process" --log_path="/var/log/uwsgi/$app/$app.log"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|