From 79b562e108d91fe0d59fc53bf7ea0b65f36fb793 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 26 Jun 2021 11:55:18 +0200 Subject: [PATCH 1/9] Update upgrade --- scripts/upgrade | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index afcc96e..c7446db 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -125,18 +125,11 @@ pip3 install --requirement $final_path/requirements-ynh.txt --upgrade #================================================= # CONFIGURE SEARX #================================================= -ynh_script_progression --message="Reconfiguring Searx..." --weight=2 +ynh_script_progression --message="Configuring Searx..." --weight=2 -# Change instance name -ynh_replace_string --match_string="instance_name : \"searx\"" --replace_string="instance_name : \"YunoSearx\"" --target_file="$final_path/searx/settings.yml" +secret_key=$(ynh_string_random) -# Generate a secret key -ynh_replace_string --match_string="secret_key : \"ultrasecretkey\"" --replace_string="secret_key : \"$(ynh_string_random)\"" --target_file="$final_path/searx/settings.yml" - -# Modify the base_url parameter -#ynh_replace_string --match_string="base_url : False" --replace_string="base_url : https://${domain}${path_url%/}/" --target_file="$final_path/searx/settings.yml" - -ynh_store_file_checksum --file="$final_path/searx/settings.yml" +ynh_add_config --template="../conf/settings.yml" --destination="$final_path/searx/settings.yml" #================================================= # GENERIC FINALISATION From 91c57361ebba7a666a59254169b75007aca8da7c Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 26 Jun 2021 12:02:15 +0200 Subject: [PATCH 2/9] Fix --- scripts/install | 7 ++----- scripts/upgrade | 3 --- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/scripts/install b/scripts/install index 039d0cc..1eb7f79 100644 --- a/scripts/install +++ b/scripts/install @@ -63,7 +63,7 @@ ynh_install_app_dependencies $pkg_dependencies ynh_script_progression --message="Configuring system user..." --weight=3 # Create a system user -ynh_system_user_create --username=$app +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # NGINX CONFIGURATION @@ -92,10 +92,7 @@ ynh_script_progression --message="Installing Searx..." --weight=2 python3 -m venv --system-site-packages "$final_path" set +u; source $final_path/bin/activate; set -u -pip3 install -U pip -pip3 install -U setuptools -pip3 install -U wheel -pip3 install -U pyyaml +pip3 install -U pip setuptools wheel pyyaml pip3 install --requirement $final_path/requirements-ynh.txt #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index c7446db..f6aaaa6 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -81,9 +81,6 @@ ynh_system_user_create --username=$app if [ "$upgrade_type" == "UPGRADE_APP" ] then - # Verify the checksum and backup the file if it's different - ynh_backup_if_checksum_is_different --file="$final_path/searx/settings.yml" - ynh_script_progression --message="Upgrading source files..." --weight=3 # Download, check integrity, uncompress and patch the source from app.src From 82e05c954d2c47ec1bcf9a1f9b0000b2c8752c72 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 26 Jun 2021 12:02:51 +0200 Subject: [PATCH 3/9] Update install --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 1eb7f79..cb808fe 100644 --- a/scripts/install +++ b/scripts/install @@ -102,7 +102,7 @@ ynh_script_progression --message="Configuring Searx..." --weight=2 secret_key=$(ynh_string_random) -ynh_add_config --template="../conf/settings.yml" --destination="$final_path/searx/settings.yml" +ynh_add_config --template="../conf/settings.yml" --destination="$final_path/searx/settings.yml" 2>/dev/null #================================================= # SET PERMISSIONS ON SEARX DIRECTORY From fcddb4c8bc898e3a96101c0567c095062d1d9cc7 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 26 Jun 2021 12:08:49 +0200 Subject: [PATCH 4/9] Fix --- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index cb808fe..c88a4a1 100644 --- a/scripts/install +++ b/scripts/install @@ -115,7 +115,7 @@ chown -R $app: $final_path #================================================= ynh_script_progression --message="Configuring uWSGI for Searx..." --weight=2 -ynh_add_uwsgi_service +ynh_add_uwsgi_service 2>/dev/null #================================================= # CHECK SEARX STARTING diff --git a/scripts/restore b/scripts/restore index 8672a9b..7082849 100755 --- a/scripts/restore +++ b/scripts/restore @@ -53,7 +53,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_script_progression --message="Recreating the dedicated system user..." --weight=3 # Create the dedicated user (if not existing) -ynh_system_user_create --username=$app +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # RESTORE OF THE MAIN DIR OF THE APP diff --git a/scripts/upgrade b/scripts/upgrade index f6aaaa6..6644832 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -73,7 +73,7 @@ ynh_install_app_dependencies $pkg_dependencies ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 # Create a dedicated user (if not existing) -ynh_system_user_create --username=$app +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE From bb3ec87b64ad550ac907709d59691ec812a82f78 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 26 Jun 2021 12:26:23 +0200 Subject: [PATCH 5/9] Fix --- scripts/change_url | 2 +- scripts/install | 4 ++-- scripts/remove | 2 +- scripts/restore | 4 ++-- scripts/upgrade | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 3773192..ef9790d 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -118,7 +118,7 @@ ynh_script_progression --message="Reconfiguring Searx..." --weight=2 #================================================= ynh_script_progression --message="Starting Searx..." --weight=2 -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" +ynh_systemd_action --service_name=uwsgi-app@.service --action=restart --line_match="spawned uWSGI master process" --log_path="/var/log/uwsgi/$app/$app.log" #================================================= # RELOAD NGINX diff --git a/scripts/install b/scripts/install index c88a4a1..3c5e1ee 100644 --- a/scripts/install +++ b/scripts/install @@ -115,7 +115,7 @@ chown -R $app: $final_path #================================================= ynh_script_progression --message="Configuring uWSGI for Searx..." --weight=2 -ynh_add_uwsgi_service 2>/dev/null +ynh_add_uwsgi_service #================================================= # CHECK SEARX STARTING @@ -123,7 +123,7 @@ ynh_add_uwsgi_service 2>/dev/null ynh_script_progression --message="Starting Searx..." --weight=4 # Wait for Searx to be fully started -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" +ynh_systemd_action --service_name=uwsgi-app@.service --action=start --line_match="spawned uWSGI master process" --log_path="/var/log/uwsgi/$app/$app.log" #================================================= # GENERIC FINALISATION diff --git a/scripts/remove b/scripts/remove index 364e882..4c257b8 100644 --- a/scripts/remove +++ b/scripts/remove @@ -27,7 +27,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) ynh_script_progression --message="Stopping and removing the systemd service..." --weight=2 # Remove the uwsgi configuration -ynh_systemd_action --service_name "uwsgi-app@$app.service" --action stop +ynh_systemd_action --service_name "uwsgi-app@.service" --action stop ynh_remove_uwsgi_service #================================================= diff --git a/scripts/restore b/scripts/restore index 7082849..f2538b9 100755 --- a/scripts/restore +++ b/scripts/restore @@ -86,7 +86,7 @@ ynh_restore_file --origin_path="/etc/uwsgi/apps-available/$app.ini" ynh_restore_file --origin_path "/var/log/uwsgi/$app" chown $app:root /var/log/uwsgi/$app ynh_check_global_uwsgi_config -systemctl enable "uwsgi-app@$app.service" --quiet +systemctl enable "uwsgi-app@.service" --quiet #================================================= # GENERIC FINALISATION @@ -103,7 +103,7 @@ ynh_systemd_action --service_name=nginx --action=reload ynh_script_progression --message="Starting Searx..." --weight=4 # Wait for searx to be fully started -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" +ynh_systemd_action --service_name=uwsgi-app@.service --action=start --line_match="spawned uWSGI master process" --log_path="/var/log/uwsgi/$app/$app.log" #================================================= # END OF SCRIPT diff --git a/scripts/upgrade b/scripts/upgrade index 6644832..c021d86 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -152,7 +152,7 @@ ynh_add_uwsgi_service ynh_script_progression --message="Restarting Searx..." --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" +ynh_systemd_action --service_name=uwsgi-app@.service --action=restart --line_match="spawned uWSGI master process" --log_path="/var/log/uwsgi/$app/$app.log" #================================================= # RELOAD NGINX From 83068cd214d58a8e00e0ccae9868ecf9ae2098cf Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 26 Jun 2021 12:33:40 +0200 Subject: [PATCH 6/9] Revert "Fix" This reverts commit bb3ec87b64ad550ac907709d59691ec812a82f78. --- scripts/change_url | 2 +- scripts/install | 4 ++-- scripts/remove | 2 +- scripts/restore | 4 ++-- scripts/upgrade | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index ef9790d..3773192 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -118,7 +118,7 @@ ynh_script_progression --message="Reconfiguring Searx..." --weight=2 #================================================= ynh_script_progression --message="Starting Searx..." --weight=2 -ynh_systemd_action --service_name=uwsgi-app@.service --action=restart --line_match="spawned uWSGI master process" --log_path="/var/log/uwsgi/$app/$app.log" +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" #================================================= # RELOAD NGINX diff --git a/scripts/install b/scripts/install index 3c5e1ee..c88a4a1 100644 --- a/scripts/install +++ b/scripts/install @@ -115,7 +115,7 @@ chown -R $app: $final_path #================================================= ynh_script_progression --message="Configuring uWSGI for Searx..." --weight=2 -ynh_add_uwsgi_service +ynh_add_uwsgi_service 2>/dev/null #================================================= # CHECK SEARX STARTING @@ -123,7 +123,7 @@ ynh_add_uwsgi_service ynh_script_progression --message="Starting Searx..." --weight=4 # Wait for Searx to be fully started -ynh_systemd_action --service_name=uwsgi-app@.service --action=start --line_match="spawned uWSGI master process" --log_path="/var/log/uwsgi/$app/$app.log" +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" #================================================= # GENERIC FINALISATION diff --git a/scripts/remove b/scripts/remove index 4c257b8..364e882 100644 --- a/scripts/remove +++ b/scripts/remove @@ -27,7 +27,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) ynh_script_progression --message="Stopping and removing the systemd service..." --weight=2 # Remove the uwsgi configuration -ynh_systemd_action --service_name "uwsgi-app@.service" --action stop +ynh_systemd_action --service_name "uwsgi-app@$app.service" --action stop ynh_remove_uwsgi_service #================================================= diff --git a/scripts/restore b/scripts/restore index f2538b9..7082849 100755 --- a/scripts/restore +++ b/scripts/restore @@ -86,7 +86,7 @@ ynh_restore_file --origin_path="/etc/uwsgi/apps-available/$app.ini" ynh_restore_file --origin_path "/var/log/uwsgi/$app" chown $app:root /var/log/uwsgi/$app ynh_check_global_uwsgi_config -systemctl enable "uwsgi-app@.service" --quiet +systemctl enable "uwsgi-app@$app.service" --quiet #================================================= # GENERIC FINALISATION @@ -103,7 +103,7 @@ ynh_systemd_action --service_name=nginx --action=reload ynh_script_progression --message="Starting Searx..." --weight=4 # Wait for searx to be fully started -ynh_systemd_action --service_name=uwsgi-app@.service --action=start --line_match="spawned uWSGI master process" --log_path="/var/log/uwsgi/$app/$app.log" +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 diff --git a/scripts/upgrade b/scripts/upgrade index c021d86..6644832 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -152,7 +152,7 @@ ynh_add_uwsgi_service ynh_script_progression --message="Restarting Searx..." --weight=3 # Wait for searx to be fully started -ynh_systemd_action --service_name=uwsgi-app@.service --action=restart --line_match="spawned uWSGI master process" --log_path="/var/log/uwsgi/$app/$app.log" +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" #================================================= # RELOAD NGINX From 8ee1e53a9d77df1dee00baf096116e209a5696cc Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 26 Jun 2021 12:50:24 +0200 Subject: [PATCH 7/9] Update install --- scripts/install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index c88a4a1..73643ee 100644 --- a/scripts/install +++ b/scripts/install @@ -92,8 +92,8 @@ ynh_script_progression --message="Installing Searx..." --weight=2 python3 -m venv --system-site-packages "$final_path" set +u; source $final_path/bin/activate; set -u -pip3 install -U pip setuptools wheel pyyaml -pip3 install --requirement $final_path/requirements-ynh.txt +pip3 install -U pip setuptools wheel pyyaml --no-cache-dir +pip3 install --requirement $final_path/requirements-ynh.txt --no-cache-dir #================================================= # CONFIGURE SEARX From 5ac33e41f924234215c6e5d7a956c3d2844329a2 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 26 Jun 2021 18:53:34 +0200 Subject: [PATCH 8/9] Update upgrade --- scripts/upgrade | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 6644832..9155b83 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -83,8 +83,21 @@ if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." --weight=3 +# Create a temporary directory + tmpdir="$(mktemp -d)" + + # Backup the config file in the temp dir + cp -a "$final_path/searx/settings.yml" "$tmpdir/settings.yml" + # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" + + # Copy the admin saved settings from tmp directory to final path + cp -a "$tmpdir/settings.yml" "$final_path/searx/settings.yml" + + # Remove the tmp directory securely + ynh_secure_remove --file="$tmpdir" + fi #================================================= @@ -122,11 +135,11 @@ pip3 install --requirement $final_path/requirements-ynh.txt --upgrade #================================================= # CONFIGURE SEARX #================================================= -ynh_script_progression --message="Configuring Searx..." --weight=2 +# ynh_script_progression --message="Configuring Searx..." --weight=2 -secret_key=$(ynh_string_random) +# secret_key=$(ynh_string_random) -ynh_add_config --template="../conf/settings.yml" --destination="$final_path/searx/settings.yml" +# ynh_add_config --template="../conf/settings.yml" --destination="$final_path/searx/settings.yml" #================================================= # GENERIC FINALISATION From fc4c6127b1875bab413caf68c615d8529d6463bc Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Tue, 20 Jul 2021 21:00:24 +0200 Subject: [PATCH 9/9] Update install --- scripts/install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 73643ee..2c6f59c 100644 --- a/scripts/install +++ b/scripts/install @@ -102,7 +102,7 @@ ynh_script_progression --message="Configuring Searx..." --weight=2 secret_key=$(ynh_string_random) -ynh_add_config --template="../conf/settings.yml" --destination="$final_path/searx/settings.yml" 2>/dev/null +ynh_add_config --template="../conf/settings.yml" --destination="$final_path/searx/settings.yml" #================================================= # SET PERMISSIONS ON SEARX DIRECTORY @@ -115,7 +115,7 @@ chown -R $app: $final_path #================================================= ynh_script_progression --message="Configuring uWSGI for Searx..." --weight=2 -ynh_add_uwsgi_service 2>/dev/null +ynh_add_uwsgi_service #================================================= # CHECK SEARX STARTING