2022-11-23 10:08:54 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
upgrade_type=$(ynh_check_app_version_changed)
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STANDARD UPGRADE STEPS
|
|
|
|
#=================================================
|
|
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
|
|
|
|
2023-09-18 18:10:55 +02:00
|
|
|
if [ ! -e "$data_dir/settings.yml" ]; then
|
|
|
|
secret_key=$(ynh_string_random)
|
|
|
|
ynh_add_config --template="../conf/settings.yml" --destination="$data_dir/settings.yml"
|
|
|
|
chmod 400 "$data_dir/settings.yml"
|
|
|
|
chown $app: "$data_dir"
|
|
|
|
fi
|
|
|
|
if [ -e "$install_dir/searx" ]; then
|
|
|
|
ynh_secure_remove --file="$install_dir"
|
|
|
|
ynh_delete_file_checksum --file="/opt/yunohost/$app/searx/settings.yml"
|
2022-11-23 10:08:54 +01:00
|
|
|
fi
|
|
|
|
|
2023-09-18 18:10:55 +02:00
|
|
|
ynh_delete_file_checksum --file="etc/nginx_conf.d/$domain/$app.conf"
|
|
|
|
|
2022-11-23 10:08:54 +01:00
|
|
|
#=================================================
|
2023-09-18 18:10:55 +02:00
|
|
|
# STOP SYSTEMD SERVICE
|
2022-11-23 10:08:54 +01:00
|
|
|
#=================================================
|
2023-09-18 18:10:55 +02:00
|
|
|
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
2022-11-23 10:08:54 +01:00
|
|
|
|
2023-09-18 18:10:55 +02:00
|
|
|
ynh_systemd_action --service_name="uwsgi-app@$app.service" --action="stop" --log_path="/var/log/uwsgi/$app/$app.log"
|
2022-11-23 10:08:54 +01:00
|
|
|
|
2023-09-18 18:10:55 +02:00
|
|
|
#=================================================
|
|
|
|
# "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN NPM BUILD...)
|
2022-11-23 10:08:54 +01:00
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
|
|
|
then
|
|
|
|
ynh_script_progression --message="Upgrading source files..." --weight=1
|
2023-03-01 19:36:12 +01:00
|
|
|
|
2023-09-18 18:10:55 +02:00
|
|
|
ynh_secure_remove --file="$install_dir/searxng-src"
|
|
|
|
ynh_exec_fully_quiet git clone -n "$repo_fullpath" "$install_dir/searxng-src"
|
|
|
|
pushd "$install_dir/searxng-src"
|
|
|
|
ynh_exec_fully_quiet git checkout "$commit_sha"
|
|
|
|
popd
|
|
|
|
|
|
|
|
ynh_secure_remove --file="$install_dir/searxng-pyenv"
|
|
|
|
python3 -m venv --system-site-packages "$install_dir/searxng-pyenv"
|
2023-09-18 19:51:03 +02:00
|
|
|
set +o nounset; source "$install_dir/searxng-pyenv/bin/activate"; set -o nounset
|
2023-09-18 18:10:55 +02:00
|
|
|
pip3 install -U pip setuptools wheel pyyaml --no-cache-dir
|
|
|
|
ynh_exec_fully_quiet pip3 install -e "$install_dir/searxng-src"
|
2022-11-23 10:08:54 +01:00
|
|
|
fi
|
|
|
|
|
2023-09-18 18:10:55 +02:00
|
|
|
chmod 750 "$install_dir"
|
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app: "$install_dir"
|
2022-11-23 10:08:54 +01:00
|
|
|
|
|
|
|
#=================================================
|
2023-09-18 18:10:55 +02:00
|
|
|
# REAPPLY SYSTEM CONFIGURATIONS
|
2022-11-23 10:08:54 +01:00
|
|
|
#=================================================
|
2023-09-18 18:10:55 +02:00
|
|
|
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
2022-11-23 10:08:54 +01:00
|
|
|
|
2023-09-18 18:10:55 +02:00
|
|
|
ynh_add_nginx_config
|
2022-11-23 10:08:54 +01:00
|
|
|
|
|
|
|
#=================================================
|
2023-09-18 18:10:55 +02:00
|
|
|
# RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS...)
|
2022-11-23 10:08:54 +01:00
|
|
|
#=================================================
|
2023-09-18 18:10:55 +02:00
|
|
|
# UPDATE A CONFIG FILE
|
2022-11-23 10:08:54 +01:00
|
|
|
#=================================================
|
2023-09-18 18:10:55 +02:00
|
|
|
ynh_script_progression --message="Updating a configuration file..." --weight=1
|
2022-11-23 10:08:54 +01:00
|
|
|
|
2023-03-01 19:36:12 +01:00
|
|
|
ynh_add_uwsgi_service
|
2022-11-23 10:08:54 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# START SYSTEMD SERVICE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
2023-09-18 18:10:55 +02:00
|
|
|
|
|
|
|
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"
|
2022-11-23 10:08:54 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|