mirror of
https://github.com/YunoHost-Apps/searxng_ynh.git
synced 2024-09-03 20:26:00 +02:00
86 lines
3.2 KiB
Bash
86 lines
3.2 KiB
Bash
#!/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
|
|
|
|
if [ -e "$install_dir/searx" ]; then
|
|
tempdir="$(mktemp -d)"
|
|
mv "$install_dir/searx/settings.yml" "$tempdir/settings.yml"
|
|
sed -i '1s/^/use_default_settings: true\n\n/' "$tempdir/settings.yml"
|
|
ynh_secure_remove --file="$install_dir"
|
|
mkdir "$install_dir"
|
|
mv "$tempdir/settings.yml" "$install_dir/settings.yml"
|
|
ynh_secure_remove --file="$tempdir"
|
|
ynh_store_file_checksum --file="$install_dir/settings.yml"
|
|
ynh_delete_file_checksum --file="/opt/yunohost/$app/searx/settings.yml"
|
|
fi
|
|
|
|
ynh_delete_file_checksum --file="etc/nginx_conf.d/$domain/$app.conf"
|
|
|
|
#=================================================
|
|
# STOP SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
|
|
|
ynh_systemd_action --service_name="uwsgi-app@$app.service" --action="stop" --log_path="/var/log/uwsgi/$app/$app.log"
|
|
|
|
#=================================================
|
|
# "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN NPM BUILD...)
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
|
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
|
then
|
|
ynh_secure_remove --file="$install_dir/.profile"
|
|
ynh_secure_remove --file="$install_dir/.cache"
|
|
ynh_secure_remove --file="$install_dir/searxng-src"
|
|
ynh_secure_remove --file="$install_dir/searxng-pyenv"
|
|
myynh_source_searxng
|
|
myynh_install_searxng
|
|
fi
|
|
|
|
myynh_set_permissions
|
|
|
|
#=================================================
|
|
# REAPPLY SYSTEM CONFIGURATIONS
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
|
|
|
ynh_add_nginx_config
|
|
|
|
#=================================================
|
|
# RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS...)
|
|
#=================================================
|
|
# UPDATE A CONFIG FILE
|
|
#=================================================
|
|
ynh_script_progression --message="Updating a configuration file..." --weight=1
|
|
|
|
ynh_add_uwsgi_service
|
|
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
|
|
|
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"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|