From 57b8f340a6689fafd0c8d92aebd2b263b090af18 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Mon, 12 Jul 2021 16:51:36 +0200 Subject: [mod] utils/searx.sh - add command 'inspect settings' Inspect YAML setting from SearXNG instance (${SEARX_SRC}):: utils/searx.sh inspect settings server.base_url utils/lib_install.sh should not log on stdout which is used for the output of function prompt_installation_setting(). Turned build_msg (stdout) into info_msg (stderr). Signed-off-by: Markus Heiser --- utils/searx.sh | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 55 insertions(+), 6 deletions(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index bc57f7b4a..f02611059 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -146,7 +146,7 @@ usage:: $(basename "$0") remove [all|user|pyenv|searx-src] $(basename "$0") activate [service] $(basename "$0") deactivate [service] - $(basename "$0") inspect [service] + $(basename "$0") inspect [service|settings ] $(basename "$0") option [debug-[on|off]|image-proxy-[on|off]|result-proxy ] $(basename "$0") apache [install|remove] @@ -169,8 +169,9 @@ activate service activate and start service daemon (systemd unit) deactivate service stop and deactivate service daemon (systemd unit) -inspect service - run some small tests and inspect service's status and log +inspect + :service: run some small tests and inspect service's status and log + :settings: inspect YAML setting from SearXNG instance (${SEARX_SRC}) option set one of the available options apache @@ -205,6 +206,10 @@ main() { sudo_or_exit inspect_service ;; + settings) + prompt_installation_setting "$3" + dump_return $? + ;; *) usage "$_usage"; exit 42;; esac ;; install) @@ -425,9 +430,14 @@ EOF } prompt_installation_status(){ - local _state - _state="$(install_searx_get_state)" - case $_state in + + local state branch remote remote_url instance_setting + state="$(install_searx_get_state)" + branch="$(git name-rev --name-only HEAD)" + remote="$(git config branch."${branch}".remote)" + remote_url="$(git config remote."${remote}".url)" + + case $state in missing-searx-clone) info_msg "${_BBlue}(status: $(install_searx_get_state))${_creset}" return 0 @@ -435,6 +445,16 @@ prompt_installation_status(){ *) warn_msg "SearXNG instance already installed at: $SEARX_SRC" warn_msg "status: ${_BBlue}$(install_searx_get_state)${_creset} " + instance_setting="$(prompt_installation_setting brand.git_url)" + if ! [ "$instance_setting" = "$remote_url" ]; then + warn_msg "instance's brand.git_url: '${instance_setting}'" \ + "differs from local clone's remote URL: ${remote_url}" + fi + instance_setting="$(prompt_installation_setting brand.git_branch)" + if ! [ "$instance_setting" = "$branch" ]; then + warn_msg "instance brand.git_branch: ${instance_setting}" \ + "differs from local clone's branch: ${branch}" + fi return 42 ;; esac @@ -447,6 +467,35 @@ verify_continue_install(){ fi } +prompt_installation_setting(){ + + # usage: prompt_installation_setting brand.git_url + # + # Prompts the value of the (YAML) setting in the SearXNG instance. + + local _state + _state="$(install_searx_get_state)" + case $_state in + python-installed|installer-modified) + sudo -H -u "${SERVICE_USER}" "${SEARX_PYENV}/bin/python" <