From 81bba4486916dbca4467a7e8c8b839a7c55c2a09 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Fri, 27 May 2022 18:41:08 +0200 Subject: [PATCH 1/6] [install scripts] rename SEARX_ variables to SEARXNG_ Signed-off-by: Markus Heiser --- .config.sh | 4 +- docs/build-templates/searx.rst | 24 ++-- utils/filtron.sh | 2 +- utils/lib_install.sh | 52 ++++---- utils/morty.sh | 2 +- utils/searx.sh | 118 +++++++++--------- .../httpd/sites-available/searxng.conf:uwsgi | 13 +- .../searxng.conf:filtron | 2 +- .../etc/uwsgi/apps-archlinux/searxng.ini | 18 +-- .../uwsgi/apps-archlinux/searxng.ini:socket | 24 ++-- .../etc/uwsgi/apps-available/searxng.ini | 18 +-- .../uwsgi/apps-available/searxng.ini:socket | 24 ++-- 12 files changed, 159 insertions(+), 142 deletions(-) diff --git a/.config.sh b/.config.sh index cc7663648..972728c35 100644 --- a/.config.sh +++ b/.config.sh @@ -4,7 +4,7 @@ # # This file should be edited only ones just before the installation of any # service is done. After the installation of the searx service a copy of this -# file is placed into the $SEARX_SRC of the instance, e.g.:: +# file is placed into the $SEARXNG_SRC of the instance, e.g.:: # # /usr/local/searx/searx-src/.config.sh # @@ -24,7 +24,7 @@ # $ ./utils/searx.sh --help # ---- SearXNG instance setup (already installed) # SEARXNG_SETTINGS_PATH : /etc/searxng/settings.yml -# SEARX_SRC : /usr/local/searx/searx-src +# SEARXNG_SRC : /usr/local/searx/searx-src # # [1] https://docs.searxng.org/admin/engines/settings.html diff --git a/docs/build-templates/searx.rst b/docs/build-templates/searx.rst index 626cce6bd..0e7877ba4 100644 --- a/docs/build-templates/searx.rst +++ b/docs/build-templates/searx.rst @@ -1,4 +1,4 @@ -.. template evaluated by: ./utils/searx.sh docs +.. template evaluated by: ./utils/searx.sh doc .. hint: all dollar-names are variables, dollar sign itself is quoted by: \\$ .. START distro-packages @@ -81,7 +81,7 @@ ${fedora_build} .. code-block:: sh $ sudo -H -u ${SERVICE_USER} -i - (${SERVICE_USER})$ git clone \"$GIT_URL\" \"$SEARX_SRC\" + (${SERVICE_USER})$ git clone \"$GIT_URL\" \"$SEARXNG_SRC\" .. END clone searxng @@ -93,8 +93,8 @@ ${fedora_build} .. code-block:: sh - (${SERVICE_USER})$ python3 -m venv \"${SEARX_PYENV}\" - (${SERVICE_USER})$ echo \". ${SEARX_PYENV}/bin/activate\" >> \"$SERVICE_HOME/.profile\" + (${SERVICE_USER})$ python3 -m venv \"${SEARXNG_PYENV}\" + (${SERVICE_USER})$ echo \". ${SEARXNG_PYENV}/bin/activate\" >> \"$SERVICE_HOME/.profile\" .. END create virtualenv @@ -109,7 +109,7 @@ ${fedora_build} $ sudo -H -u ${SERVICE_USER} -i (${SERVICE_USER})$ command -v python && python --version - $SEARX_PYENV/bin/python + $SEARXNG_PYENV/bin/python Python 3.8.1 # update pip's boilerplate .. @@ -119,7 +119,7 @@ ${fedora_build} pip install -U pyyaml # jump to SearXNG's working tree and install SearXNG into virtualenv - (${SERVICE_USER})$ cd \"$SEARX_SRC\" + (${SERVICE_USER})$ cd \"$SEARXNG_SRC\" (${SERVICE_USER})$ pip install -e . @@ -134,7 +134,7 @@ ${fedora_build} .. code-block:: sh $ sudo -H mkdir -p \"$(dirname ${SEARXNG_SETTINGS_PATH})\" - $ sudo -H cp \"$SEARX_SRC/utils/templates/etc/searxng/settings.yml\" \\ + $ sudo -H cp \"$SEARXNG_SRC/utils/templates/etc/searxng/settings.yml\" \\ \"${SEARXNG_SETTINGS_PATH}\" .. group-tab:: searx/settings.yml @@ -142,7 +142,7 @@ ${fedora_build} .. code-block:: sh $ sudo -H mkdir -p \"$(dirname ${SEARXNG_SETTINGS_PATH})\" - $ sudo -H cp \"$SEARX_SRC/searx/settings.yml\" \\ + $ sudo -H cp \"$SEARXNG_SRC/searx/settings.yml\" \\ \"${SEARXNG_SETTINGS_PATH}\" .. tabs:: @@ -168,14 +168,14 @@ ${fedora_build} # start webapp $ sudo -H -u ${SERVICE_USER} -i - (${SERVICE_USER})$ cd ${SEARX_SRC} + (${SERVICE_USER})$ cd ${SEARXNG_SRC} (${SERVICE_USER})$ export SEARXNG_SETTINGS_PATH=\"${SEARXNG_SETTINGS_PATH}\" (${SERVICE_USER})$ python searx/webapp.py # disable debug $ sudo -H sed -i -e \"s/debug : True/debug : False/g\" \"$SEARXNG_SETTINGS_PATH\" -Open WEB browser and visit http://$SEARX_INTERNAL_HTTP . If you are inside a +Open WEB browser and visit http://$SEARXNG_INTERNAL_HTTP . If you are inside a container or in a script, test with curl: .. tabs:: @@ -184,13 +184,13 @@ container or in a script, test with curl: .. code-block:: sh - $ xdg-open http://$SEARX_INTERNAL_HTTP + $ xdg-open http://$SEARXNG_INTERNAL_HTTP .. group-tab:: curl .. code-block:: none - $ curl --location --verbose --head --insecure $SEARX_INTERNAL_HTTP + $ curl --location --verbose --head --insecure $SEARXNG_INTERNAL_HTTP * Trying 127.0.0.1:8888... * TCP_NODELAY set diff --git a/utils/filtron.sh b/utils/filtron.sh index 2536214e4..158fd55be 100755 --- a/utils/filtron.sh +++ b/utils/filtron.sh @@ -569,7 +569,7 @@ This installs a reverse proxy (ProxyPass) into nginx site (${NGINX_FILTRON_SITE} "${REPO_ROOT}/utils/searx.sh" install uwsgi # shellcheck disable=SC2034 - SEARX_SRC=$("${REPO_ROOT}/utils/searx.sh" --getenv SEARX_SRC) + SEARXNG_SRC=$("${REPO_ROOT}/utils/searx.sh" --getenv SEARXNG_SRC) # shellcheck disable=SC2034 SEARXNG_URL_PATH=$("${REPO_ROOT}/utils/searx.sh" --getenv SEARXNG_URL_PATH) nginx_install_app --variant=filtron "${NGINX_FILTRON_SITE}" diff --git a/utils/lib_install.sh b/utils/lib_install.sh index 5d84c066f..04bec5d9a 100755 --- a/utils/lib_install.sh +++ b/utils/lib_install.sh @@ -8,7 +8,7 @@ # Initialize installation procedures: # # - Modified source_dot_config function that -# - loads .config.sh from an existing installation (at SEARX_SRC). +# - loads .config.sh from an existing installation (at SEARXNG_SRC). # - initialize **SEARX_SRC_INIT_FILES** # - functions like: # - install_log_searx_instance() @@ -25,13 +25,13 @@ # - utils/morty.sh # - utils/filtron.sh # -# If '${SEARX_SRC}/.config.sh' exists, the modified source_dot_config() function +# If '${SEARXNG_SRC}/.config.sh' exists, the modified source_dot_config() function # loads this configuration (instead of './.config.sh'). # **SEARX_SRC_INIT_FILES** # -# Array of file names to sync into a installation at $SEARX_SRC. The file names -# are relative to the $REPO_ROOT. Set by function init_SEARX_SRC_INIT_FILES(). +# Array of file names to sync into a installation at $SEARXNG_SRC. The file names +# are relative to the $REPO_ROOT. Set by function init_SEARXNG_SRC_INIT_FILES(). # Most often theses are files like: # - .config.sh # - searx/settings.yml @@ -46,25 +46,25 @@ eval orig_"$(declare -f source_dot_config)" source_dot_config() { # Modified source_dot_config function that - # - loads .config.sh from an existing installation (at SEARX_SRC). + # - loads .config.sh from an existing installation (at SEARXNG_SRC). # - initialize SEARX_SRC_INIT_FILES - if [ -z "$eval_SEARX_SRC" ]; then - export eval_SEARX_SRC='true' - SEARX_SRC=$("${REPO_ROOT}/utils/searx.sh" --getenv SEARX_SRC) - SEARX_PYENV=$("${REPO_ROOT}/utils/searx.sh" --getenv SEARX_PYENV) + if [ -z "$eval_SEARXNG_SRC" ]; then + export eval_SEARXNG_SRC='true' + SEARXNG_SRC=$("${REPO_ROOT}/utils/searx.sh" --getenv SEARXNG_SRC) + SEARXNG_PYENV=$("${REPO_ROOT}/utils/searx.sh" --getenv SEARXNG_PYENV) SEARXNG_SETTINGS_PATH=$("${REPO_ROOT}/utils/searx.sh" --getenv SEARXNG_SETTINGS_PATH) - if [ ! -r "${SEARX_SRC}" ]; then - info_msg "not yet cloned: ${SEARX_SRC}" + if [ ! -r "${SEARXNG_SRC}" ]; then + info_msg "not yet cloned: ${SEARXNG_SRC}" orig_source_dot_config return 0 fi - info_msg "using instance at: ${SEARX_SRC}" + info_msg "using instance at: ${SEARXNG_SRC}" # set and log DOT_CONFIG - if [ -r "${SEARX_SRC}/.config.sh" ]; then - info_msg "switching to ${SEARX_SRC}/.config.sh" - DOT_CONFIG="${SEARX_SRC}/.config.sh" + if [ -r "${SEARXNG_SRC}/.config.sh" ]; then + info_msg "switching to ${SEARXNG_SRC}/.config.sh" + DOT_CONFIG="${SEARXNG_SRC}/.config.sh" else info_msg "using local config: ${DOT_CONFIG}" fi @@ -86,7 +86,7 @@ init_SEARX_SRC_INIT_FILES(){ # keep list empty if there is no installation SEARX_SRC_INIT_FILES=() - if [ ! -r "$SEARX_SRC" ]; then + if [ ! -r "$SEARXNG_SRC" ]; then return 0 fi @@ -104,9 +104,9 @@ init_SEARX_SRC_INIT_FILES(){ if [ -z "$fname" ]; then continue fi - if [ -r "${SEARX_SRC}/${fname}" ]; then - # diff "${REPO_ROOT}/${fname}" "${SEARX_SRC}/${fname}" - if ! cmp --silent "${REPO_ROOT}/${fname}" "${SEARX_SRC}/${fname}"; then + if [ -r "${SEARXNG_SRC}/${fname}" ]; then + # diff "${REPO_ROOT}/${fname}" "${SEARXNG_SRC}/${fname}" + if ! cmp --silent "${REPO_ROOT}/${fname}" "${SEARXNG_SRC}/${fname}"; then SEARX_SRC_INIT_FILES+=("${fname}") info_msg "local clone (workingtree), modified file: ./$fname" msg="to update use: sudo -H ./utils/searx.sh install init-src" @@ -120,8 +120,8 @@ install_log_searx_instance() { echo -e "---- SearXNG instance setup ${_BBlue}(status: $(install_searx_get_state))${_creset}" echo -e " SEARXNG_SETTINGS_PATH : ${_BBlue}${SEARXNG_SETTINGS_PATH}${_creset}" - echo -e " SEARX_PYENV : ${_BBlue}${SEARX_PYENV}${_creset}" - echo -e " SEARX_SRC : ${_BBlue}${SEARX_SRC:-none}${_creset}" + echo -e " SEARXNG_PYENV : ${_BBlue}${SEARXNG_PYENV}${_creset}" + echo -e " SEARXNG_SRC : ${_BBlue}${SEARXNG_SRC:-none}${_creset}" echo -e " SEARXNG_URL : ${_BBlue}${SEARXNG_URL:-none}${_creset}" if in_container; then @@ -148,26 +148,26 @@ install_searx_get_state(){ # Prompts a string indicating the status of the installation procedure # # missing-searx-clone: - # There is no clone at ${SEARX_SRC} + # There is no clone at ${SEARXNG_SRC} # missing-searx-pyenv: - # There is no pyenv in ${SEARX_PYENV} + # There is no pyenv in ${SEARXNG_PYENV} # installer-modified: # There are files modified locally in the installer (clone), # see ${SEARX_SRC_INIT_FILES} description. # python-installed: # Scripts can be executed in instance's environment # - user: ${SERVICE_USER} - # - pyenv: ${SEARX_PYENV} + # - pyenv: ${SEARXNG_PYENV} if [ -f /etc/searx/settings.yml ]; then err_msg "settings.yml in /etc/searx/ is deprecated, move file to folder /etc/searxng/" fi - if ! [ -r "${SEARX_SRC}" ]; then + if ! [ -r "${SEARXNG_SRC}" ]; then echo "missing-searx-clone" return fi - if ! [ -f "${SEARX_PYENV}/bin/activate" ]; then + if ! [ -f "${SEARXNG_PYENV}/bin/activate" ]; then echo "missing-searx-pyenv" return fi diff --git a/utils/morty.sh b/utils/morty.sh index c4e7bdf52..28b76947e 100755 --- a/utils/morty.sh +++ b/utils/morty.sh @@ -502,7 +502,7 @@ This installs a reverse proxy (ProxyPass) into nginx site (${NGINX_MORTY_SITE})" "${REPO_ROOT}/utils/searx.sh" install uwsgi # shellcheck disable=SC2034 - SEARX_SRC=$("${REPO_ROOT}/utils/searx.sh" --getenv SEARX_SRC) + SEARXNG_SRC=$("${REPO_ROOT}/utils/searx.sh" --getenv SEARXNG_SRC) # shellcheck disable=SC2034 SEARXNG_URL_PATH=$("${REPO_ROOT}/utils/searx.sh" --getenv SEARXNG_URL_PATH) nginx_install_app "${NGINX_MORTY_SITE}" diff --git a/utils/searx.sh b/utils/searx.sh index ce118ed77..af925e810 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -12,7 +12,7 @@ source "${REPO_ROOT}/utils/lib_install.sh" # config # ---------------------------------------------------------------------------- -SEARX_INTERNAL_HTTP="${SEARXNG_BIND_ADDRESS}:${SEARXNG_PORT}" +SEARXNG_INTERNAL_HTTP="${SEARXNG_BIND_ADDRESS}:${SEARXNG_PORT}" SEARXNG_URL_PATH="${SEARXNG_URL_PATH:-$(echo "${PUBLIC_URL}" \ | sed -e 's,^.*://[^/]*\(/.*\),\1,g')}" @@ -26,12 +26,14 @@ SERVICE_HOME="${SERVICE_HOME_BASE}/${SERVICE_USER}" SERVICE_GROUP="${SERVICE_USER}" GIT_BRANCH="${GIT_BRANCH:-master}" -SEARX_PYENV="${SERVICE_HOME}/searx-pyenv" -SEARX_SRC="${SERVICE_HOME}/searx-src" +SEARXNG_PYENV="${SERVICE_HOME}/searx-pyenv" +SEARXNG_SRC="${SERVICE_HOME}/searx-src" +# shellcheck disable=SC2034 +SEARXNG_STATIC="${SEARXNG_SRC}/searx/static" SEARXNG_SETTINGS_PATH="/etc/searxng/settings.yml" SEARXNG_UWSGI_APP="searxng.ini" # shellcheck disable=SC2034 -SEARX_UWSGI_SOCKET="/run/uwsgi/app/searxng/socket" +SEARXNG_UWSGI_SOCKET="/run/uwsgi/app/searxng/socket" # apt packages SEARX_PACKAGES_debian="\ @@ -153,10 +155,10 @@ shell install / remove :all: complete (de-) installation of SearXNG service :user: add/remove service user '$SERVICE_USER' ($SERVICE_HOME) - :dot-config: copy ./config.sh to ${SEARX_SRC} + :dot-config: copy ./config.sh to ${SEARXNG_SRC} :searx-src: clone $GIT_URL - :init-src: copy files (SEARX_SRC_INIT_FILES) to ${SEARX_SRC} - :pyenv: create/remove virtualenv (python) in $SEARX_PYENV + :init-src: copy files (SEARXNG_SRC_INIT_FILES) to ${SEARXNG_SRC} + :pyenv: create/remove virtualenv (python) in $SEARXNG_PYENV :uwsgi: install SearXNG uWSGI application :settings: reinstall settings from ${SEARXNG_SETTINGS_PATH} :packages: install needed packages from OS package manager @@ -173,7 +175,7 @@ deactivate service stop and deactivate service daemon (systemd unit) inspect :service: run some small tests and inspect service's status and log - :settings: inspect YAML setting from SearXNG instance (${SEARX_SRC}) + :settings: inspect YAML setting from SearXNG instance (${SEARXNG_SRC}) option set one of the available options apache @@ -267,8 +269,8 @@ main() { rst_title "SearXNG (install uwsgi)" verify_continue_install install_searx_uwsgi - if ! service_is_available "http://${SEARX_INTERNAL_HTTP}"; then - err_msg "URL http://${SEARX_INTERNAL_HTTP} not available, check SearXNG & uwsgi setup!" + if ! service_is_available "http://${SEARXNG_INTERNAL_HTTP}"; then + err_msg "URL http://${SEARXNG_INTERNAL_HTTP} not available, check SearXNG & uwsgi setup!" fi ;; packages) @@ -355,8 +357,8 @@ install_all() { test_local_searx wait_key install_searx_uwsgi - if ! service_is_available "http://${SEARX_INTERNAL_HTTP}"; then - err_msg "URL http://${SEARX_INTERNAL_HTTP} not available, check SearXNG & uwsgi setup!" + if ! service_is_available "http://${SEARXNG_INTERNAL_HTTP}"; then + err_msg "URL http://${SEARXNG_INTERNAL_HTTP} not available, check SearXNG & uwsgi setup!" fi if ask_yn "Do you want to inspect the installation?" Ny; then inspect_service @@ -391,7 +393,7 @@ install_check() { uWSGI_app_available "$SEARXNG_UWSGI_APP" \ || err_msg "uWSGI app $SEARXNG_UWSGI_APP not available!" - sudo -H -u "${SERVICE_USER}" "${SEARX_PYENV}/bin/python" "utils/searxng_check.py" + sudo -H -u "${SERVICE_USER}" "${SEARXNG_PYENV}/bin/python" "utils/searxng_check.py" if uWSGI_app_available 'searx.ini'; then warn_msg "old searx.ini uWSGI app exists" @@ -404,7 +406,7 @@ update_searx() { rst_para "fetch from $GIT_URL and reset to origin/$GIT_BRANCH" tee_stderr 0.3 <&1 | prefix_stdout "$_service_prefix" -cd ${SEARX_SRC} +cd ${SEARXNG_SRC} git fetch origin "$GIT_BRANCH" git reset --hard "origin/$GIT_BRANCH" pip install -U pip @@ -458,7 +460,7 @@ EOF } clone_is_available() { - [[ -f "$SEARX_SRC/.git/config" ]] + [[ -f "$SEARXNG_SRC/.git/config" ]] } # shellcheck disable=SC2164 @@ -482,12 +484,12 @@ clone_searx() { warn_msg "take into account, installing branch $GIT_BRANCH while current branch is $(git rev-parse --abbrev-ref HEAD)" fi export SERVICE_HOME - git_clone "$REPO_ROOT" "$SEARX_SRC" \ + git_clone "$REPO_ROOT" "$SEARXNG_SRC" \ "$GIT_BRANCH" "$SERVICE_USER" - pushd "${SEARX_SRC}" > /dev/null + pushd "${SEARXNG_SRC}" > /dev/null tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" -cd "${SEARX_SRC}" +cd "${SEARXNG_SRC}" git remote set-url origin ${GIT_URL} git config user.email "$ADMIN_EMAIL" git config user.name "$ADMIN_NAME" @@ -509,7 +511,7 @@ prompt_installation_status(){ return 0 ;; *) - info_msg "SearXNG instance already installed at: $SEARX_SRC" + info_msg "SearXNG instance already installed at: $SEARXNG_SRC" info_msg "status: ${_BBlue}$(install_searx_get_state)${_creset} " branch="$(git name-rev --name-only HEAD)" remote="$(git config branch."${branch}".remote)" @@ -549,7 +551,7 @@ prompt_installation_setting(){ _state="$(install_searx_get_state)" case $_state in python-installed|installer-modified) - sudo -H -u "${SERVICE_USER}" "${SEARX_PYENV}/bin/python" < ${SEARX_SRC}/${fname}" - cp "${REPO_ROOT}/${fname}" "${SEARX_SRC}/${fname}" + info_msg "copy: ${REPO_ROOT}/${fname} --> ${SEARXNG_SRC}/${fname}" + cp "${REPO_ROOT}/${fname}" "${SEARXNG_SRC}/${fname}" break ;; "diff files") - $DIFF_CMD "${SEARX_SRC}/${fname}" "${REPO_ROOT}/${fname}" + $DIFF_CMD "${SEARXNG_SRC}/${fname}" "${REPO_ROOT}/${fname}" ;; "interactive shell") - backup_file "${SEARX_SRC}/${fname}" + backup_file "${SEARXNG_SRC}/${fname}" echo -e "// edit ${_Red}${dst}${_creset} to your needs" echo -e "// exit with [${_BCyan}CTRL-D${_creset}]" sudo -H -u "${SERVICE_USER}" -i - $DIFF_CMD "${SEARX_SRC}/${fname}" "${REPO_ROOT}/${fname}" + $DIFF_CMD "${SEARXNG_SRC}/${fname}" "${REPO_ROOT}/${fname}" echo echo -e "// ${_BBlack}did you edit file ...${_creset}" echo -en "// ${_Red}${dst}${_creset}" @@ -650,19 +652,19 @@ init_SEARX_SRC(){ } install_DOT_CONFIG(){ - rst_title "Update instance: ${SEARX_SRC}/.config.sh" section + rst_title "Update instance: ${SEARXNG_SRC}/.config.sh" section - if cmp --silent "${REPO_ROOT}/.config.sh" "${SEARX_SRC}/.config.sh"; then - info_msg "${SEARX_SRC}/.config.sh is up to date" + if cmp --silent "${REPO_ROOT}/.config.sh" "${SEARXNG_SRC}/.config.sh"; then + info_msg "${SEARXNG_SRC}/.config.sh is up to date" return 0 fi - diff "${REPO_ROOT}/.config.sh" "${SEARX_SRC}/.config.sh" + diff "${REPO_ROOT}/.config.sh" "${SEARXNG_SRC}/.config.sh" if ! ask_yn "Do you want to copy file .config.sh into instance?" Yn; then return 42 fi - backup_file "${SEARX_SRC}/.config.sh" - cp "${REPO_ROOT}/.config.sh" "${SEARX_SRC}/.config.sh" + backup_file "${SEARXNG_SRC}/.config.sh" + cp "${REPO_ROOT}/.config.sh" "${SEARXNG_SRC}/.config.sh" } install_settings() { @@ -689,30 +691,30 @@ remove_settings() { remove_searx() { rst_title "Drop SearXNG sources" section - if ask_yn "Do you really want to drop SearXNG sources ($SEARX_SRC)?"; then - rm -rf "$SEARX_SRC" + if ask_yn "Do you really want to drop SearXNG sources ($SEARXNG_SRC)?"; then + rm -rf "$SEARXNG_SRC" else rst_para "Leave SearXNG sources unchanged." fi } pyenv_is_available() { - [[ -f "${SEARX_PYENV}/bin/activate" ]] + [[ -f "${SEARXNG_PYENV}/bin/activate" ]] } create_pyenv() { rst_title "Create virtualenv (python)" section echo - if [[ ! -f "${SEARX_SRC}/manage" ]]; then + if [[ ! -f "${SEARXNG_SRC}/manage" ]]; then err_msg "to create pyenv for SearXNG, SearXNG has to be cloned first" return 42 fi - info_msg "create pyenv in ${SEARX_PYENV}" + info_msg "create pyenv in ${SEARXNG_PYENV}" tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" -rm -rf "${SEARX_PYENV}" -python3 -m venv "${SEARX_PYENV}" -grep -qFs -- 'source ${SEARX_PYENV}/bin/activate' ~/.profile \ - || echo 'source ${SEARX_PYENV}/bin/activate' >> ~/.profile +rm -rf "${SEARXNG_PYENV}" +python3 -m venv "${SEARXNG_PYENV}" +grep -qFs -- 'source ${SEARXNG_PYENV}/bin/activate' ~/.profile \ + || echo 'source ${SEARXNG_PYENV}/bin/activate' >> ~/.profile EOF info_msg "inspect python's virtual environment" tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" @@ -725,22 +727,22 @@ pip install -U pip pip install -U setuptools pip install -U wheel pip install -U pyyaml -cd ${SEARX_SRC} +cd ${SEARXNG_SRC} pip install -e . EOF } remove_pyenv() { rst_title "Remove virtualenv (python)" section - if ! ask_yn "Do you really want to drop ${SEARX_PYENV} ?"; then + if ! ask_yn "Do you really want to drop ${SEARXNG_PYENV} ?"; then return fi info_msg "remove pyenv activation from ~/.profile" tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" -grep -v 'source ${SEARX_PYENV}/bin/activate' ~/.profile > ~/.profile.## +grep -v 'source ${SEARXNG_PYENV}/bin/activate' ~/.profile > ~/.profile.## mv ~/.profile.## ~/.profile EOF - rm -rf "${SEARX_PYENV}" + rm -rf "${SEARXNG_PYENV}" } configure_searx() { @@ -748,7 +750,7 @@ configure_searx() { rst_para "Setup SearXNG config located at $SEARXNG_SETTINGS_PATH" echo tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" -cd ${SEARX_SRC} +cd ${SEARXNG_SRC} sed -i -e "s/ultrasecretkey/$(openssl rand -hex 16)/g" "$SEARXNG_SETTINGS_PATH" EOF } @@ -757,8 +759,8 @@ test_local_searx() { rst_title "Testing SearXNG instance localy" section echo - if service_is_available "http://${SEARX_INTERNAL_HTTP}" &>/dev/null; then - err_msg "URL/port http://${SEARX_INTERNAL_HTTP} is already in use, you" + if service_is_available "http://${SEARXNG_INTERNAL_HTTP}" &>/dev/null; then + err_msg "URL/port http://${SEARXNG_INTERNAL_HTTP} is already in use, you" err_msg "should stop that service before starting local tests!" if ! ask_yn "Continue with local tests?"; then return @@ -767,10 +769,10 @@ test_local_searx() { sed -i -e "s/debug: false/debug: true/g" "$SEARXNG_SETTINGS_PATH" tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" export SEARXNG_SETTINGS_PATH="${SEARXNG_SETTINGS_PATH}" -cd ${SEARX_SRC} +cd ${SEARXNG_SRC} timeout 10 python searx/webapp.py & sleep 3 -curl --location --verbose --head --insecure $SEARX_INTERNAL_HTTP +curl --location --verbose --head --insecure $SEARXNG_INTERNAL_HTTP EOF sed -i -e "s/debug: true/debug: false/g" "$SEARXNG_SETTINGS_PATH" } @@ -805,7 +807,7 @@ deactivate_service() { enable_image_proxy() { info_msg "try to enable image_proxy ..." tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" -cd ${SEARX_SRC} +cd ${SEARXNG_SRC} sed -i -e "s/image_proxy: false/image_proxy: true/g" "$SEARXNG_SETTINGS_PATH" EOF uWSGI_restart "$SEARXNG_UWSGI_APP" @@ -814,7 +816,7 @@ EOF disable_image_proxy() { info_msg "try to enable image_proxy ..." tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" -cd ${SEARX_SRC} +cd ${SEARXNG_SRC} sed -i -e "s/image_proxy: true/image_proxy: false/g" "$SEARXNG_SETTINGS_PATH" EOF uWSGI_restart "$SEARXNG_UWSGI_APP" @@ -824,7 +826,7 @@ enable_debug() { warn_msg "Do not enable debug in production environments!!" info_msg "try to enable debug mode ..." tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" -cd ${SEARX_SRC} +cd ${SEARXNG_SRC} sed -i -e "s/debug: false/debug: true/g" "$SEARXNG_SETTINGS_PATH" EOF uWSGI_restart "$SEARXNG_UWSGI_APP" @@ -833,7 +835,7 @@ EOF disable_debug() { info_msg "try to disable debug mode ..." tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" -cd ${SEARX_SRC} +cd ${SEARXNG_SRC} sed -i -e "s/debug: true/debug: false/g" "$SEARXNG_SETTINGS_PATH" EOF uWSGI_restart "$SEARXNG_UWSGI_APP" @@ -903,11 +905,11 @@ EOF lxc_suite_info else info_msg "public URL --> ${PUBLIC_URL}" - info_msg "internal URL --> http://${SEARX_INTERNAL_HTTP}" + info_msg "internal URL --> http://${SEARXNG_INTERNAL_HTTP}" fi - if ! service_is_available "http://${SEARX_INTERNAL_HTTP}"; then - err_msg "uWSGI app (service) at http://${SEARX_INTERNAL_HTTP} is not available!" + if ! service_is_available "http://${SEARXNG_INTERNAL_HTTP}"; then + err_msg "uWSGI app (service) at http://${SEARXNG_INTERNAL_HTTP} is not available!" MSG="${_Green}[${_BCyan}CTRL-C${_Green}] to stop or [${_BCyan}KEY${_Green}] to continue"\ wait_key fi diff --git a/utils/templates/etc/httpd/sites-available/searxng.conf:uwsgi b/utils/templates/etc/httpd/sites-available/searxng.conf:uwsgi index aabc125ae..1e4ee4123 100644 --- a/utils/templates/etc/httpd/sites-available/searxng.conf:uwsgi +++ b/utils/templates/etc/httpd/sites-available/searxng.conf:uwsgi @@ -3,8 +3,8 @@ LoadModule headers_module ${APACHE_MODULES}/mod_headers.so LoadModule proxy_module ${APACHE_MODULES}/mod_proxy.so LoadModule proxy_uwsgi_module ${APACHE_MODULES}/mod_proxy_uwsgi.so -# LoadModule setenvif_module ${APACHE_MODULES}/mod_setenvif.so - +# LoadModule setenvif_module ${APACHE_MODULES}/mod_setenvif.so +# # SetEnvIf Request_URI "${SEARXNG_URL_PATH}" dontlog # CustomLog /dev/null combined env=dontlog @@ -22,6 +22,13 @@ LoadModule proxy_uwsgi_module ${APACHE_MODULES}/mod_proxy_uwsgi.so Allow from all ProxyPreserveHost On - ProxyPass unix:${SEARX_UWSGI_SOCKET}|uwsgi://uwsgi-uds-searx/ + ProxyPass unix:${SEARXNG_UWSGI_SOCKET}|uwsgi://uwsgi-uds-searx/ + +# uWSGI serves the static files and in settings.yml we use:: +# +# ui: +# static_use_hash: true +# +# Alias ${SEARXNG_URL_PATH}/static/ ${SEARXNG_STATIC}/ diff --git a/utils/templates/etc/nginx/default.apps-available/searxng.conf:filtron b/utils/templates/etc/nginx/default.apps-available/searxng.conf:filtron index e25461c47..631f2b265 100644 --- a/utils/templates/etc/nginx/default.apps-available/searxng.conf:filtron +++ b/utils/templates/etc/nginx/default.apps-available/searxng.conf:filtron @@ -12,5 +12,5 @@ location ${SEARXNG_URL_PATH} { } location ${SEARXNG_URL_PATH}/static/ { - alias ${SEARX_SRC}/searx/static/; + alias ${SEARXNG_STATIC}/; } diff --git a/utils/templates/etc/uwsgi/apps-archlinux/searxng.ini b/utils/templates/etc/uwsgi/apps-archlinux/searxng.ini index aaf55a807..931746306 100644 --- a/utils/templates/etc/uwsgi/apps-archlinux/searxng.ini +++ b/utils/templates/etc/uwsgi/apps-archlinux/searxng.ini @@ -16,7 +16,7 @@ env = LANGUAGE=C.UTF-8 env = LC_ALL=C.UTF-8 # chdir to specified directory before apps loading -chdir = ${SEARX_SRC}/searx +chdir = ${SEARXNG_SRC}/searx # SearXNG configuration (settings.yml) env = SEARXNG_SETTINGS_PATH=${SEARXNG_SETTINGS_PATH} @@ -57,10 +57,10 @@ enable-threads = true module = searx.webapp # set PYTHONHOME/virtualenv -virtualenv = ${SEARX_PYENV} +virtualenv = ${SEARXNG_PYENV} # add directory (or glob) to pythonpath -pythonpath = ${SEARX_SRC} +pythonpath = ${SEARXNG_SRC} # speak to upstream @@ -74,20 +74,20 @@ pythonpath = ${SEARX_SRC} # https://uwsgi-docs.readthedocs.io/en/latest/Options.html#plugin-http # Native HTTP support: https://uwsgi-docs.readthedocs.io/en/latest/HTTP.html -http = ${SEARX_INTERNAL_HTTP} +http = ${SEARXNG_INTERNAL_HTTP} # using unix-sockets: # -# On some distributions you need to create the app folder for the sockets:: +# Don't forget to create the folder where the sockets should take place:: # -# mkdir -p ${SEARX_UWSGI_SOCKET} -# chown -R ${SERVICE_USER}:${SERVICE_GROUP} ${SEARX_UWSGI_SOCKET} +# mkdir -p "$(dirname ${SEARXNG_UWSGI_SOCKET})" +# chown -R "${SERVICE_USER}:${SERVICE_GROUP}" "$(dirname ${SEARXNG_UWSGI_SOCKET})" # -# socket = ${SEARX_UWSGI_SOCKET} +# socket = ${SEARXNG_UWSGI_SOCKET} # uwsgi serves the static files # expires set to one year since there are hashes -static-map = /static=${SEARX_SRC}/searx/static +static-map = /static=${SEARXNG_STATIC} static-expires = /* 31557600 static-gzip-all = True offload-threads = %k diff --git a/utils/templates/etc/uwsgi/apps-archlinux/searxng.ini:socket b/utils/templates/etc/uwsgi/apps-archlinux/searxng.ini:socket index e8facda86..158973140 100644 --- a/utils/templates/etc/uwsgi/apps-archlinux/searxng.ini:socket +++ b/utils/templates/etc/uwsgi/apps-archlinux/searxng.ini:socket @@ -16,7 +16,7 @@ env = LANGUAGE=C.UTF-8 env = LC_ALL=C.UTF-8 # chdir to specified directory before apps loading -chdir = ${SEARX_SRC}/searx +chdir = ${SEARXNG_SRC}/searx # SearXNG configuration (settings.yml) env = SEARXNG_SETTINGS_PATH=${SEARXNG_SETTINGS_PATH} @@ -57,10 +57,10 @@ enable-threads = true module = searx.webapp # set PYTHONHOME/virtualenv -virtualenv = ${SEARX_PYENV} +virtualenv = ${SEARXNG_PYENV} # add directory (or glob) to pythonpath -pythonpath = ${SEARX_SRC} +pythonpath = ${SEARXNG_SRC} # speak to upstream @@ -74,20 +74,24 @@ pythonpath = ${SEARX_SRC} # https://uwsgi-docs.readthedocs.io/en/latest/Options.html#plugin-http # Native HTTP support: https://uwsgi-docs.readthedocs.io/en/latest/HTTP.html -# http = ${SEARX_INTERNAL_HTTP} +# http = ${SEARXNG_INTERNAL_HTTP} # using unix-sockets: # -# On some distributions you need to create the app folder for the sockets:: +# Don't forget to create the folder where the sockets should take place:: # -# mkdir -p ${SEARX_UWSGI_SOCKET} -# chown -R ${SERVICE_USER}:${SERVICE_GROUP} ${SEARX_UWSGI_SOCKET} +# mkdir -p "$(dirname ${SEARXNG_UWSGI_SOCKET})" +# chown -R "${SERVICE_USER}:${SERVICE_GROUP}" "$(dirname ${SEARXNG_UWSGI_SOCKET})" # -socket = ${SEARX_UWSGI_SOCKET} +socket = ${SEARXNG_UWSGI_SOCKET} -# uwsgi serves the static files +# uWSGI serves the static files and in settings.yml we use:: +# +# ui: +# static_use_hash: true +# +static-map = /static=${SEARXNG_STATIC} # expires set to one year since there are hashes -static-map = /static=${SEARX_SRC}/searx/static static-expires = /* 31557600 static-gzip-all = True offload-threads = %k diff --git a/utils/templates/etc/uwsgi/apps-available/searxng.ini b/utils/templates/etc/uwsgi/apps-available/searxng.ini index 9dad84c16..1926b446d 100644 --- a/utils/templates/etc/uwsgi/apps-available/searxng.ini +++ b/utils/templates/etc/uwsgi/apps-available/searxng.ini @@ -16,7 +16,7 @@ env = LANGUAGE=C.UTF-8 env = LC_ALL=C.UTF-8 # chdir to specified directory before apps loading -chdir = ${SEARX_SRC}/searx +chdir = ${SEARXNG_SRC}/searx # SearXNG configuration (settings.yml) env = SEARXNG_SETTINGS_PATH=${SEARXNG_SETTINGS_PATH} @@ -56,10 +56,10 @@ enable-threads = true module = searx.webapp # set PYTHONHOME/virtualenv -virtualenv = ${SEARX_PYENV} +virtualenv = ${SEARXNG_PYENV} # add directory (or glob) to pythonpath -pythonpath = ${SEARX_SRC} +pythonpath = ${SEARXNG_SRC} # speak to upstream @@ -73,20 +73,20 @@ pythonpath = ${SEARX_SRC} # https://uwsgi-docs.readthedocs.io/en/latest/Options.html#plugin-http # Native HTTP support: https://uwsgi-docs.readthedocs.io/en/latest/HTTP.html -http = ${SEARX_INTERNAL_HTTP} +http = ${SEARXNG_INTERNAL_HTTP} # using unix-sockets: # -# On some distributions you need to create the app folder for the sockets:: +# Don't forget to create the folder where the sockets should take place:: # -# mkdir -p /run/uwsgi/app/searxng -# chown -R ${SERVICE_USER}:${SERVICE_GROUP} ${SEARX_UWSGI_SOCKET} +# mkdir -p "$(dirname ${SEARXNG_UWSGI_SOCKET})" +# chown -R "${SERVICE_USER}:${SERVICE_GROUP}" "$(dirname ${SEARXNG_UWSGI_SOCKET})" # -# socket = ${SEARX_UWSGI_SOCKET} +# socket = ${SEARXNG_UWSGI_SOCKET} # uwsgi serves the static files # expires set to one year since there are hashes -static-map = /static=${SEARX_SRC}/searx/static +static-map = /static=${SEARXNG_STATIC} static-expires = /* 31557600 static-gzip-all = True offload-threads = %k diff --git a/utils/templates/etc/uwsgi/apps-available/searxng.ini:socket b/utils/templates/etc/uwsgi/apps-available/searxng.ini:socket index c76d084e1..796d18b8e 100644 --- a/utils/templates/etc/uwsgi/apps-available/searxng.ini:socket +++ b/utils/templates/etc/uwsgi/apps-available/searxng.ini:socket @@ -16,7 +16,7 @@ env = LANGUAGE=C.UTF-8 env = LC_ALL=C.UTF-8 # chdir to specified directory before apps loading -chdir = ${SEARX_SRC}/searx +chdir = ${SEARXNG_SRC}/searx # SearXNG configuration (settings.yml) env = SEARXNG_SETTINGS_PATH=${SEARXNG_SETTINGS_PATH} @@ -56,10 +56,10 @@ enable-threads = true module = searx.webapp # set PYTHONHOME/virtualenv -virtualenv = ${SEARX_PYENV} +virtualenv = ${SEARXNG_PYENV} # add directory (or glob) to pythonpath -pythonpath = ${SEARX_SRC} +pythonpath = ${SEARXNG_SRC} # speak to upstream @@ -73,20 +73,24 @@ pythonpath = ${SEARX_SRC} # https://uwsgi-docs.readthedocs.io/en/latest/Options.html#plugin-http # Native HTTP support: https://uwsgi-docs.readthedocs.io/en/latest/HTTP.html -# http = ${SEARX_INTERNAL_HTTP} +# http = ${SEARXNG_INTERNAL_HTTP} # using unix-sockets: # -# On some distributions you need to create the app folder for the sockets:: +# Don't forget to create the folder where the sockets should take place:: # -# mkdir -p ${SEARX_UWSGI_SOCKET} -# chown -R ${SERVICE_USER}:${SERVICE_GROUP} ${SEARX_UWSGI_SOCKET} +# mkdir -p "$(dirname ${SEARXNG_UWSGI_SOCKET})" +# chown -R "${SERVICE_USER}:${SERVICE_GROUP}" "$(dirname ${SEARXNG_UWSGI_SOCKET})" # -socket = ${SEARX_UWSGI_SOCKET} +socket = ${SEARXNG_UWSGI_SOCKET} -# uwsgi serves the static files +# uWSGI serves the static files and in settings.yml we use:: +# +# ui: +# static_use_hash: true +# +static-map = /static=${SEARXNG_STATIC} # expires set to one year since there are hashes -static-map = /static=${SEARX_SRC}/searx/static static-expires = /* 31557600 static-gzip-all = True offload-threads = %k From 782f73540e2d383ea122716507ccd9582918ab51 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Fri, 27 May 2022 18:43:14 +0200 Subject: [PATCH 2/6] [utils/searxng.sh] implement new script to install SearXNG Signed-off-by: Markus Heiser --- Makefile | 3 +- docs/dev/lxcdev.rst | 4 +- docs/utils/index.rst | 7 +- docs/utils/lxc.sh.rst | 46 +- searx/shared/redisdb.py | 6 +- utils/lib.sh | 47 +- utils/lib_install.sh | 7 +- utils/lib_redis.sh | 27 +- utils/{lxc-searx.env => lxc-searxng.env} | 51 +- utils/lxc.sh | 2 +- utils/morty.sh | 2 +- utils/searxng.sh | 894 ++++++++++++++++++ utils/searxng_check.py | 7 + .../etc/httpd/sites-available/searxng.conf | 41 + .../httpd/sites-available/searxng.conf:socket | 41 + .../nginx/default.apps-available/searxng.conf | 29 + .../searxng.conf:socket | 26 + utils/templates/etc/searxng/settings.yml | 78 +- .../etc/uwsgi/apps-archlinux/searxng.ini | 18 +- .../uwsgi/apps-archlinux/searxng.ini:socket | 17 - .../etc/uwsgi/apps-available/searxng.ini | 24 +- .../uwsgi/apps-available/searxng.ini:socket | 23 +- 22 files changed, 1182 insertions(+), 218 deletions(-) rename utils/{lxc-searx.env => lxc-searxng.env} (53%) create mode 100755 utils/searxng.sh create mode 100644 utils/templates/etc/httpd/sites-available/searxng.conf create mode 100644 utils/templates/etc/httpd/sites-available/searxng.conf:socket create mode 100644 utils/templates/etc/nginx/default.apps-available/searxng.conf create mode 100644 utils/templates/etc/nginx/default.apps-available/searxng.conf:socket diff --git a/Makefile b/Makefile index fe28e0f47..f21734793 100644 --- a/Makefile +++ b/Makefile @@ -66,9 +66,10 @@ test.shell: utils/lib_redis.sh \ utils/filtron.sh \ utils/searx.sh \ + utils/searxng.sh \ utils/morty.sh \ utils/lxc.sh \ - utils/lxc-searx.env \ + utils/lxc-searxng.env \ .config.sh $(Q)$(MTOOLS) build_msg TEST "$@ OK" diff --git a/docs/dev/lxcdev.rst b/docs/dev/lxcdev.rst index 597f99925..85b262212 100644 --- a/docs/dev/lxcdev.rst +++ b/docs/dev/lxcdev.rst @@ -91,8 +91,8 @@ fork: $ git clone https://github.com/searxng/searxng.git searxng $ cd searxng -The :ref:`lxc-searx.env` consists of several images, see ``export -LXC_SUITE=(...`` near by :origin:`utils/lxc-searx.env#L19`. For this blog post +The :ref:`lxc-searxng.env` consists of several images, see ``export +LXC_SUITE=(...`` near by :origin:`utils/lxc-searxng.env#L19`. For this blog post we exercise on a archlinux_ image. The container of this image is named ``searx-archlinux``. Lets build the container, but be sure that this container does not already exists, so first lets remove possible old one: diff --git a/docs/utils/index.rst b/docs/utils/index.rst index 2077bbb13..62e02655b 100644 --- a/docs/utils/index.rst +++ b/docs/utils/index.rst @@ -35,10 +35,11 @@ Scripts to maintain services often dispose of common commands and environments. ``FORCE_TIMEOUT`` : environment Sets timeout for interactive prompts. If you want to run a script in batch job, with defaults choices, set ``FORCE_TIMEOUT=0``. By example; to install a - reverse proxy for filtron on all containers of the :ref:`SearXNG suite - ` use :: + SearXNG server and nginx proxy on all containers of the :ref:`SearXNG suite + ` use:: - sudo -H ./utils/lxc.sh cmd -- FORCE_TIMEOUT=0 ./utils/filtron.sh apache install + sudo -H ./utils/lxc.sh cmd -- FORCE_TIMEOUT=0 ./utils/searxng.sh install all + sudo -H ./utils/lxc.sh cmd -- FORCE_TIMEOUT=0 ./utils/searxng.sh install nginx .. _toolboxing setup: diff --git a/docs/utils/lxc.sh.rst b/docs/utils/lxc.sh.rst index f09b033f4..291c4f147 100644 --- a/docs/utils/lxc.sh.rst +++ b/docs/utils/lxc.sh.rst @@ -23,7 +23,7 @@ With the use of *Linux Containers* (LXC_) we can scale our tasks over a stack of containers, what we call the: *lxc suite*. The *SearXNG suite* -(:origin:`lxc-searx.env `) is loaded by default, every time +(:origin:`lxc-searxng.env `) is loaded by default, every time you start the ``lxc.sh`` script (*you do not need to care about*). Before you can start with containers, you need to install and initiate LXD_ @@ -49,7 +49,7 @@ help>`. If you do not want to build all containers, **you can build just one**:: - $ sudo -H ./utils/lxc.sh build searx-ubu1804 + $ sudo -H ./utils/lxc.sh build searx-archlinux *Good to know ...* @@ -62,9 +62,9 @@ of:: In the containers, you can run what ever you want, e.g. to start a bash use:: - $ sudo -H ./utils/lxc.sh cmd searx-ubu1804 bash - INFO: [searx-ubu1804] bash - root@searx-ubu1804:/share/searx# + $ sudo -H ./utils/lxc.sh cmd searx-archlinux bash + INFO: [searx-archlinux] bash + root@searx-archlinux:/share/searxng# If there comes the time you want to **get rid off all** the containers and **clean up local images** just type:: @@ -121,28 +121,26 @@ Install suite ============= To install the complete :ref:`SearXNG suite (includes searx, morty & filtron) -` into all LXC_ use:: +` into all LXC_ use:: $ sudo -H ./utils/lxc.sh install suite -The command above installs a SearXNG suite (see :ref:`installation scripts`). To -get the IP (URL) of the filtron service in the containers use ``show suite`` +The command above installs a SearXNG suite (see :ref:`installation scripts`). +To :ref:`install a nginx ` reverse proxy (or alternatively +use :ref:`apache `):: + + sudo -H ./utils/lxc.sh cmd -- FORCE_TIMEOUT=0 ./utils/searxng.sh install nginx + +To get the IP (URL) of the SearXNG service in the containers use ``show suite`` command. To test instances from containers just open the URLs in your WEB-Browser:: - $ sudo ./utils/lxc.sh show suite | grep filtron - [searx-ubu1604] INFO: (eth0) filtron: http://n.n.n.246:4004/ http://n.n.n.246/searx - [searx-ubu1804] INFO: (eth0) filtron: http://n.n.n.147:4004/ http://n.n.n.147/searx - [searx-ubu1910] INFO: (eth0) filtron: http://n.n.n.140:4004/ http://n.n.n.140/searx - [searx-ubu2004] INFO: (eth0) filtron: http://n.n.n.18:4004/ http://n.n.n.18/searx - [searx-fedora31] INFO: (eth0) filtron: http://n.n.n.46:4004/ http://n.n.n.46/searx - [searx-archlinux] INFO: (eth0) filtron: http://n.n.n.32:4004/ http://n.n.n.32/searx + $ sudo ./utils/lxc.sh show suite | grep SEARXNG_URL -To :ref:`install a nginx ` reverse proxy for filtron and -morty use (or alternatively use :ref:`apache `):: - - sudo -H ./utils/lxc.sh cmd -- FORCE_TIMEOUT=0 ./utils/filtron.sh nginx install - sudo -H ./utils/lxc.sh cmd -- FORCE_TIMEOUT=0 ./utils/morty.sh nginx install + [searxng-ubu2110] SEARXNG_URL : http://n.n.n.147/searxng + [searxng-ubu2004] SEARXNG_URL : http://n.n.n.246/searxng + [searxnggfedora35] SEARXNG_URL : http://n.n.n.140/searxng + [searxng-archlinux] SEARXNG_URL : http://n.n.n.165/searxng Running commands @@ -152,7 +150,7 @@ Running commands :ref:`toolboxing`. By example: to setup a :ref:`buildhosts` and run the Makefile target ``test`` in the archlinux_ container:: - sudo -H ./utils/lxc.sh cmd searx-archlinux ./utils/searx.sh install buildhost + sudo -H ./utils/lxc.sh cmd searx-archlinux ./utils/searxng.sh install buildhost sudo -H ./utils/lxc.sh cmd searx-archlinux make test @@ -164,7 +162,7 @@ The installation procedure to set up a :ref:`build host` takes its time. Installation in all containers will take more time (time for another cup of coffee).:: - sudo -H ./utils/lxc.sh cmd -- ./utils/searx.sh install buildhost + sudo -H ./utils/lxc.sh cmd -- ./utils/searxng.sh install buildhost To build (live) documentation inside a archlinux_ container:: @@ -189,10 +187,10 @@ The ``--help`` output of the script is largely self-explanatory: .. program-output:: ../utils/lxc.sh --help -.. _lxc-searx.env: +.. _lxc-searxng.env: SearXNG suite ============= -.. literalinclude:: ../../utils/lxc-searx.env +.. literalinclude:: ../../utils/lxc-searxng.env :language: bash diff --git a/searx/shared/redisdb.py b/searx/shared/redisdb.py index da71d169c..bb7a0eeb4 100644 --- a/searx/shared/redisdb.py +++ b/searx/shared/redisdb.py @@ -19,10 +19,13 @@ A redis DB connect can be tested by:: """ +import os +import pwd import logging import redis from searx import get_setting + logger = logging.getLogger('searx.shared.redis') _client = None @@ -42,6 +45,7 @@ def init(): logger.info("connected redis DB --> %s", c.acl_whoami()) return True except redis.exceptions.ConnectionError as exc: - logger.error("can't connet redis DB ...") + _pw = pwd.getpwuid(os.getuid()) + logger.error("[%s (%s)] can't connect redis DB ...", _pw.pw_name, _pw.pw_uid) logger.error(" %s", exc) return False diff --git a/utils/lib.sh b/utils/lib.sh index 257c15024..32db47524 100755 --- a/utils/lib.sh +++ b/utils/lib.sh @@ -195,7 +195,7 @@ wait_key(){ [[ -n $_t ]] && _t="-t $_t" printf "$msg" # shellcheck disable=SC2086 - read -r -s -n1 $_t + read -r -s -n1 $_t || true echo clean_stdin } @@ -1027,7 +1027,7 @@ nginx_include_apps_enabled() { local include_directive="include ${NGINX_APPS_ENABLED}/*.conf;" local include_directive_re="^\s*include ${NGINX_APPS_ENABLED}/\*\.conf;" - info_msg "checking existence: '${include_directive}' in file ${server_conf}" + info_msg "checking existence: '${include_directive}' in file ${server_conf}" if grep "${include_directive_re}" "${server_conf}"; then info_msg "OK, already exists." return @@ -1117,7 +1117,7 @@ apache_distro_setup() { APACHE_SITES_AVAILABLE="/etc/httpd/sites-available" APACHE_SITES_ENABLED="/etc/httpd/sites-enabled" APACHE_MODULES="modules" - APACHE_PACKAGES="httpd" + APACHE_PACKAGES="httpd mod_ssl" ;; *) err_msg "$DIST_ID-$DIST_VERS: apache not yet implemented" @@ -1249,8 +1249,6 @@ apache_dissable_site() { # ----- uWSGI_SETUP="${uWSGI_SETUP:=/etc/uwsgi}" -uWSGI_USER= -uWSGI_GROUP= # How distros manage uWSGI apps is very different. From uWSGI POV read: # - https://uwsgi-docs.readthedocs.io/en/latest/Management.html @@ -1276,13 +1274,14 @@ uWSGI_distro_setup() { ;; fedora-*|centos-7) # systemd --> /usr/lib/systemd/system/uwsgi.service - # The unit file starts uWSGI in emperor mode (/etc/uwsgi.ini), see - # - https://uwsgi-docs.readthedocs.io/en/latest/Emperor.html + # Fedora runs uWSGI in emperor-tyrant mode: in Tyrant mode the + # Emperor will run the vassal using the UID/GID of the vassal + # configuration file [1] (user and group of the app .ini file). + # There are some quirks abbout additional POSIX groups in uWSGI + # 2.0.x, read at least: https://github.com/unbit/uwsgi/issues/2099 uWSGI_APPS_AVAILABLE="${uWSGI_SETUP}/apps-available" uWSGI_APPS_ENABLED="${uWSGI_SETUP}.d" uWSGI_PACKAGES="uwsgi" - uWSGI_USER="uwsgi" - uWSGI_GROUP="uwsgi" ;; *) err_msg "$DIST_ID-$DIST_VERS: uWSGI not yet implemented" @@ -1344,30 +1343,6 @@ uWSGI_restart() { esac } -uWSGI_prepare_app() { - - # usage: uWSGI_prepare_app - - [[ -z $1 ]] && die_caller 42 "missing argument " - - local APP="${1%.*}" - - case $DIST_ID-$DIST_VERS in - fedora-*|centos-7) - # in emperor mode, the uwsgi user is the owner of the sockets - info_msg "prepare (uwsgi:uwsgi) /run/uwsgi/app/${APP}" - mkdir -p "/run/uwsgi/app/${APP}" - chown -R "uwsgi:uwsgi" "/run/uwsgi/app/${APP}" - ;; - *) - info_msg "prepare (${SERVICE_USER}:${SERVICE_GROUP}) /run/uwsgi/app/${APP}" - mkdir -p "/run/uwsgi/app/${APP}" - chown -R "${SERVICE_USER}:${SERVICE_GROUP}" "/run/uwsgi/app/${APP}" - ;; - esac -} - - uWSGI_app_available() { # usage: uWSGI_app_available local CONF="$1" @@ -1378,7 +1353,7 @@ uWSGI_app_available() { uWSGI_install_app() { - # usage: uWSGI_install_app [