From 11d1b3530211c2f5ad9fc0253c579924edf978f1 Mon Sep 17 00:00:00 2001 From: free Date: Thu, 7 Jun 2018 21:34:06 +0200 Subject: [PATCH] Update 'scripts/upgrade' --- scripts/upgrade | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index d481d50..b7a4ac9 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,7 +1,8 @@ #!/bin/bash #================================================= -# GENERIC STARTING +# + GENERIC STARTING #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -47,7 +48,8 @@ ynh_backup_before_upgrade # Backup the current version of the app ynh_clean_setup () { ynh_restore_upgradebackup # restore it if the upgrade fails } -ynh_abort_if_errors # Exit if an error occurs during the execution of the script +ynh_abort_if_errors # Exit if an error occurs during the execution of +the script #================================================= # CHECK THE PATH @@ -65,7 +67,8 @@ path_url=$(ynh_normalize_url_path $path_url) # Verify the checksum and backup the file if it's different ynh_backup_if_checksum_is_different "$final_path/searx/settings.yml" -# Download, check integrity, uncompress and patch the source from app.src +# Download, check integrity, uncompress and patch the source from +app.src ynh_setup_source "$final_path" #================================================= @@ -75,11 +78,13 @@ ynh_setup_source "$final_path" ynh_add_nginx_config if [ "$path_url" = "/" ] then - ynh_replace_string "__PATH_NO_ROOT__" "" /etc/nginx/conf.d/$domain.d/$app.conf + ynh_replace_string "__PATH_NO_ROOT__" "" +/etc/nginx/conf.d/$domain.d/$app.conf sed --in-place '/#noroot*/d' /etc/nginx/conf.d/$domain.d/$app.conf else ynh_replace_string "#noroot" "" /etc/nginx/conf.d/$domain.d/$app.conf - ynh_replace_string "__PATH_NO_ROOT__" "$path_url" /etc/nginx/conf.d/$domain.d/$app.conf + ynh_replace_string "__PATH_NO_ROOT__" "$path_url" +/etc/nginx/conf.d/$domain.d/$app.conf fi ynh_store_file_checksum "/etc/nginx/conf.d/$domain.d/$app.conf" @@ -96,26 +101,33 @@ ynh_system_user_create $app # UPGRADE SEARX IN ITS VIRTUALENV #================================================= -rm -r $final_path/lib/python2.7/site-packages/setuptools $final_path/lib/python2.7/site-packages/setuptools-* +rm -r $final_path/lib/python2.7/site-packages/setuptools +$final_path/lib/python2.7/site-packages/setuptools-* virtualenv --system-site-packages "$final_path" -bash -c "source $final_path/bin/activate && pip install -U setuptools && pip install --requirement $final_path/requirements-ynh.txt --upgrade" +bash -c "source $final_path/bin/activate && pip install -U +setuptools && pip install --requirement +$final_path/requirements-ynh.txt --upgrade" #================================================= # CONFIGURE SEARX #================================================= # Change instance name -ynh_replace_string "instance_name : \"searx\"" "instance_name : \"YunoSearx\"" "$final_path/searx/settings.yml" +ynh_replace_string "instance_name : \"searx\"" "instance_name : +\"YunoSearx\"" "$final_path/searx/settings.yml" # Generate a secret key -ynh_replace_string "secret_key : \"ultrasecretkey\"" "secret_key : \"$(ynh_string_random)\"" "$final_path/searx/settings.yml" +ynh_replace_string "secret_key : \"ultrasecretkey\"" "secret_key : +\"$(ynh_string_random)\"" "$final_path/searx/settings.yml" # Modify the base_url parameter, if it's installed in a subpath if [ "$path_url" != "/" ] then - ynh_replace_string "base_url : False" "base_url : https://${domain}${path_url}/" "$final_path/searx/settings.yml" + ynh_replace_string "base_url : False" "base_url : +http://${domain}${path_url}/" "$final_path/searx/settings.yml" else - ynh_replace_string "base_url : False" "base_url : False" "$final_path/searx/settings.yml" + ynh_replace_string "base_url : False" "base_url : False" +"$final_path/searx/settings.yml" fi ynh_store_file_checksum "$final_path/searx/settings.yml" @@ -133,7 +145,8 @@ chown $app: --recursive "$final_path" cp ../conf/searx.ini /etc/uwsgi/apps-available/$app.ini ynh_replace_string "__APP__" "$app" /etc/uwsgi/apps-available/$app.ini -ynh_replace_string "__FINALPATH__" "$final_path" /etc/uwsgi/apps-available/$app.ini +ynh_replace_string "__FINALPATH__" "$final_path" +/etc/uwsgi/apps-available/$app.ini systemctl restart uwsgi #=================================================