2014-09-23 12:04:43 +02:00
|
|
|
#!/bin/bash
|
2016-07-04 21:16:34 +02:00
|
|
|
|
2017-05-01 15:47:20 +02:00
|
|
|
#=================================================
|
2022-03-06 19:01:21 +01:00
|
|
|
# GENERIC START
|
2017-05-01 15:47:20 +02:00
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
2016-07-04 21:16:34 +02:00
|
|
|
|
2020-04-15 20:29:35 +02:00
|
|
|
source _common.sh
|
2020-04-16 02:18:06 +02:00
|
|
|
source /usr/share/yunohost/helpers
|
2014-09-23 12:04:43 +02:00
|
|
|
|
2019-05-18 20:15:36 +02:00
|
|
|
#=================================================
|
|
|
|
# CHECK VERSION
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
upgrade_type=$(ynh_check_app_version_changed)
|
2015-03-03 13:20:04 +01:00
|
|
|
|
2022-03-06 19:01:21 +01:00
|
|
|
#=================================================
|
|
|
|
# STANDARD UPGRADE STEPS
|
2017-05-01 15:47:20 +02:00
|
|
|
#=================================================
|
2019-03-03 20:32:26 +01:00
|
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
2017-05-01 15:47:20 +02:00
|
|
|
#=================================================
|
2019-05-18 20:15:36 +02:00
|
|
|
ynh_script_progression --message="Ensuring downward compatibility..."
|
2014-07-21 23:53:27 +02:00
|
|
|
|
2022-03-09 20:30:52 +01:00
|
|
|
mkdir -p /var/log/uwsgi/$app
|
|
|
|
chown $app:root /var/log/uwsgi/$app
|
|
|
|
chmod -R u=rwX,g=rX,o= /var/log/uwsgi/$app
|
|
|
|
|
2017-05-01 15:47:20 +02:00
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
|
|
|
|
2019-05-18 20:15:36 +02:00
|
|
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
|
|
|
then
|
|
|
|
ynh_script_progression --message="Upgrading source files..." --weight=3
|
2017-11-30 19:39:06 +01:00
|
|
|
|
2021-11-22 22:51:12 +01:00
|
|
|
# Create a temporary directory
|
2022-06-29 01:07:32 +02:00
|
|
|
tmpdir="$(mktemp -d)"
|
2021-11-22 22:51:12 +01:00
|
|
|
|
2022-06-29 01:07:32 +02:00
|
|
|
# Backup the config file in the temp dir
|
2023-08-18 11:38:35 +02:00
|
|
|
cp -a "$install_dir/searx/settings.yml" "$tmpdir/settings.yml"
|
2021-11-22 22:51:12 +01:00
|
|
|
|
2019-05-18 20:15:36 +02:00
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2023-08-18 11:38:35 +02:00
|
|
|
ynh_setup_source --dest_dir="$install_dir"
|
2021-11-22 22:51:12 +01:00
|
|
|
|
2022-06-29 01:07:32 +02:00
|
|
|
# Copy the admin saved settings from tmp directory to final path
|
2023-08-18 11:38:35 +02:00
|
|
|
cp -a "$tmpdir/settings.yml" "$install_dir/searx/settings.yml"
|
2021-11-22 22:51:12 +01:00
|
|
|
|
2022-06-29 01:07:32 +02:00
|
|
|
# Remove the tmp directory securely
|
|
|
|
ynh_secure_remove --file="$tmpdir"
|
2019-05-18 20:15:36 +02:00
|
|
|
fi
|
2017-05-01 15:47:20 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
#=================================================
|
2020-12-19 23:34:40 +01:00
|
|
|
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
|
2017-05-01 15:47:20 +02:00
|
|
|
|
2023-08-18 11:38:35 +02:00
|
|
|
path_no_root=${path%/}
|
2020-09-19 16:09:37 +02:00
|
|
|
# Create a dedicated NGINX config
|
2019-03-03 20:32:26 +01:00
|
|
|
ynh_add_nginx_config "path_no_root"
|
2014-07-21 23:53:27 +02:00
|
|
|
|
2017-05-01 15:47:20 +02:00
|
|
|
#=================================================
|
|
|
|
# SPECIFIC UPGRADE
|
|
|
|
#=================================================
|
|
|
|
# UPGRADE SEARX IN ITS VIRTUALENV
|
|
|
|
#=================================================
|
2019-05-18 20:15:36 +02:00
|
|
|
ynh_script_progression --message="Upgrading Searx..." --weight=7
|
2017-05-01 15:47:20 +02:00
|
|
|
|
2020-09-19 20:39:58 +02:00
|
|
|
# Clean venv if it still on python2
|
2023-08-18 11:38:35 +02:00
|
|
|
if [ ! -e $install_dir/bin/python3 ]
|
2020-09-19 20:39:58 +02:00
|
|
|
then
|
2023-08-18 11:38:35 +02:00
|
|
|
ynh_regex_secure_remove --file=$install_dir/lib/ --regex='python[^/.]*'
|
|
|
|
ynh_regex_secure_remove --file=$install_dir/lib64/ --regex='python[^/.]*'
|
|
|
|
ynh_regex_secure_remove --file=$install_dir/share/python-wheels
|
2020-09-19 20:39:58 +02:00
|
|
|
fi
|
2023-08-18 11:38:35 +02:00
|
|
|
ynh_regex_secure_remove --file=$install_dir/lib/python3/site-packages/setuptools
|
|
|
|
ynh_regex_secure_remove --file=$install_dir/lib/python3/site-packages/ --regex='setuptools-[^/.]*'
|
2020-09-19 20:39:58 +02:00
|
|
|
|
2023-08-18 11:38:35 +02:00
|
|
|
python3 -m venv --system-site-packages "$install_dir"
|
2020-11-09 15:58:11 +01:00
|
|
|
|
2023-08-18 11:38:35 +02:00
|
|
|
set +u; source $install_dir/bin/activate; set -u
|
2020-04-11 14:19:29 +02:00
|
|
|
pip3 install -U setuptools
|
2023-08-18 11:38:35 +02:00
|
|
|
pip3 install --requirement $install_dir/requirements-ynh.txt --upgrade
|
2020-09-19 18:59:31 +02:00
|
|
|
|
2023-08-18 11:38:35 +02:00
|
|
|
chown -R $app: "$install_dir"
|
2022-03-06 19:01:21 +01:00
|
|
|
|
2017-05-01 15:47:20 +02:00
|
|
|
#=================================================
|
|
|
|
# CONFIGURE SEARX
|
|
|
|
#=================================================
|
2021-06-26 18:53:34 +02:00
|
|
|
# ynh_script_progression --message="Configuring Searx..." --weight=2
|
2017-05-01 15:47:20 +02:00
|
|
|
|
2021-06-26 18:53:34 +02:00
|
|
|
# secret_key=$(ynh_string_random)
|
2023-08-18 11:38:35 +02:00
|
|
|
# ynh_add_config --template="../conf/settings.yml" --destination="$install_dir/searx/settings.yml"
|
2017-05-01 15:47:20 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CONFIGURE UWSGI FOR SEARX
|
|
|
|
#=================================================
|
2020-12-19 23:34:40 +01:00
|
|
|
ynh_script_progression --message="Reconfiguring uWSGI for Searx..." --weight=2
|
2017-05-01 15:47:20 +02:00
|
|
|
|
2020-04-10 22:02:55 +02:00
|
|
|
# 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
|
2018-05-11 22:59:18 +02:00
|
|
|
|
|
|
|
#=================================================
|
2022-03-06 19:01:21 +01:00
|
|
|
# GENERIC FINALISATION
|
|
|
|
#=================================================
|
|
|
|
# START SYSTEMD SERVICE
|
2018-05-11 22:59:18 +02:00
|
|
|
#=================================================
|
2022-03-06 19:01:21 +01:00
|
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=3
|
2018-05-11 22:59:18 +02:00
|
|
|
|
|
|
|
# Wait for searx to be fully started
|
2021-06-26 12:33:40 +02:00
|
|
|
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"
|
2014-07-21 23:53:27 +02:00
|
|
|
|
2019-03-03 20:33:02 +01:00
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2022-03-06 19:01:21 +01:00
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|