From 3cf31528f33c2a600cad21952b46a6ebe1e31420 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Tue, 14 Jan 2020 19:26:54 +0100 Subject: utils/searx.sh: add script to install isolated searx service (WIP) WIP: written from scratch / linted but untested Signed-off-by: Markus Heiser --- utils/searx.sh | 349 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 349 insertions(+) create mode 100755 utils/searx.sh (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh new file mode 100755 index 000000000..0d47820b0 --- /dev/null +++ b/utils/searx.sh @@ -0,0 +1,349 @@ +#!/usr/bin/env bash +# -*- coding: utf-8; mode: sh -*- +# shellcheck disable=SC2119 + +# shellcheck source=utils/lib.sh +source "$(dirname "${BASH_SOURCE[0]}")/lib.sh" + +# ---------------------------------------------------------------------------- +# config +# ---------------------------------------------------------------------------- + +SERVICE_NAME="searx" +SERVICE_USER="${SERVICE_NAME}" +# shellcheck disable=SC2034 +SERVICE_GROUP="${SERVICE_USER}" +SERVICE_HOME="/home/${SERVICE_USER}" + +SEARX_GIT_URL="https://github.com/asciimoo/searx.git" +SEARX_GIT_BRANCH="origin/master" + +# FIXME: Arch Linux & RHEL should be added + +SEARX_APT_PACKAGES="\ +libapache2-mod-uwsgi uwsgi uwsgi-plugin-python3 \ + git build-essential libxslt-dev python3-dev python3-babel zlib1g-dev \ + libffi-dev libssl-dev" + +SEARX_VENV="${SEARX_HOME}/searx-venv" +SEARX_SRC="${SEARX_HOME}/searx-src" +SEARX_SETTINGS="${SEARX_SRC}/searx/settings.yml" +SEARX_INSTANCE_NAME="${SEARX_INSTANCE_NAME:-searx@$(uname -n)}" +SEARX_UWSGI_APP="${uWSGI_SETUP}/apps-available/searx.ini" + +# shellcheck disable=SC2034 +CONFIG_FILES=( + "${SEARX_UWSGI_APP}" +) + +# shellcheck disable=SC2034 +CONFIG_BACKUP_ENCRYPTED=( + "${SEARX_SETTINGS}" +) + +# ---------------------------------------------------------------------------- +usage(){ +# ---------------------------------------------------------------------------- + + # shellcheck disable=SC1117 + cat < https://${SEARX_APACHE_DOMAIN}${SEARX_APACHE_URL}" + +} + +update_searx() { + rst_title "Update searx instance" + + echo + tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" +cd ${SEARX_SRC} +cp -f ${SEARX_SETTINGS} ${SEARX_SETTINGS}.backup +git stash push -m "BACKUP -- 'update server' at ($(date))" +git checkout -b "$(basename "$SEARX_GIT_BRANCH")" --track "$SEARX_GIT_BRANCH" +git pull "$SEARX_GIT_BRANCH" +${SEARX_SRC}/manage.sh update_packages +EOF + configure_searx + + rst_title "${SEARX_SETTINGS}" section + rstBlock 'Diff between new setting file (<) and backup (>):' + echo + diff "$SEARX_SETTINGS}" "${SEARX_SETTINGS}.backup" + + local action + choose_one action "What should happen to the settings file? " \ + "keep new configuration" \ + "revert to the old configuration (backup file)" \ + "start interactiv shell" + case $action in + "keep new configuration") + info_msg "continue using new settings file" + ;; + "revert to the old configuration (backup file)") + tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" +cp -f ${SEARX_SETTINGS}.backup ${SEARX_SETTINGS} +EOF + ;; + "start interactiv shell") + interactive_shell + ;; + esac + chown "${SERVICE_USER}:${SERVICE_USER}" "${SEARX_SETTINGS}" + + # shellcheck disable=SC2016 + rst_para 'Diff between local modified settings (<) and $SEARX_GIT_BRANCH branch (>):' + echo + git_diff + wait_key + uWSGI_restart +} + +remove_all() { + rst_title "De-Install $SERVICE_NAME (service)" + remove_service + wait_key + remove_user +} + +assert_user() { + rst_title "user $SERVICE_USER" section + echo + tee_stderr 1 <&1 | prefix_stdout + else + rst_para "Leave HOME folder $(du -sh "$SERVICE_HOME") unchanged." + fi +} + +# shellcheck disable=SC2164 +clone_searx(){ + rst_title "Clone searx sources" section + echo + git_clone "$SEARX_GIT_URL" "$SEARX_SRC" \ + "$SEARX_GIT_BRANCH" "$SERVICE_USER" + + pushd "${SEARX_SRC}" > /dev/null + tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" +cd "${SEARX_SRC}" +git config user.email "$ADMIN_EMAIL" +git config user.name "$ADMIN_NAME" +git checkout "$SEARX_GIT_BRANCH" +EOF + popd > /dev/null +} + +create_venv(){ + rst_title "Create virtualenv (python)" section + + rst_para "Create venv in ${SEARX_VENV} and install needed python packages." + echo + tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" +rm -rf "${SEARX_VENV}" +python3 -m venv "${SEARX_VENV}" +. ${SEARX_VENV}/bin/activate +${SEARX_SRC}/manage.sh update_packages +EOF + tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" +grep -qFs -- 'source ${SEARX_VENV}/bin/activate' ~/.profile \ + || echo 'source ${SEARX_VENV}/bin/activate' >> ~/.profile +EOF + +} + +configure_searx(){ + rst_title "Configure searx" section + rst_para "Setup searx config located at $SEARX_SETTINGS" + echo + tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" +cd ${SEARX_SRC} +sed -i -e "s/ultrasecretkey/$(openssl rand -hex 16)/g" "$SEARX_SETTINGS" +sed -i -e "s/{instance_name}/${SEARX_INSTANCE_NAME}/g" "$SEARX_SETTINGS" +EOF +} + +test_local_searx(){ + rstHeading "Testing searx instance localy" section + echo + tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" +cd ${SEARX_SRC} +sed -i -e "s/debug : False/debug : True/g" "$SEARX_SETTINGS" +timeout 5 python3 searx/webapp.py & +sleep 1 +curl --location --verbose --head --insecure http://127.0.0.1:8888/ +sed -i -e "s/debug : True/debug : False/g" "$SEARX_SETTINGS" +EOF + waitKEY +} + +install_searx_uwsgi() { + rst_title "Install searx's uWSGI app (searx.ini)" section + echo + uWSGI_install_app "$SEARX_UWSGI_APP" +} + +remove_searx_uwsgi() { + rst_title "Remove searx's uWSGI app (searx.ini)" section + echo + uWSGI_remove_app "$SEARX_UWSGI_APP" +} + +activate_service () { + rst_title "Activate $SERVICE_NAME (service)" section + uWSGI_enable_app "$SEARX_UWSGI_APP" +} + +deactivate_service () { + rst_title "De-Activate $SERVICE_NAME (service)" section + uWSGI_disable_app "$SEARX_UWSGI_APP" +} + +interactive_shell(){ + echo "// exit with CTRL-D" + sudo -H -u "${SERVICE_USER}" -i +} + +git_diff(){ + sudo -H -u "${SERVICE_USER}" -i < Date: Thu, 16 Jan 2020 14:01:38 +0100 Subject: utils/searx.sh: add script to install isolated searx service (WIP) Signed-off-by: Markus Heiser --- utils/searx.sh | 110 ++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 78 insertions(+), 32 deletions(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index 0d47820b0..6955f82a2 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# -*- coding: utf-8; mode: sh -*- +# -*- coding: utf-8; mode: sh indent-tabs-mode: nil -*- # shellcheck disable=SC2119 # shellcheck source=utils/lib.sh @@ -15,8 +15,11 @@ SERVICE_USER="${SERVICE_NAME}" SERVICE_GROUP="${SERVICE_USER}" SERVICE_HOME="/home/${SERVICE_USER}" +# shellcheck disable=SC2034 +SEARX_URL="127.0.0.1:8888" + SEARX_GIT_URL="https://github.com/asciimoo/searx.git" -SEARX_GIT_BRANCH="origin/master" +SEARX_GIT_BRANCH="master" # FIXME: Arch Linux & RHEL should be added @@ -25,8 +28,8 @@ libapache2-mod-uwsgi uwsgi uwsgi-plugin-python3 \ git build-essential libxslt-dev python3-dev python3-babel zlib1g-dev \ libffi-dev libssl-dev" -SEARX_VENV="${SEARX_HOME}/searx-venv" -SEARX_SRC="${SEARX_HOME}/searx-src" +SEARX_PYENV="${SERVICE_HOME}/searx-pyenv" +SEARX_SRC="${SERVICE_HOME}/searx-src" SEARX_SETTINGS="${SEARX_SRC}/searx/settings.yml" SEARX_INSTANCE_NAME="${SEARX_INSTANCE_NAME:-searx@$(uname -n)}" SEARX_UWSGI_APP="${uWSGI_SETUP}/apps-available/searx.ini" @@ -51,25 +54,26 @@ usage(){ usage: $(basename "$0") shell - $(basename "$0") install [all|user] + $(basename "$0") install [all|user|pyenv|searx-src] $(basename "$0") update [searx] - $(basename "$0") remove [all] + $(basename "$0") remove [all|user|pyenv|searx-src] $(basename "$0") activate [service] $(basename "$0") deactivate [service] $(basename "$0") show [service] shell start interactive shell from user ${SERVICE_USER} -install / remove all - complete setup of searx service +install / remove + all: complete (de-) installation of searx service + user: add/remove service user '$SERVICE_USER' at $SERVICE_HOME + searx-src: clone $SEARX_GIT_URL + pyenv: create/remove virtualenv (python) in $SEARX_PYENV update searx Update searx installation of user ${SERVICE_USER} activate activate and start service daemon (systemd unit) deactivate service stop and deactivate service daemon (systemd unit) -install user - add service user '$SERVICE_USER' at $SERVICE_HOME show service show service status and log EOF @@ -102,6 +106,8 @@ main(){ case $2 in all) install_all ;; user) assert_user ;; + pyenv) create_pyenv ;; + searx-src) clone_searx ;; *) usage "$_usage"; exit 42;; esac ;; update) @@ -115,6 +121,8 @@ main(){ case $2 in all) remove_all;; user) remove_user ;; + pyenv) remove_pyenv ;; + searx-src) remove_searx ;; *) usage "$_usage"; exit 42;; esac ;; activate) @@ -143,7 +151,7 @@ install_all() { wait_key clone_searx wait_key - create_venv + create_pyenv wait_key configure_searx wait_key @@ -167,7 +175,7 @@ update_searx() { cd ${SEARX_SRC} cp -f ${SEARX_SETTINGS} ${SEARX_SETTINGS}.backup git stash push -m "BACKUP -- 'update server' at ($(date))" -git checkout -b "$(basename "$SEARX_GIT_BRANCH")" --track "$SEARX_GIT_BRANCH" +git checkout -b $SEARX_GIT_BRANCH" --track "$SEARX_GIT_BRANCH" git pull "$SEARX_GIT_BRANCH" ${SEARX_SRC}/manage.sh update_packages EOF @@ -185,16 +193,16 @@ EOF "start interactiv shell" case $action in "keep new configuration") - info_msg "continue using new settings file" - ;; + info_msg "continue using new settings file" + ;; "revert to the old configuration (backup file)") tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" cp -f ${SEARX_SETTINGS}.backup ${SEARX_SETTINGS} EOF - ;; - "start interactiv shell") - interactive_shell - ;; + ;; + "start interactiv shell") + interactive_shell + ;; esac chown "${SERVICE_USER}:${SERVICE_USER}" "${SEARX_SETTINGS}" @@ -208,7 +216,10 @@ EOF remove_all() { rst_title "De-Install $SERVICE_NAME (service)" - remove_service + if ! ask_yn "Do you really want to deinstall $SERVICE_NAME?"; then + return + fi + remove_searx_uwsgi wait_key remove_user } @@ -240,35 +251,71 @@ remove_user() { clone_searx(){ rst_title "Clone searx sources" section echo + SERVICE_HOME="$(sudo -i -u "$SERVICE_USER" echo \$HOME 2>/dev/null)" + if [[ ! "${SERVICE_HOME}" ]]; then + err_msg "to clone searx sources, user $SERVICE_USER hast to be created first" + return 42 + fi + export SERVICE_HOME + git_clone "$SEARX_GIT_URL" "$SEARX_SRC" \ - "$SEARX_GIT_BRANCH" "$SERVICE_USER" + "$SEARX_GIT_BRANCH" "$SERVICE_USER" pushd "${SEARX_SRC}" > /dev/null tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" cd "${SEARX_SRC}" git config user.email "$ADMIN_EMAIL" git config user.name "$ADMIN_NAME" -git checkout "$SEARX_GIT_BRANCH" +git config --list EOF popd > /dev/null } -create_venv(){ - rst_title "Create virtualenv (python)" section +remove_searx() { + rst_title "Drop searx sources" section + if ask_yn "Do you really want to drop searx sources ($SEARX_SRC)?"; then + rm -rf "$SEARX_SRC" + else + rst_para "Leave searx sources unchanged." + fi +} - rst_para "Create venv in ${SEARX_VENV} and install needed python packages." +create_pyenv(){ + rst_title "Create virtualenv (python)" section echo + if [[ ! -f "${SEARX_SRC}/manage.sh" ]]; then + err_msg "to create pyenv for searx, searx has to be cloned first" + return 42 + fi + info_msg "create pyenv in ${SEARX_PYENV}" tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" -rm -rf "${SEARX_VENV}" -python3 -m venv "${SEARX_VENV}" -. ${SEARX_VENV}/bin/activate -${SEARX_SRC}/manage.sh update_packages +rm -rf "${SEARX_PYENV}" +python3 -m venv "${SEARX_PYENV}" +grep -qFs -- 'source ${SEARX_PYENV}/bin/activate' ~/.profile \ + || echo 'source ${SEARX_PYENV}/bin/activate' >> ~/.profile +EOF + info_msg "inspect python's virtual environment" + tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" +command -v python && python --version EOF + wait_key + info_msg "install needed python packages" tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" -grep -qFs -- 'source ${SEARX_VENV}/bin/activate' ~/.profile \ - || echo 'source ${SEARX_VENV}/bin/activate' >> ~/.profile +${SEARX_SRC}/manage.sh update_packages EOF +} +remove_pyenv(){ + rst_title "Remove virtualenv (python)" section + if ! ask_yn "Do you really want to drop ${SEARX_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.## +mv ~/.profile.## ~/.profile +EOF + rm -rf "${SEARX_PYENV}" } configure_searx(){ @@ -283,7 +330,7 @@ EOF } test_local_searx(){ - rstHeading "Testing searx instance localy" section + rst_title "Testing searx instance localy" section echo tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" cd ${SEARX_SRC} @@ -293,7 +340,6 @@ sleep 1 curl --location --verbose --head --insecure http://127.0.0.1:8888/ sed -i -e "s/debug : True/debug : False/g" "$SEARX_SETTINGS" EOF - waitKEY } install_searx_uwsgi() { -- cgit v1.2.3 From 9b5a7f7559faf121e44ba3e7260290bd7efe74bf Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Mon, 20 Jan 2020 16:55:05 +0100 Subject: utils/searx.sh: add script to install isolated searx service First version which serves searx over uwsgi at http://127.0.0.1:8888 Signed-off-by: Markus Heiser --- utils/searx.sh | 137 ++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 116 insertions(+), 21 deletions(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index 6955f82a2..c9adecc8c 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -32,11 +32,11 @@ SEARX_PYENV="${SERVICE_HOME}/searx-pyenv" SEARX_SRC="${SERVICE_HOME}/searx-src" SEARX_SETTINGS="${SEARX_SRC}/searx/settings.yml" SEARX_INSTANCE_NAME="${SEARX_INSTANCE_NAME:-searx@$(uname -n)}" -SEARX_UWSGI_APP="${uWSGI_SETUP}/apps-available/searx.ini" +SEARX_UWSGI_APP="searx.ini" # shellcheck disable=SC2034 CONFIG_FILES=( - "${SEARX_UWSGI_APP}" + "${uWSGI_SETUP}/apps-available/${SEARX_UWSGI_APP}" ) # shellcheck disable=SC2034 @@ -45,7 +45,7 @@ CONFIG_BACKUP_ENCRYPTED=( ) # ---------------------------------------------------------------------------- -usage(){ +usage() { # ---------------------------------------------------------------------------- # shellcheck disable=SC1117 @@ -60,6 +60,7 @@ usage: $(basename "$0") activate [service] $(basename "$0") deactivate [service] $(basename "$0") show [service] + $(basename "$0") option [debug-on|debug-off] shell start interactive shell from user ${SERVICE_USER} @@ -75,12 +76,14 @@ activate deactivate service stop and deactivate service daemon (systemd unit) show service - show service status and log + run some small tests and show service's status and log +option + set one of te available options EOF [ ! -z ${1+x} ] && echo -e "$1" } -main(){ +main() { rst_title "$SERVICE_NAME" part local _usage="ERROR: unknown or missing $1 command $2" @@ -128,13 +131,21 @@ main(){ activate) sudo_or_exit case $2 in - service) activate_service ;; + service) + activate_service; uWSGI_restart ;; *) usage "$_usage"; exit 42;; esac ;; deactivate) sudo_or_exit case $2 in - service) deactivate_service ;; + service) deactivate_service; uWSGI_restart ;; + *) usage "$_usage"; exit 42;; + esac ;; + option) + sudo_or_exit + case $2 in + debug-on) echo; enable_debug ;; + debug-off) echo; disable_debug ;; *) usage "$_usage"; exit 42;; esac ;; *) usage "ERROR: unknown or missing command $1"; exit 42;; @@ -158,6 +169,11 @@ install_all() { test_local_searx wait_key install_searx_uwsgi + if service_is_available; then + info_msg "URL http://$SEARX_URL is available." + else + err_msg "URL http://$SEARX_URL not available, check searx & uwsgi setup!" + fi wait_key # ToDo ... @@ -224,6 +240,10 @@ remove_all() { remove_user } +user_is_available() { + sudo -i -u "$SERVICE_USER" echo \$HOME &>/dev/null +} + assert_user() { rst_title "user $SERVICE_USER" section echo @@ -247,8 +267,12 @@ remove_user() { fi } +clone_is_available() { + [[ -f "$SEARX_SETTINGS" ]] +} + # shellcheck disable=SC2164 -clone_searx(){ +clone_searx() { rst_title "Clone searx sources" section echo SERVICE_HOME="$(sudo -i -u "$SERVICE_USER" echo \$HOME 2>/dev/null)" @@ -280,7 +304,11 @@ remove_searx() { fi } -create_pyenv(){ +pyenv_is_available() { + [[ -f "${SEARX_PYENV}/bin/activate" ]] +} + +create_pyenv() { rst_title "Create virtualenv (python)" section echo if [[ ! -f "${SEARX_SRC}/manage.sh" ]]; then @@ -305,7 +333,7 @@ ${SEARX_SRC}/manage.sh update_packages EOF } -remove_pyenv(){ +remove_pyenv() { rst_title "Remove virtualenv (python)" section if ! ask_yn "Do you really want to drop ${SEARX_PYENV} ?"; then return @@ -318,7 +346,7 @@ EOF rm -rf "${SEARX_PYENV}" } -configure_searx(){ +configure_searx() { rst_title "Configure searx" section rst_para "Setup searx config located at $SEARX_SETTINGS" echo @@ -329,7 +357,7 @@ sed -i -e "s/{instance_name}/${SEARX_INSTANCE_NAME}/g" "$SEARX_SETTINGS" EOF } -test_local_searx(){ +test_local_searx() { rst_title "Testing searx instance localy" section echo tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" @@ -337,7 +365,7 @@ cd ${SEARX_SRC} sed -i -e "s/debug : False/debug : True/g" "$SEARX_SETTINGS" timeout 5 python3 searx/webapp.py & sleep 1 -curl --location --verbose --head --insecure http://127.0.0.1:8888/ +curl --location --verbose --head --insecure $SEARX_URL sed -i -e "s/debug : True/debug : False/g" "$SEARX_SETTINGS" EOF } @@ -354,39 +382,106 @@ remove_searx_uwsgi() { uWSGI_remove_app "$SEARX_UWSGI_APP" } -activate_service () { +activate_service() { rst_title "Activate $SERVICE_NAME (service)" section + echo uWSGI_enable_app "$SEARX_UWSGI_APP" } -deactivate_service () { +deactivate_service() { rst_title "De-Activate $SERVICE_NAME (service)" section + echo uWSGI_disable_app "$SEARX_UWSGI_APP" } -interactive_shell(){ +interactive_shell() { echo "// exit with CTRL-D" sudo -H -u "${SERVICE_USER}" -i } -git_diff(){ +git_diff() { sudo -H -u "${SERVICE_USER}" -i </dev/null +} + +enable_debug() { + info_msg "try to enable debug mode ..." + tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" +cd ${SEARX_SRC} +sed -i -e "s/debug : False/debug : True/g" "$SEARX_SETTINGS" +EOF + uWSGI_restart +} + +disable_debug() { + info_msg "try to disable debug mode ..." + tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" +cd ${SEARX_SRC} +sed -i -e "s/debug : True/debug : False/g" "$SEARX_SETTINGS" +EOF + uWSGI_restart +} + + +show_service() { rst_title "service status & log" echo - systemctl status uwsgi.service + + if user_is_available; then + info_msg "service account $SERVICE_USER available." + else + err_msg "service account $SERVICE_USER not available!" + fi + if service_is_available; then + info_msg "URL http://$SEARX_URL is available." + else + err_msg "URL http://$SEARX_URL not available!" + fi + if pyenv_is_available; then + info_msg "${SEARX_PYENV}/bin/activate is available." + else + err_msg "${SEARX_PYENV}/bin/activate not available!" + fi + if clone_is_available; then + info_msg "Searx software is installed." + else + err_msg "Missing searx software!" + fi + + uWSGI_app_available "$SEARX_UWSGI_APP" \ + || err_msg "uWSGI app $SEARX_UWSGI_APP not available!" + + if uWSGI_app_enabled "$SEARX_UWSGI_APP"; then + info_msg "uWSGI app $SEARX_UWSGI_APP is enabled." + else + err_msg "uWSGI app $SEARX_UWSGI_APP not enabled!" + fi + + local _debug_on + if ask_yn "Enable searx debug mode?"; then + enable_debug + _debug_on=1 + fi + wait_key echo - read -r -s -n1 -t 5 -p "// use CTRL-C to stop monitoring the log" + systemctl status uwsgi.service + read -r -s -n1 -t 2 -p "// use CTRL-C to stop monitoring the log" echo while true; do trap break 2 - journalctl -f -u uwsgi.service + #journalctl -f -u uwsgi.service + tail -f /var/log/uwsgi/app/searx.log done + + if [[ $_debug_on == 1 ]]; then + disable_debug + fi return 0 } -- cgit v1.2.3 From af2f58fc5847756d20741bb4c782f07943b0af60 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Mon, 20 Jan 2020 19:08:56 +0100 Subject: utils/filtron.sh: add script to install filtron middleware (apache) Preparation for the installation of an apache site. Signed-off-by: Markus Heiser --- utils/searx.sh | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index c9adecc8c..a1b1140ed 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -15,7 +15,6 @@ SERVICE_USER="${SERVICE_NAME}" SERVICE_GROUP="${SERVICE_USER}" SERVICE_HOME="/home/${SERVICE_USER}" -# shellcheck disable=SC2034 SEARX_URL="127.0.0.1:8888" SEARX_GIT_URL="https://github.com/asciimoo/searx.git" @@ -34,6 +33,8 @@ SEARX_SETTINGS="${SEARX_SRC}/searx/settings.yml" SEARX_INSTANCE_NAME="${SEARX_INSTANCE_NAME:-searx@$(uname -n)}" SEARX_UWSGI_APP="searx.ini" +APACHE_SITE="searx.conf" + # shellcheck disable=SC2034 CONFIG_FILES=( "${uWSGI_SETUP}/apps-available/${SEARX_UWSGI_APP}" @@ -175,9 +176,12 @@ install_all() { err_msg "URL http://$SEARX_URL not available, check searx & uwsgi setup!" fi wait_key + if apache_is_installed; then + install_apache_site + wait_key + fi # ToDo ... - # install_apache_site # test_public_searx # info_msg "searX --> https://${SEARX_APACHE_DOMAIN}${SEARX_APACHE_URL}" @@ -428,11 +432,12 @@ EOF uWSGI_restart } - show_service() { rst_title "service status & log" echo + apache_is_installed && info_msg "Apache is installed." + if user_is_available; then info_msg "service account $SERVICE_USER available." else @@ -468,9 +473,9 @@ show_service() { enable_debug _debug_on=1 fi - wait_key echo - systemctl status uwsgi.service + systemctl --no-pager -l status uwsgi.service + echo read -r -s -n1 -t 2 -p "// use CTRL-C to stop monitoring the log" echo while true; do @@ -485,6 +490,13 @@ show_service() { return 0 } +install_apache_site() { + rst_title "Install Apache site $APACHE_SITE" section + echo + err_msg "not yet implemented (${APACHE_SITE})"; return 42 + # apache_install_site "${APACHE_SITE}" +} + # ---------------------------------------------------------------------------- main "$@" # ---------------------------------------------------------------------------- -- cgit v1.2.3 From d171fcd56ea0444598c6ae6d6d089dd2488bd64d Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Tue, 21 Jan 2020 18:38:57 +0100 Subject: utils/searx.sh: add apache site searx.conf:uwsgi Signed-off-by: Markus Heiser --- utils/searx.sh | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index a1b1140ed..bd847e549 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -32,8 +32,11 @@ SEARX_SRC="${SERVICE_HOME}/searx-src" SEARX_SETTINGS="${SEARX_SRC}/searx/settings.yml" SEARX_INSTANCE_NAME="${SEARX_INSTANCE_NAME:-searx@$(uname -n)}" SEARX_UWSGI_APP="searx.ini" +SEARX_UWSGI_SOCKET="/run/uwsgi/app/searx/socket" -APACHE_SITE="searx.conf" +# Apache Settings +SEARX_APACHE_URL="/searx" +SEARX_APACHE_SITE="searx.conf" # shellcheck disable=SC2034 CONFIG_FILES=( @@ -55,7 +58,7 @@ usage() { usage: $(basename "$0") shell - $(basename "$0") install [all|user|pyenv|searx-src] + $(basename "$0") install [all|user|pyenv|searx-src|apache] $(basename "$0") update [searx] $(basename "$0") remove [all|user|pyenv|searx-src] $(basename "$0") activate [service] @@ -69,7 +72,8 @@ install / remove all: complete (de-) installation of searx service user: add/remove service user '$SERVICE_USER' at $SERVICE_HOME searx-src: clone $SEARX_GIT_URL - pyenv: create/remove virtualenv (python) in $SEARX_PYENV + pyenv: create/remove virtualenv (python) in $SEARX_PYENV + apache: install apache site for searx-uwsgi app update searx Update searx installation of user ${SERVICE_USER} activate @@ -112,6 +116,7 @@ main() { user) assert_user ;; pyenv) create_pyenv ;; searx-src) clone_searx ;; + apache) install_apache_site ;; *) usage "$_usage"; exit 42;; esac ;; update) @@ -175,16 +180,6 @@ install_all() { else err_msg "URL http://$SEARX_URL not available, check searx & uwsgi setup!" fi - wait_key - if apache_is_installed; then - install_apache_site - wait_key - fi - - # ToDo ... - # test_public_searx - # info_msg "searX --> https://${SEARX_APACHE_DOMAIN}${SEARX_APACHE_URL}" - } update_searx() { @@ -236,6 +231,11 @@ EOF remove_all() { rst_title "De-Install $SERVICE_NAME (service)" + + rst_para "\ +It goes without saying that this script can only be used to remove +installations that were installed with this script." + if ! ask_yn "Do you really want to deinstall $SERVICE_NAME?"; then return fi @@ -491,10 +491,20 @@ show_service() { } install_apache_site() { - rst_title "Install Apache site $APACHE_SITE" section + rst_title "Install Apache site $SEARX_APACHE_SITE" + + rst_para "\ +This installs the searx uwsgi app as apache site. If your server ist public to +the internet you should instead use a reverse proxy (filtron) to block +excessively bot queries." + + ! apache_is_installed && err_msg "Apache is not installed." + + if ! ask_yn "Do you really want to install apache site for searx-uwsgi?"; then + return + fi echo - err_msg "not yet implemented (${APACHE_SITE})"; return 42 - # apache_install_site "${APACHE_SITE}" + apache_install_site --variant=uwsgi "${SEARX_APACHE_SITE}" } # ---------------------------------------------------------------------------- -- cgit v1.2.3 From 971a8264b2e21dd844d2cc2b54686def8ba18c06 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Mon, 27 Jan 2020 19:08:40 +0100 Subject: utils/searx.sh: add apache site searx.conf:uwsgi (WIP) Signed-off-by: Markus Heiser --- utils/searx.sh | 131 +++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 90 insertions(+), 41 deletions(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index bd847e549..3092d2fa9 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash # -*- coding: utf-8; mode: sh indent-tabs-mode: nil -*- +# SPDX-License-Identifier: AGPL-3.0-or-later # shellcheck disable=SC2119 # shellcheck source=utils/lib.sh @@ -9,33 +10,41 @@ source "$(dirname "${BASH_SOURCE[0]}")/lib.sh" # config # ---------------------------------------------------------------------------- -SERVICE_NAME="searx" -SERVICE_USER="${SERVICE_NAME}" +SEARX_PUBLIC_URL="${SEARX_PUBLIC_URL:-https://$(uname -n)/searx}" +SEARX_URL_PATH="${SEARX_URL_PATH:-$(echo "$SEARX_PUBLIC_URL" \ +| sed -e 's,^.*://[^/]*\(/.*\),\1,g') }" +SEARX_INSTANCE_NAME="${SEARX_INSTANCE_NAME:-searx@$(echo "$SEARX_PUBLIC_URL" \ +| sed -e 's,^.*://\([^\:/]*\).*,\1,g') }" + +SERVICE_USER="searx" # shellcheck disable=SC2034 SERVICE_GROUP="${SERVICE_USER}" SERVICE_HOME="/home/${SERVICE_USER}" -SEARX_URL="127.0.0.1:8888" - +SEARX_INTERNAL_URL="127.0.0.1:8888" SEARX_GIT_URL="https://github.com/asciimoo/searx.git" SEARX_GIT_BRANCH="master" - -# FIXME: Arch Linux & RHEL should be added - -SEARX_APT_PACKAGES="\ -libapache2-mod-uwsgi uwsgi uwsgi-plugin-python3 \ - git build-essential libxslt-dev python3-dev python3-babel zlib1g-dev \ - libffi-dev libssl-dev" - SEARX_PYENV="${SERVICE_HOME}/searx-pyenv" SEARX_SRC="${SERVICE_HOME}/searx-src" SEARX_SETTINGS="${SEARX_SRC}/searx/settings.yml" -SEARX_INSTANCE_NAME="${SEARX_INSTANCE_NAME:-searx@$(uname -n)}" SEARX_UWSGI_APP="searx.ini" +# shellcheck disable=SC2034 SEARX_UWSGI_SOCKET="/run/uwsgi/app/searx/socket" +# FIXME: Arch Linux & RHEL should be added + +SEARX_APT_PACKAGES="\ + uwsgi uwsgi-plugin-python3 \ + git build-essential libxslt-dev python3-dev python3-babel zlib1g-dev \ + libffi-dev libssl-dev \ +" + # Apache Settings -SEARX_APACHE_URL="/searx" + +APACHE_APT_PACKAGES="\ + apache2 libapache2-mod-uwsgi \ +" + SEARX_APACHE_SITE="searx.conf" # shellcheck disable=SC2034 @@ -63,7 +72,7 @@ usage: $(basename "$0") remove [all|user|pyenv|searx-src] $(basename "$0") activate [service] $(basename "$0") deactivate [service] - $(basename "$0") show [service] + $(basename "$0") inspect [service] $(basename "$0") option [debug-on|debug-off] shell @@ -80,16 +89,23 @@ activate activate and start service daemon (systemd unit) deactivate service stop and deactivate service daemon (systemd unit) -show service - run some small tests and show service's status and log +inspect service + run some small tests and inspect service's status and log option set one of te available options + +Use environment SEARX_PUBLIC_URL to set public URL of your WEB-Server: + + SEARX_PUBLIC_URL : ${SEARX_PUBLIC_URL} + SEARX_URL_PATH : ${SEARX_URL_PATH} + SEARX_INSTANCE_NAME : ${SEARX_INSTANCE_NAME} + EOF [ ! -z ${1+x} ] && echo -e "$1" } main() { - rst_title "$SERVICE_NAME" part + rst_title "$SEARX_INSTANCE_NAME" part local _usage="ERROR: unknown or missing $1 command $2" @@ -101,11 +117,11 @@ main() { sudo_or_exit interactive_shell ;; - show) + inspect) case $2 in service) sudo_or_exit - show_service + inspect_service ;; *) usage "$_usage"; exit 42;; esac ;; @@ -161,7 +177,7 @@ main() { _service_prefix=" |$SERVICE_USER| " install_all() { - rst_title "Install $SERVICE_NAME (service)" + rst_title "Install $SEARX_INSTANCE_NAME (service)" pkg_install "$SEARX_APT_PACKAGES" wait_key assert_user @@ -175,11 +191,15 @@ install_all() { test_local_searx wait_key install_searx_uwsgi - if service_is_available; then - info_msg "URL http://$SEARX_URL is available." + if service_is_available "http://$SEARX_INTERNAL_URL" &>/dev/null; then + info_msg "URL http://$SEARX_INTERNAL_URL is available." else - err_msg "URL http://$SEARX_URL not available, check searx & uwsgi setup!" + err_msg "URL http://$SEARX_INTERNAL_URL not available, check searx & uwsgi setup!" + fi + if ask_yn "Do you want to inspect the installation?" Yn; then + inspect_service fi + } update_searx() { @@ -230,13 +250,13 @@ EOF } remove_all() { - rst_title "De-Install $SERVICE_NAME (service)" + rst_title "De-Install $SEARX_INSTANCE_NAME (service)" rst_para "\ It goes without saying that this script can only be used to remove installations that were installed with this script." - if ! ask_yn "Do you really want to deinstall $SERVICE_NAME?"; then + if ! ask_yn "Do you really want to deinstall $SEARX_INSTANCE_NAME?"; then return fi remove_searx_uwsgi @@ -364,12 +384,20 @@ EOF test_local_searx() { rst_title "Testing searx instance localy" section echo + + if service_is_available "http://$SEARX_INTERNAL_URL" &>/dev/null; then + err_msg "URL/port http://$SEARX_INTERNAL_URL is already in use, you" + err_msg "should stop that service before starting local tests!" + if ! ask_yn "Continue with local tests?"; then + return + fi + fi tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" cd ${SEARX_SRC} sed -i -e "s/debug : False/debug : True/g" "$SEARX_SETTINGS" timeout 5 python3 searx/webapp.py & sleep 1 -curl --location --verbose --head --insecure $SEARX_URL +curl --location --verbose --head --insecure $SEARX_INTERNAL_URL sed -i -e "s/debug : True/debug : False/g" "$SEARX_SETTINGS" EOF } @@ -387,13 +415,13 @@ remove_searx_uwsgi() { } activate_service() { - rst_title "Activate $SERVICE_NAME (service)" section + rst_title "Activate $SEARX_INSTANCE_NAME (service)" section echo uWSGI_enable_app "$SEARX_UWSGI_APP" } deactivate_service() { - rst_title "De-Activate $SERVICE_NAME (service)" section + rst_title "De-Activate $SEARX_INSTANCE_NAME (service)" section echo uWSGI_disable_app "$SEARX_UWSGI_APP" } @@ -411,7 +439,9 @@ EOF } service_is_available() { - curl --insecure "http://$SEARX_URL" &>/dev/null + curl -H 'Cache-Control: no-cache' -o /dev/null \ + --silent --head --write-out '%{http_code}' --insecure \ + "${1?missing URL argument}" } enable_debug() { @@ -432,42 +462,51 @@ EOF uWSGI_restart } -show_service() { +inspect_service() { rst_title "service status & log" echo apache_is_installed && info_msg "Apache is installed." if user_is_available; then - info_msg "service account $SERVICE_USER available." - else - err_msg "service account $SERVICE_USER not available!" - fi - if service_is_available; then - info_msg "URL http://$SEARX_URL is available." + info_msg "Service account $SERVICE_USER exists." else - err_msg "URL http://$SEARX_URL not available!" + err_msg "Service account $SERVICE_USER does not exists!" fi + if pyenv_is_available; then info_msg "${SEARX_PYENV}/bin/activate is available." else err_msg "${SEARX_PYENV}/bin/activate not available!" fi + if clone_is_available; then info_msg "Searx software is installed." else err_msg "Missing searx software!" fi - uWSGI_app_available "$SEARX_UWSGI_APP" \ - || err_msg "uWSGI app $SEARX_UWSGI_APP not available!" - if uWSGI_app_enabled "$SEARX_UWSGI_APP"; then info_msg "uWSGI app $SEARX_UWSGI_APP is enabled." else err_msg "uWSGI app $SEARX_UWSGI_APP not enabled!" fi + uWSGI_app_available "$SEARX_UWSGI_APP" \ + || err_msg "uWSGI app $SEARX_UWSGI_APP not available!" + + if service_is_available "http://$SEARX_INTERNAL_URL" &>/dev/null; then + info_msg "uWSGI app (service) at http://$SEARX_INTERNAL_URL is available" + else + err_msg "uWSGI app (service) at http://$SEARX_INTERNAL_URL is not available!" + fi + + if service_is_available "${SEARX_PUBLIC_URL}" &>/dev/null; then + info_msg "Public service at ${SEARX_PUBLIC_URL} is available" + else + err_msg "Public service at ${SEARX_PUBLIC_URL} is not available!" + fi + local _debug_on if ask_yn "Enable searx debug mode?"; then enable_debug @@ -503,8 +542,18 @@ excessively bot queries." if ! ask_yn "Do you really want to install apache site for searx-uwsgi?"; then return fi + + pkg_install "$APACHE_APT_PACKAGES" + a2enmod uwsgi + echo apache_install_site --variant=uwsgi "${SEARX_APACHE_SITE}" + + if service_is_available "${SEARX_PUBLIC_URL}" &>/dev/null; then + info_msg "Public service at ${SEARX_PUBLIC_URL} is available" + else + err_msg "Public service at ${SEARX_PUBLIC_URL} is not available!" + fi } # ---------------------------------------------------------------------------- -- cgit v1.2.3 From 924bf6551794e5962688c1e2962dc0c94869e2f1 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Wed, 29 Jan 2020 20:00:50 +0100 Subject: utils/searx.sh & filtron.sh: misc changes from first tests (WIP) Signed-off-by: Markus Heiser --- utils/searx.sh | 116 +++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 72 insertions(+), 44 deletions(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index 3092d2fa9..a352c0439 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -1,19 +1,20 @@ #!/usr/bin/env bash # -*- coding: utf-8; mode: sh indent-tabs-mode: nil -*- # SPDX-License-Identifier: AGPL-3.0-or-later -# shellcheck disable=SC2119 +# shellcheck disable=SC2001 # shellcheck source=utils/lib.sh source "$(dirname "${BASH_SOURCE[0]}")/lib.sh" +source_dot_config # ---------------------------------------------------------------------------- # config # ---------------------------------------------------------------------------- -SEARX_PUBLIC_URL="${SEARX_PUBLIC_URL:-https://$(uname -n)/searx}" -SEARX_URL_PATH="${SEARX_URL_PATH:-$(echo "$SEARX_PUBLIC_URL" \ -| sed -e 's,^.*://[^/]*\(/.*\),\1,g') }" -SEARX_INSTANCE_NAME="${SEARX_INSTANCE_NAME:-searx@$(echo "$SEARX_PUBLIC_URL" \ +SEARX_URL_PATH="${SEARX_URL_PATH:-$(echo "${PUBLIC_URL}" \ +| sed -e 's,^.*://[^/]*\(/.*\),\1,g')}" +[[ "${SEARX_URL_PATH}" == "${PUBLIC_URL}" ]] && SEARX_URL_PATH=/ +SEARX_INSTANCE_NAME="${SEARX_INSTANCE_NAME:-searx@$(echo "$PUBLIC_URL" \ | sed -e 's,^.*://\([^\:/]*\).*,\1,g') }" SERVICE_USER="searx" @@ -42,10 +43,10 @@ SEARX_APT_PACKAGES="\ # Apache Settings APACHE_APT_PACKAGES="\ - apache2 libapache2-mod-uwsgi \ + libapache2-mod-uwsgi \ " -SEARX_APACHE_SITE="searx.conf" +APACHE_SEARX_SITE="searx.conf" # shellcheck disable=SC2034 CONFIG_FILES=( @@ -74,6 +75,7 @@ usage: $(basename "$0") deactivate [service] $(basename "$0") inspect [service] $(basename "$0") option [debug-on|debug-off] + $(basename "$0") apache [install|remove] shell start interactive shell from user ${SERVICE_USER} @@ -82,23 +84,25 @@ install / remove user: add/remove service user '$SERVICE_USER' at $SERVICE_HOME searx-src: clone $SEARX_GIT_URL pyenv: create/remove virtualenv (python) in $SEARX_PYENV - apache: install apache site for searx-uwsgi app update searx Update searx installation of user ${SERVICE_USER} -activate +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 option - set one of te available options + set one of the available options +apache + install: apache site with the searx uwsgi app + remove: apache site ${APACHE_FILTRON_SITE} -Use environment SEARX_PUBLIC_URL to set public URL of your WEB-Server: +If needed change the environment variable PUBLIC_URL of your WEB service in the +${DOT_CONFIG#"$REPO_ROOT/"} file: - SEARX_PUBLIC_URL : ${SEARX_PUBLIC_URL} - SEARX_URL_PATH : ${SEARX_URL_PATH} - SEARX_INSTANCE_NAME : ${SEARX_INSTANCE_NAME} + PUBLIC_URL : ${PUBLIC_URL} + SEARX_INSTANCE_NAME : ${SEARX_INSTANCE_NAME} EOF [ ! -z ${1+x} ] && echo -e "$1" @@ -107,6 +111,10 @@ EOF main() { rst_title "$SEARX_INSTANCE_NAME" part + required_commands \ + dpkg systemctl apt-get install git wget curl \ + || exit + local _usage="ERROR: unknown or missing $1 command $2" case $1 in @@ -132,7 +140,6 @@ main() { user) assert_user ;; pyenv) create_pyenv ;; searx-src) clone_searx ;; - apache) install_apache_site ;; *) usage "$_usage"; exit 42;; esac ;; update) @@ -154,13 +161,13 @@ main() { sudo_or_exit case $2 in service) - activate_service; uWSGI_restart ;; + activate_service ;; *) usage "$_usage"; exit 42;; esac ;; deactivate) sudo_or_exit case $2 in - service) deactivate_service; uWSGI_restart ;; + service) deactivate_service ;; *) usage "$_usage"; exit 42;; esac ;; option) @@ -170,6 +177,14 @@ main() { debug-off) echo; disable_debug ;; *) usage "$_usage"; exit 42;; esac ;; + apache) + sudo_or_exit + case $2 in + install) install_apache_site ;; + remove) remove_apache_site ;; + *) usage "$_usage"; exit 42;; + esac ;; + *) usage "ERROR: unknown or missing command $1"; exit 42;; esac } @@ -191,9 +206,7 @@ install_all() { test_local_searx wait_key install_searx_uwsgi - if service_is_available "http://$SEARX_INTERNAL_URL" &>/dev/null; then - info_msg "URL http://$SEARX_INTERNAL_URL is available." - else + if ! service_is_available "http://$SEARX_INTERNAL_URL"; then err_msg "URL http://$SEARX_INTERNAL_URL not available, check searx & uwsgi setup!" fi if ask_yn "Do you want to inspect the installation?" Yn; then @@ -418,12 +431,14 @@ activate_service() { rst_title "Activate $SEARX_INSTANCE_NAME (service)" section echo uWSGI_enable_app "$SEARX_UWSGI_APP" + uWSGI_restart } deactivate_service() { rst_title "De-Activate $SEARX_INSTANCE_NAME (service)" section echo uWSGI_disable_app "$SEARX_UWSGI_APP" + uWSGI_restart } interactive_shell() { @@ -438,12 +453,6 @@ git --no-pager diff EOF } -service_is_available() { - curl -H 'Cache-Control: no-cache' -o /dev/null \ - --silent --head --write-out '%{http_code}' --insecure \ - "${1?missing URL argument}" -} - enable_debug() { info_msg "try to enable debug mode ..." tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" @@ -464,7 +473,16 @@ EOF inspect_service() { rst_title "service status & log" - echo + cat </dev/null; then - info_msg "uWSGI app (service) at http://$SEARX_INTERNAL_URL is available" - else + if ! service_is_available "http://$SEARX_INTERNAL_URL"; then err_msg "uWSGI app (service) at http://$SEARX_INTERNAL_URL is not available!" fi - if service_is_available "${SEARX_PUBLIC_URL}" &>/dev/null; then - info_msg "Public service at ${SEARX_PUBLIC_URL} is available" - else - err_msg "Public service at ${SEARX_PUBLIC_URL} is not available!" + if ! service_is_available "${PUBLIC_URL}"; then + err_msg "Public service at ${PUBLIC_URL} is not available!" fi local _debug_on @@ -530,7 +544,7 @@ inspect_service() { } install_apache_site() { - rst_title "Install Apache site $SEARX_APACHE_SITE" + rst_title "Install Apache site $APACHE_SEARX_SITE" rst_para "\ This installs the searx uwsgi app as apache site. If your server ist public to @@ -547,13 +561,27 @@ excessively bot queries." a2enmod uwsgi echo - apache_install_site --variant=uwsgi "${SEARX_APACHE_SITE}" + apache_install_site --variant=uwsgi "${APACHE_SEARX_SITE}" - if service_is_available "${SEARX_PUBLIC_URL}" &>/dev/null; then - info_msg "Public service at ${SEARX_PUBLIC_URL} is available" - else - err_msg "Public service at ${SEARX_PUBLIC_URL} is not available!" + if ! service_is_available "${PUBLIC_URL}"; then + err_msg "Public service at ${PUBLIC_URL} is not available!" + fi +} + +remove_apache_site() { + + rst_title "Remove Apache site ${APACHE_SEARX_SITE}" + + rst_para "\ +This removes apache site ${APACHE_SEARX_SITE}." + + ! apache_is_installed && err_msg "Apache is not installed." + + if ! ask_yn "Do you really want to continue?"; then + return fi + + apache_remove_site "${APACHE_SEARX_SITE}" } # ---------------------------------------------------------------------------- -- cgit v1.2.3 From 6274a54746b4444f8850aecea0cb0734c6bdc29c Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Thu, 30 Jan 2020 19:55:51 +0100 Subject: utils/searx.sh & filtron.sh: misc changes from first tests (WIP) Signed-off-by: Markus Heiser --- utils/searx.sh | 3 +++ 1 file changed, 3 insertions(+) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index a352c0439..b036541cf 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -275,6 +275,9 @@ installations that were installed with this script." remove_searx_uwsgi wait_key remove_user + if service_is_available "${PUBLIC_URL}"; then + MSG="** Don't forgett to remove your public site! (${PUBLIC_URL}) **" wait_key 10 + fi } user_is_available() { -- cgit v1.2.3 From cd9b877c8c186925e7eab5088554fcf5fc2ca5d5 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Fri, 31 Jan 2020 15:53:53 +0100 Subject: utils/searx.sh & filtron.sh: misc changes from first tests (WIP) Signed-off-by: Markus Heiser --- utils/searx.sh | 2 ++ 1 file changed, 2 insertions(+) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index b036541cf..359ae7124 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -102,6 +102,7 @@ If needed change the environment variable PUBLIC_URL of your WEB service in the ${DOT_CONFIG#"$REPO_ROOT/"} file: PUBLIC_URL : ${PUBLIC_URL} + PUBLIC_HOST : ${PUBLIC_HOST} SEARX_INSTANCE_NAME : ${SEARX_INSTANCE_NAME} EOF @@ -481,6 +482,7 @@ inspect_service() { sourced ${DOT_CONFIG#"$REPO_ROOT/"} : PUBLIC_URL : ${PUBLIC_URL} + PUBLIC_HOST : ${PUBLIC_HOST} SEARX_URL_PATH : ${SEARX_URL_PATH} SEARX_INSTANCE_NAME : ${SEARX_INSTANCE_NAME} SEARX_INTERNAL_URL : ${SEARX_INTERNAL_URL} -- cgit v1.2.3 From 56a93ee77006499b869b2fa067b72b0171710c61 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Fri, 31 Jan 2020 18:24:31 +0100 Subject: utils/lib.sh: colorize messages Signed-off-by: Markus Heiser --- utils/searx.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index 359ae7124..ad8515d4f 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -445,9 +445,9 @@ deactivate_service() { uWSGI_restart } -interactive_shell() { - echo "// exit with CTRL-D" - sudo -H -u "${SERVICE_USER}" -i +interactive_shell(){ + echo "// exit with ${_BCyan}CTRL-D${_creset}" + sudo -H -u ${SERVICE_USER} -i } git_diff() { @@ -534,7 +534,9 @@ EOF echo systemctl --no-pager -l status uwsgi.service echo - read -r -s -n1 -t 2 -p "// use CTRL-C to stop monitoring the log" + # shellcheck disable=SC2059 + printf "// use ${_BCyan}CTRL-C${_creset} to stop monitoring the log" + read -r -s -n1 -t 2 echo while true; do trap break 2 -- cgit v1.2.3 From 709ac51d331853ad29c4f6de26c695a7aeeca125 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sat, 1 Feb 2020 16:59:27 +0100 Subject: utils/filtron.sh: generalize systemd, accounts and golang tasks Signed-off-by: Markus Heiser --- utils/searx.sh | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index ad8515d4f..47aad286b 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -124,7 +124,7 @@ main() { shell) sudo_or_exit - interactive_shell + interactive_shell "${SERVICE_USER}" ;; inspect) case $2 in @@ -153,7 +153,7 @@ main() { sudo_or_exit case $2 in all) remove_all;; - user) remove_user ;; + user) drop_service_account "${SERVICE_USER}";; pyenv) remove_pyenv ;; searx-src) remove_searx ;; *) usage "$_usage"; exit 42;; @@ -250,7 +250,7 @@ cp -f ${SEARX_SETTINGS}.backup ${SEARX_SETTINGS} EOF ;; "start interactiv shell") - interactive_shell + interactive_shell "${SERVICE_USER}" ;; esac chown "${SERVICE_USER}:${SERVICE_USER}" "${SEARX_SETTINGS}" @@ -275,16 +275,12 @@ installations that were installed with this script." fi remove_searx_uwsgi wait_key - remove_user + drop_service_account "${SERVICE_USER}" if service_is_available "${PUBLIC_URL}"; then MSG="** Don't forgett to remove your public site! (${PUBLIC_URL}) **" wait_key 10 fi } -user_is_available() { - sudo -i -u "$SERVICE_USER" echo \$HOME &>/dev/null -} - assert_user() { rst_title "user $SERVICE_USER" section echo @@ -299,15 +295,6 @@ EOF #echo "export SERVICE_HOME=$SERVICE_HOME" } -remove_user() { - rst_title "Drop $SERVICE_USER HOME" section - if ask_yn "Do you really want to drop $SERVICE_USER home folder?"; then - userdel -r -f "$SERVICE_USER" 2>&1 | prefix_stdout - else - rst_para "Leave HOME folder $(du -sh "$SERVICE_HOME") unchanged." - fi -} - clone_is_available() { [[ -f "$SEARX_SETTINGS" ]] } @@ -445,11 +432,6 @@ deactivate_service() { uWSGI_restart } -interactive_shell(){ - echo "// exit with ${_BCyan}CTRL-D${_creset}" - sudo -H -u ${SERVICE_USER} -i -} - git_diff() { sudo -H -u "${SERVICE_USER}" -i < Date: Sun, 2 Feb 2020 18:14:10 +0100 Subject: utils/morty.sh: add script to install morty result proxy Signed-off-by: Markus Heiser --- utils/searx.sh | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index 47aad286b..204386fa8 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -17,10 +17,11 @@ SEARX_URL_PATH="${SEARX_URL_PATH:-$(echo "${PUBLIC_URL}" \ SEARX_INSTANCE_NAME="${SEARX_INSTANCE_NAME:-searx@$(echo "$PUBLIC_URL" \ | sed -e 's,^.*://\([^\:/]*\).*,\1,g') }" -SERVICE_USER="searx" +SERVICE_NAME="searx" +SERVICE_USER="${SERVICE_USER:-${SERVICE_NAME}}" +SERVICE_HOME="/home/${SERVICE_USER}" # shellcheck disable=SC2034 SERVICE_GROUP="${SERVICE_USER}" -SERVICE_HOME="/home/${SERVICE_USER}" SEARX_INTERNAL_URL="127.0.0.1:8888" SEARX_GIT_URL="https://github.com/asciimoo/searx.git" @@ -65,7 +66,7 @@ usage() { # shellcheck disable=SC1117 cat <&1 | prefix_stdout "$_service_prefix" cd ${SEARX_SRC} @@ -500,8 +501,10 @@ EOF uWSGI_app_available "$SEARX_UWSGI_APP" \ || err_msg "uWSGI app $SEARX_UWSGI_APP not available!" - if ! service_is_available "http://$SEARX_INTERNAL_URL"; then - err_msg "uWSGI app (service) at http://$SEARX_INTERNAL_URL is not available!" + if ! service_is_available "http://${SEARX_INTERNAL_URL}"; then + err_msg "uWSGI app (service) at http://${SEARX_INTERNAL_URL} is not available!" + echo -e "${_Green}stop with [${_BCyan}CTRL-C${_Green}] or .." + wait_key fi if ! service_is_available "${PUBLIC_URL}"; then @@ -514,15 +517,18 @@ EOF _debug_on=1 fi echo - systemctl --no-pager -l status uwsgi.service + systemctl --no-pager -l status "${SERVICE_NAME}" echo + # shellcheck disable=SC2059 + info_msg "public URL --> ${PUBLIC_URL}" + info_msg "internal URL --> http://${SEARX_INTERNAL_URL}" printf "// use ${_BCyan}CTRL-C${_creset} to stop monitoring the log" read -r -s -n1 -t 2 echo while true; do trap break 2 - #journalctl -f -u uwsgi.service + #journalctl -f -u "${SERVICE_NAME}" tail -f /var/log/uwsgi/app/searx.log done -- cgit v1.2.3 From 94ac560dcc85e2e75d3b14706a65eb9488643eb4 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Mon, 3 Feb 2020 13:25:51 +0100 Subject: doc: add descriptions of our tooling box in ./utils Initial started with the scripts for searx, filtron and morty installations. Signed-off-by: Markus Heiser --- utils/searx.sh | 1 + 1 file changed, 1 insertion(+) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index 204386fa8..ec4eaacce 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -104,6 +104,7 @@ If needed, set PUBLIC_URL of your WEB service in the '${DOT_CONFIG#"$REPO_ROOT/" PUBLIC_URL : ${PUBLIC_URL} PUBLIC_HOST : ${PUBLIC_HOST} SEARX_INSTANCE_NAME : ${SEARX_INSTANCE_NAME} + SERVICE_USER : ${SERVICE_USER} EOF [ ! -z ${1+x} ] && echo -e "$1" -- cgit v1.2.3 From 79e1f837ef7e7c402fd6e9dbb167aac695f2aee7 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Tue, 4 Feb 2020 10:39:42 +0100 Subject: utils & Makefile: add .config.mk & .config.sh for searx brands By isolating the environment of makefiles and bash scripts into .config.mk and .config.sh it is simple to maintain searx brands by setting some central environments. Signed-off-by: Markus Heiser --- utils/searx.sh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index ec4eaacce..2b5e92c40 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -11,6 +11,8 @@ source_dot_config # config # ---------------------------------------------------------------------------- +SEARX_INTERNAL_URL="${SEARX_INTERNAL_URL:-127.0.0.1:8888}" + SEARX_URL_PATH="${SEARX_URL_PATH:-$(echo "${PUBLIC_URL}" \ | sed -e 's,^.*://[^/]*\(/.*\),\1,g')}" [[ "${SEARX_URL_PATH}" == "${PUBLIC_URL}" ]] && SEARX_URL_PATH=/ @@ -19,13 +21,13 @@ SEARX_INSTANCE_NAME="${SEARX_INSTANCE_NAME:-searx@$(echo "$PUBLIC_URL" \ SERVICE_NAME="searx" SERVICE_USER="${SERVICE_USER:-${SERVICE_NAME}}" -SERVICE_HOME="/home/${SERVICE_USER}" +SERVICE_HOME_BASE="${SERVICE_HOME_BASE:-/usr/local}" +SERVICE_HOME="${SERVICE_HOME_BASE}/${SERVICE_USER}" # shellcheck disable=SC2034 SERVICE_GROUP="${SERVICE_USER}" -SEARX_INTERNAL_URL="127.0.0.1:8888" -SEARX_GIT_URL="https://github.com/asciimoo/searx.git" -SEARX_GIT_BRANCH="master" +SEARX_GIT_URL="${SEARX_GIT_URL:-https://github.com/asciimoo/searx.git}" +SEARX_GIT_BRANCH="${SEARX_GIT_BRANCH:-master}" SEARX_PYENV="${SERVICE_HOME}/searx-pyenv" SEARX_SRC="${SERVICE_HOME}/searx-src" SEARX_SETTINGS="${SEARX_SRC}/searx/settings.yml" @@ -82,11 +84,11 @@ shell start interactive shell from user ${SERVICE_USER} install / remove :all: complete (de-) installation of searx service - :user: add/remove service user '$SERVICE_USER' at $SERVICE_HOME + :user: add/remove service user '$SERVICE_USER' ($SERVICE_HOME) :searx-src: clone $SEARX_GIT_URL :pyenv: create/remove virtualenv (python) in $SEARX_PYENV update searx - Update searx installation of user ${SERVICE_USER} + Update searx installation ($SERVICE_HOME) activate service activate and start service daemon (systemd unit) deactivate service @@ -521,9 +523,9 @@ EOF systemctl --no-pager -l status "${SERVICE_NAME}" echo - # shellcheck disable=SC2059 info_msg "public URL --> ${PUBLIC_URL}" info_msg "internal URL --> http://${SEARX_INTERNAL_URL}" + # shellcheck disable=SC2059 printf "// use ${_BCyan}CTRL-C${_creset} to stop monitoring the log" read -r -s -n1 -t 2 echo -- cgit v1.2.3 From eedd63ccd504099836d9f528d02daffa6bc826ad Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Tue, 4 Feb 2020 16:42:13 +0100 Subject: docs: revision of the installation instructions Signed-off-by: Markus Heiser --- utils/searx.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index 2b5e92c40..707009a11 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -39,8 +39,9 @@ SEARX_UWSGI_SOCKET="/run/uwsgi/app/searx/socket" SEARX_APT_PACKAGES="\ uwsgi uwsgi-plugin-python3 \ - git build-essential libxslt-dev python3-dev python3-babel zlib1g-dev \ - libffi-dev libssl-dev \ + git build-essential \ + libxslt-dev python3-dev python3-babel\ + zlib1g-dev libffi-dev libssl-dev \ " # Apache Settings -- cgit v1.2.3 From 2f40f61f83afb34f0c4b95019a53050a504ce43a Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Tue, 4 Feb 2020 17:59:58 +0100 Subject: /etc/filtron/rules.json: normalize rules from docs & tooling box Signed-off-by: Markus Heiser --- utils/searx.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index 707009a11..7609a4acf 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -110,7 +110,7 @@ If needed, set PUBLIC_URL of your WEB service in the '${DOT_CONFIG#"$REPO_ROOT/" SERVICE_USER : ${SERVICE_USER} EOF - [ ! -z ${1+x} ] && echo -e "$1" + [ ! -z ${1+x} ] && err_msg "$1" } main() { @@ -120,7 +120,7 @@ main() { dpkg systemctl apt-get install git wget curl \ || exit - local _usage="ERROR: unknown or missing $1 command $2" + local _usage="unknown or missing $1 command $2" case $1 in --source-only) ;; @@ -190,7 +190,7 @@ main() { *) usage "$_usage"; exit 42;; esac ;; - *) usage "ERROR: unknown or missing command $1"; exit 42;; + *) usage "unknown or missing command $1"; exit 42;; esac } -- cgit v1.2.3 From 71d7550dbe750f35f0dd7b5c513bc9e8db9512ee Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Tue, 4 Feb 2020 19:47:33 +0100 Subject: tooling box ./utils/*: minor fix from production test --- utils/searx.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index 7609a4acf..ea6cb1e96 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -110,7 +110,7 @@ If needed, set PUBLIC_URL of your WEB service in the '${DOT_CONFIG#"$REPO_ROOT/" SERVICE_USER : ${SERVICE_USER} EOF - [ ! -z ${1+x} ] && err_msg "$1" + [ ! -z "${1+x}" ] && err_msg "$1" } main() { @@ -403,8 +403,8 @@ test_local_searx() { tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" cd ${SEARX_SRC} sed -i -e "s/debug : False/debug : True/g" "$SEARX_SETTINGS" -timeout 5 python3 searx/webapp.py & -sleep 1 +timeout 10 python3 searx/webapp.py & +sleep 3 curl --location --verbose --head --insecure $SEARX_INTERNAL_URL sed -i -e "s/debug : True/debug : False/g" "$SEARX_SETTINGS" EOF -- cgit v1.2.3 From ed4cb4f1603dc519aa42cc626874f23d2e9db84e Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sat, 8 Feb 2020 13:24:08 +0100 Subject: tooling box: varius fix from tests --- utils/searx.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index ea6cb1e96..f02066ea0 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -235,9 +235,9 @@ EOF configure_searx rst_title "${SEARX_SETTINGS}" section - rstBlock 'Diff between new setting file (<) and backup (>):' + rst_para 'Diff between new setting file (<) and backup (>):' echo - diff "$SEARX_SETTINGS}" "${SEARX_SETTINGS}.backup" + $DIFF_CMD "${SEARX_SETTINGS}" "${SEARX_SETTINGS}.backup" local action choose_one action "What should happen to the settings file? " \ @@ -438,7 +438,7 @@ deactivate_service() { git_diff() { sudo -H -u "${SERVICE_USER}" -i < Date: Sat, 8 Feb 2020 17:12:01 +0100 Subject: tooling box: varius fix from tests Signed-off-by: Markus Heiser --- utils/searx.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index f02066ea0..5eb16700b 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -224,12 +224,13 @@ update_searx() { rst_title "Update searx instance" echo - tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" + tee_stderr 0.3 <&1 | prefix_stdout "$_service_prefix" cd ${SEARX_SRC} cp -f ${SEARX_SETTINGS} ${SEARX_SETTINGS}.backup git stash push -m "BACKUP -- 'update server' at ($(date))" -git checkout -b $SEARX_GIT_BRANCH" --track "$SEARX_GIT_BRANCH" -git pull "$SEARX_GIT_BRANCH" +git checkout -B "$SEARX_GIT_BRANCH" +git pull +cd ${SEARX_SRC} ${SEARX_SRC}/manage.sh update_packages EOF configure_searx -- cgit v1.2.3 From ad3273986024c80cfe067d1b77983901a41b6d01 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sun, 16 Feb 2020 20:07:37 +0100 Subject: shellcheck: fix usse -n instead of ! -z (SC2236 SC2237) - https://www.shellcheck.net/wiki/SC2236 -- Use -n instead of ! -z. - https://www.shellcheck.net/wiki/SC2237 -- Use [ -n .. ] instead of ! [ -z .... Signed-off-by: Markus Heiser --- utils/searx.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index 5eb16700b..73bdd5510 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -110,7 +110,7 @@ If needed, set PUBLIC_URL of your WEB service in the '${DOT_CONFIG#"$REPO_ROOT/" SERVICE_USER : ${SERVICE_USER} EOF - [ ! -z "${1+x}" ] && err_msg "$1" + [[ -n ${1} ]] && err_msg "$1" } main() { -- cgit v1.2.3 From 0bfc61dbe9a7b54b1053f9c92f9ff04d8ff7e1bc Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sun, 16 Feb 2020 22:29:06 +0100 Subject: tooling box: misc fixes from lxc tests Tested by: sudo -H ./utils/lxc.sh build containers sudo -H ./utils/lxc.sh cmd /share/searx/utils/searx.sh install all sudo -H ./utils/lxc.sh cmd /share/searx/utils/filtron.sh install all sudo -H ./utils/lxc.sh cmd /share/searx/utils/morty.sh install all Signed-off-by: Markus Heiser --- utils/searx.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index 73bdd5510..942aa07ce 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -40,7 +40,7 @@ SEARX_UWSGI_SOCKET="/run/uwsgi/app/searx/socket" SEARX_APT_PACKAGES="\ uwsgi uwsgi-plugin-python3 \ git build-essential \ - libxslt-dev python3-dev python3-babel\ + libxslt-dev python3-dev python3-babel python3-venv \ zlib1g-dev libffi-dev libssl-dev \ " -- cgit v1.2.3 From 59e4026762a809fe2a5b5a5a949d7d671f4d989b Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Mon, 17 Feb 2020 18:58:59 +0100 Subject: searx.sh: install settings at /etc/searx/settings.yml Signed-off-by: Markus Heiser --- utils/searx.sh | 132 +++++++++++++++++++++++++++++++-------------------------- 1 file changed, 71 insertions(+), 61 deletions(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index 942aa07ce..1b9bfd42c 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -30,7 +30,7 @@ SEARX_GIT_URL="${SEARX_GIT_URL:-https://github.com/asciimoo/searx.git}" SEARX_GIT_BRANCH="${SEARX_GIT_BRANCH:-master}" SEARX_PYENV="${SERVICE_HOME}/searx-pyenv" SEARX_SRC="${SERVICE_HOME}/searx-src" -SEARX_SETTINGS="${SEARX_SRC}/searx/settings.yml" +SEARX_SETTINGS_PATH="/etc/searx/settings.yml" SEARX_UWSGI_APP="searx.ini" # shellcheck disable=SC2034 SEARX_UWSGI_SOCKET="/run/uwsgi/app/searx/socket" @@ -59,7 +59,7 @@ CONFIG_FILES=( # shellcheck disable=SC2034 CONFIG_BACKUP_ENCRYPTED=( - "${SEARX_SETTINGS}" + "${SEARX_SETTINGS_PATH}" ) # ---------------------------------------------------------------------------- @@ -88,6 +88,7 @@ install / remove :user: add/remove service user '$SERVICE_USER' ($SERVICE_HOME) :searx-src: clone $SEARX_GIT_URL :pyenv: create/remove virtualenv (python) in $SEARX_PYENV + :settings: reinstall settings from ${REPO_ROOT}/searx/settings.yml update searx Update searx installation ($SERVICE_HOME) activate service @@ -102,6 +103,8 @@ apache :install: apache site with the searx uwsgi app :remove: apache site ${APACHE_FILTRON_SITE} +searx settings: ${SEARX_SETTINGS_PATH} + If needed, set PUBLIC_URL of your WEB service in the '${DOT_CONFIG#"$REPO_ROOT/"}' file:: PUBLIC_URL : ${PUBLIC_URL} @@ -145,6 +148,7 @@ main() { user) assert_user ;; pyenv) create_pyenv ;; searx-src) clone_searx ;; + settings) install_settings ;; *) usage "$_usage"; exit 42;; esac ;; update) @@ -206,7 +210,7 @@ install_all() { wait_key create_pyenv wait_key - configure_searx + install_settings wait_key test_local_searx wait_key @@ -217,7 +221,6 @@ install_all() { if ask_yn "Do you want to inspect the installation?" Yn; then inspect_service fi - } update_searx() { @@ -226,45 +229,11 @@ update_searx() { echo tee_stderr 0.3 <&1 | prefix_stdout "$_service_prefix" cd ${SEARX_SRC} -cp -f ${SEARX_SETTINGS} ${SEARX_SETTINGS}.backup -git stash push -m "BACKUP -- 'update server' at ($(date))" git checkout -B "$SEARX_GIT_BRANCH" git pull -cd ${SEARX_SRC} ${SEARX_SRC}/manage.sh update_packages EOF - configure_searx - - rst_title "${SEARX_SETTINGS}" section - rst_para 'Diff between new setting file (<) and backup (>):' - echo - $DIFF_CMD "${SEARX_SETTINGS}" "${SEARX_SETTINGS}.backup" - - local action - choose_one action "What should happen to the settings file? " \ - "keep new configuration" \ - "revert to the old configuration (backup file)" \ - "start interactiv shell" - case $action in - "keep new configuration") - info_msg "continue using new settings file" - ;; - "revert to the old configuration (backup file)") - tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" -cp -f ${SEARX_SETTINGS}.backup ${SEARX_SETTINGS} -EOF - ;; - "start interactiv shell") - interactive_shell "${SERVICE_USER}" - ;; - esac - chown "${SERVICE_USER}:${SERVICE_USER}" "${SEARX_SETTINGS}" - - # shellcheck disable=SC2016 - rst_para 'Diff between local modified settings (<) and $SEARX_GIT_BRANCH branch (>):' - echo - git_diff - wait_key + install_settings uWSGI_restart } @@ -279,8 +248,9 @@ installations that were installed with this script." return fi remove_searx_uwsgi - wait_key drop_service_account "${SERVICE_USER}" + remove_settings + wait_key if service_is_available "${PUBLIC_URL}"; then MSG="** Don't forgett to remove your public site! (${PUBLIC_URL}) **" wait_key 10 fi @@ -301,7 +271,7 @@ EOF } clone_is_available() { - [[ -f "$SEARX_SETTINGS" ]] + [[ -f "$SEARX_SRC/.git/config" ]] } # shellcheck disable=SC2164 @@ -314,13 +284,13 @@ clone_searx() { return 42 fi export SERVICE_HOME - - git_clone "$SEARX_GIT_URL" "$SEARX_SRC" \ + git_clone "$REPO_ROOT" "$SEARX_SRC" \ "$SEARX_GIT_BRANCH" "$SERVICE_USER" pushd "${SEARX_SRC}" > /dev/null tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" cd "${SEARX_SRC}" +git remote set-url origin ${SEARX_GIT_URL} git config user.email "$ADMIN_EMAIL" git config user.name "$ADMIN_NAME" git config --list @@ -328,6 +298,52 @@ EOF popd > /dev/null } +install_settings() { + rst_title "${SEARX_SETTINGS_PATH}" section + if ! clone_is_available; then + err_msg "you have to install searx first" + exit 42 + fi + mkdir -p "$(dirname ${SEARX_SETTINGS_PATH})" + + if [[ ! -f ${SEARX_SETTINGS_PATH} ]]; then + info_msg "install settings ${REPO_ROOT}/searx/settings.yml" + info_msg " --> ${SEARX_SETTINGS_PATH}" + cp "${REPO_ROOT}/searx/settings.yml" "${SEARX_SETTINGS_PATH}" + configure_searx + return + fi + + rst_para "Diff between origin's setting file (-) and current (+):" + echo + $DIFF_CMD "${SEARX_SRC}/searx/settings.yml" "${SEARX_SETTINGS_PATH}" + + local action + choose_one action "What should happen to the settings file? " \ + "keep new configuration" \ + "start interactiv shell" + case $action in + "keep new configuration") + info_msg "continue using new settings file" + ;; + "start interactiv shell") + echo -e "// exit with [${_BCyan}CTRL-D${_creset}]" + sudo -H -i + rst_para 'Diff between new setting file (-) and current (+):' + echo + $DIFF_CMD "${SEARX_SRC}/searx/settings.yml" "${SEARX_SETTINGS_PATH}" + wait_key + ;; + esac +} + +remove_settings() { + rst_title "remove searx settings" section + echo + info_msg "delete ${SEARX_SETTINGS_PATH}" + rm -f "${SEARX_SETTINGS_PATH}" +} + remove_searx() { rst_title "Drop searx sources" section if ask_yn "Do you really want to drop searx sources ($SEARX_SRC)?"; then @@ -381,12 +397,12 @@ EOF configure_searx() { rst_title "Configure searx" section - rst_para "Setup searx config located at $SEARX_SETTINGS" + rst_para "Setup searx config located at $SEARX_SETTINGS_PATH" echo - tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" + tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" cd ${SEARX_SRC} -sed -i -e "s/ultrasecretkey/$(openssl rand -hex 16)/g" "$SEARX_SETTINGS" -sed -i -e "s/{instance_name}/${SEARX_INSTANCE_NAME}/g" "$SEARX_SETTINGS" +sed -i -e "s/ultrasecretkey/$(openssl rand -hex 16)/g" "$SEARX_SETTINGS_PATH" +sed -i -e "s/{instance_name}/${SEARX_INSTANCE_NAME}/g" "$SEARX_SETTINGS_PATH" EOF } @@ -401,14 +417,15 @@ test_local_searx() { return fi fi + sed -i -e "s/debug : False/debug : True/g" "$SEARX_SETTINGS_PATH" tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" +export SEARX_SETTINGS_PATH="${SEARX_SETTINGS_PATH}" cd ${SEARX_SRC} -sed -i -e "s/debug : False/debug : True/g" "$SEARX_SETTINGS" timeout 10 python3 searx/webapp.py & sleep 3 curl --location --verbose --head --insecure $SEARX_INTERNAL_URL -sed -i -e "s/debug : True/debug : False/g" "$SEARX_SETTINGS" EOF + sed -i -e "s/debug : True/debug : False/g" "$SEARX_SETTINGS_PATH" } install_searx_uwsgi() { @@ -437,28 +454,21 @@ deactivate_service() { uWSGI_restart } -git_diff() { - sudo -H -u "${SERVICE_USER}" -i <&1 | prefix_stdout "$_service_prefix" + tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" cd ${SEARX_SRC} -sed -i -e "s/debug : False/debug : True/g" "$SEARX_SETTINGS" +sed -i -e "s/debug : False/debug : True/g" "$SEARX_SETTINGS_PATH" EOF uWSGI_restart } disable_debug() { info_msg "try to disable debug mode ..." - tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" + tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" cd ${SEARX_SRC} -sed -i -e "s/debug : True/debug : False/g" "$SEARX_SETTINGS" +sed -i -e "s/debug : True/debug : False/g" "$SEARX_SETTINGS_PATH" EOF uWSGI_restart } @@ -513,7 +523,7 @@ EOF fi if ! service_is_available "${PUBLIC_URL}"; then - err_msg "Public service at ${PUBLIC_URL} is not available!" + warn_msg "Public service at ${PUBLIC_URL} is not available!" fi local _debug_on -- cgit v1.2.3 From 5fb6d4f508d9744a8d82160ca184729514bc18c8 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sun, 23 Feb 2020 12:10:45 +0100 Subject: LXC: normalize package installation & user creation. utils/lib.sh: - get DIST_ID & DIST_VERSION from /etc/os-release - pkg_[install|remove|...] supports ubuntu, debian, archlinux & fedora utils/lxc.sh - Workaround for the "setrlimit(RLIMIT_CORE): Operation not permitted" error:: 'Set disable_coredump false' >> /etc/sudo.conf utils/[searx.sh|filtron.sh|morty.sh] - switched user creation from 'adduser' perl script to 'useradd' built-in command utils/searx.sh - install packages for ubuntu, debian, archlinux & fedora Signed-off-by: Markus Heiser --- utils/searx.sh | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index 1b9bfd42c..0d011ef0a 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -35,14 +35,26 @@ SEARX_UWSGI_APP="searx.ini" # shellcheck disable=SC2034 SEARX_UWSGI_SOCKET="/run/uwsgi/app/searx/socket" -# FIXME: Arch Linux & RHEL should be added - -SEARX_APT_PACKAGES="\ - uwsgi uwsgi-plugin-python3 \ - git build-essential \ - libxslt-dev python3-dev python3-babel python3-venv \ - zlib1g-dev libffi-dev libssl-dev \ -" +case $DIST_ID in + ubuntu|debian) # apt packages + SEARX_PACKAGES="\ + python3-dev python3-babel python3-venv \ + uwsgi uwsgi-plugin-python3 \ + git build-essential libxslt-dev zlib1g-dev libffi-dev libssl-dev " + ;; + arch) # pacman packages + SEARX_PACKAGES="\ + python python-pip python-lxml python-babel \ + uwsgi uwsgi-plugin-python \ + git base-devel libxml2 " + ;; + fedora) # dnf packages + SEARX_PACKAGES="\ + python python-pip python-lxml python-babel \ + uwsgi uwsgi-plugin-python3 \ + git @development-tools libxml2 " + ;; +esac # Apache Settings @@ -72,7 +84,7 @@ usage() { usage:: $(basename "$0") shell - $(basename "$0") install [all|user|pyenv|searx-src|apache] + $(basename "$0") install [all|user|searx-src|pyenv|apache] $(basename "$0") update [searx] $(basename "$0") remove [all|user|pyenv|searx-src] $(basename "$0") activate [service] @@ -120,7 +132,7 @@ main() { rst_title "$SEARX_INSTANCE_NAME" part required_commands \ - dpkg systemctl apt-get install git wget curl \ + sudo systemctl install git wget curl \ || exit local _usage="unknown or missing $1 command $2" @@ -202,7 +214,7 @@ _service_prefix=" |$SERVICE_USER| " install_all() { rst_title "Install $SEARX_INSTANCE_NAME (service)" - pkg_install "$SEARX_APT_PACKAGES" + pkg_install "$SEARX_PACKAGES" wait_key assert_user wait_key @@ -260,9 +272,11 @@ assert_user() { rst_title "user $SERVICE_USER" section echo tee_stderr 1 < Date: Sun, 23 Feb 2020 21:05:22 +0100 Subject: utils/serx.sh: make uWSGI installation available for all distros (WIP) Signed-off-by: Markus Heiser --- utils/searx.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index 0d011ef0a..2bf26bba4 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -66,7 +66,7 @@ APACHE_SEARX_SITE="searx.conf" # shellcheck disable=SC2034 CONFIG_FILES=( - "${uWSGI_SETUP}/apps-available/${SEARX_UWSGI_APP}" + "${uWSGI_APPS_AVAILABLE}/${SEARX_UWSGI_APP}" ) # shellcheck disable=SC2034 @@ -246,7 +246,7 @@ git pull ${SEARX_SRC}/manage.sh update_packages EOF install_settings - uWSGI_restart + uWSGI_restart "$SEARX_UWSGI_APP" } remove_all() { @@ -458,14 +458,14 @@ activate_service() { rst_title "Activate $SEARX_INSTANCE_NAME (service)" section echo uWSGI_enable_app "$SEARX_UWSGI_APP" - uWSGI_restart + uWSGI_restart "$SEARX_UWSGI_APP" } deactivate_service() { rst_title "De-Activate $SEARX_INSTANCE_NAME (service)" section echo uWSGI_disable_app "$SEARX_UWSGI_APP" - uWSGI_restart + uWSGI_restart "$SEARX_UWSGI_APP" } enable_debug() { @@ -475,7 +475,7 @@ enable_debug() { cd ${SEARX_SRC} sed -i -e "s/debug : False/debug : True/g" "$SEARX_SETTINGS_PATH" EOF - uWSGI_restart + uWSGI_restart "$SEARX_UWSGI_APP" } disable_debug() { @@ -484,7 +484,7 @@ disable_debug() { cd ${SEARX_SRC} sed -i -e "s/debug : True/debug : False/g" "$SEARX_SETTINGS_PATH" EOF - uWSGI_restart + uWSGI_restart "$SEARX_UWSGI_APP" } inspect_service() { -- cgit v1.2.3 From d5917cc029e2736b11412a570470c666af093ec9 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Tue, 25 Feb 2020 20:20:17 +0100 Subject: utils/lib.sh: make uWSGI installation available for all distros support: ubuntu, debin, fedora, archlinux Signed-off-by: Markus Heiser --- utils/searx.sh | 3 +++ 1 file changed, 3 insertions(+) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index 2bf26bba4..c6f58b6a9 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -43,6 +43,9 @@ case $DIST_ID in git build-essential libxslt-dev zlib1g-dev libffi-dev libssl-dev " ;; arch) # pacman packages + # FIXME: + # - /usr/lib/uwsgi/http_plugin.so: cannot open shared object file: No such file or directory !!! + # - /usr/lib/uwsgi/systemd_logger_plugin.so: cannot open shared object file: No such file or directory !!! SEARX_PACKAGES="\ python python-pip python-lxml python-babel \ uwsgi uwsgi-plugin-python \ -- cgit v1.2.3 From af6acd3417bf53c151b9ba6068186c1e472a2776 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Wed, 26 Feb 2020 19:07:55 +0100 Subject: LXC: install searx-suite installs searx, filtron & morty on all containers Signed-off-by: Markus Heiser --- utils/searx.sh | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index c6f58b6a9..270c30ace 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -43,9 +43,6 @@ case $DIST_ID in git build-essential libxslt-dev zlib1g-dev libffi-dev libssl-dev " ;; arch) # pacman packages - # FIXME: - # - /usr/lib/uwsgi/http_plugin.so: cannot open shared object file: No such file or directory !!! - # - /usr/lib/uwsgi/systemd_logger_plugin.so: cannot open shared object file: No such file or directory !!! SEARX_PACKAGES="\ python python-pip python-lxml python-babel \ uwsgi uwsgi-plugin-python \ @@ -233,7 +230,7 @@ install_all() { if ! service_is_available "http://$SEARX_INTERNAL_URL"; then err_msg "URL http://$SEARX_INTERNAL_URL not available, check searx & uwsgi setup!" fi - if ask_yn "Do you want to inspect the installation?" Yn; then + if ask_yn "Do you want to inspect the installation?" Ny; then inspect_service fi } @@ -331,19 +328,26 @@ install_settings() { return fi - rst_para "Diff between origin's setting file (-) and current (+):" + rst_para "Diff between origin's setting file (+) and current (-):" echo - $DIFF_CMD "${SEARX_SRC}/searx/settings.yml" "${SEARX_SETTINGS_PATH}" + $DIFF_CMD "${SEARX_SETTINGS_PATH}" "${SEARX_SRC}/searx/settings.yml" local action choose_one action "What should happen to the settings file? " \ - "keep new configuration" \ + "keep configuration unchanged" \ + "use origin settings" \ "start interactiv shell" case $action in - "keep new configuration") - info_msg "continue using new settings file" + "keep configuration unchanged") + info_msg "leave settings file unchanged" + ;; + "use origin settings") + backup_file "${SEARX_SETTINGS_PATH}" + info_msg "install origin settings" + cp "${SEARX_SRC}/searx/settings.yml" "${SEARX_SETTINGS_PATH}" ;; "start interactiv shell") + backup_file "${SEARX_SETTINGS_PATH}" echo -e "// exit with [${_BCyan}CTRL-D${_creset}]" sudo -H -i rst_para 'Diff between new setting file (-) and current (+):' -- cgit v1.2.3 From 37c135f2cec6113aa2baaf1b52fe46fd64265975 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Thu, 27 Feb 2020 19:13:03 +0100 Subject: LXC: improved UX when working with a bunch of containers Signed-off-by: Markus Heiser --- utils/searx.sh | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index 270c30ace..c435b5c00 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -210,7 +210,7 @@ main() { esac } -_service_prefix=" |$SERVICE_USER| " +_service_prefix=" ${_Yellow}|$SERVICE_USER|${_creset} " install_all() { rst_title "Install $SEARX_INSTANCE_NAME (service)" @@ -352,7 +352,7 @@ install_settings() { sudo -H -i rst_para 'Diff between new setting file (-) and current (+):' echo - $DIFF_CMD "${SEARX_SRC}/searx/settings.yml" "${SEARX_SETTINGS_PATH}" + $DIFF_CMD "${SEARX_SRC}/searx/settings.yml" "${SEARX_SETTINGS_PATH}" wait_key ;; esac @@ -440,7 +440,7 @@ test_local_searx() { fi sed -i -e "s/debug : False/debug : True/g" "$SEARX_SETTINGS_PATH" tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" -export SEARX_SETTINGS_PATH="${SEARX_SETTINGS_PATH}" +export SEARX_SETTINGS_PATH="${SEARX_SETTINGS_PATH}" cd ${SEARX_SRC} timeout 10 python3 searx/webapp.py & sleep 3 @@ -537,6 +537,18 @@ EOF uWSGI_app_available "$SEARX_UWSGI_APP" \ || err_msg "uWSGI app $SEARX_UWSGI_APP not available!" + if is_container; then + warn_msg "runnning inside container ..." + for ip in $(hostname -I); do + if [[ $ip =~ .*:.* ]]; then + info_msg " public HTTP service (IPv6) --> http://[$ip]" + else + info_msg " public HTTP service (IPv4) --> http://$ip" + fi + done + warn_msg "SEARX_INTERNAL_URL not available from outside" + fi + if ! service_is_available "http://${SEARX_INTERNAL_URL}"; then err_msg "uWSGI app (service) at http://${SEARX_INTERNAL_URL} is not available!" echo -e "${_Green}stop with [${_BCyan}CTRL-C${_Green}] or .." @@ -545,6 +557,9 @@ EOF if ! service_is_available "${PUBLIC_URL}"; then warn_msg "Public service at ${PUBLIC_URL} is not available!" + if is_container; then + warn_msg "Check if public name is correct and routed or use the public IP from above." + fi fi local _debug_on -- cgit v1.2.3 From 491cb95a1f910e17ac022ddfa73b68aae2fbc6e2 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sun, 1 Mar 2020 18:28:10 +0100 Subject: utils/lxc.env: separate environment that is used in containers Signed-off-by: Markus Heiser --- utils/searx.sh | 1 + 1 file changed, 1 insertion(+) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index c435b5c00..1089f30d7 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -6,6 +6,7 @@ # shellcheck source=utils/lib.sh source "$(dirname "${BASH_SOURCE[0]}")/lib.sh" source_dot_config +source "${REPO_ROOT}/utils/lxc.env" # ---------------------------------------------------------------------------- # config -- cgit v1.2.3 From c3e4753ce951f759844db13d98f9ad5b226f84b6 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Mon, 2 Mar 2020 19:00:19 +0100 Subject: docs: generic documentation from the installation scripts Signed-off-by: Markus Heiser --- utils/searx.sh | 214 ++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 195 insertions(+), 19 deletions(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index 1089f30d7..de903bc09 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -36,25 +36,28 @@ SEARX_UWSGI_APP="searx.ini" # shellcheck disable=SC2034 SEARX_UWSGI_SOCKET="/run/uwsgi/app/searx/socket" +# apt packages +SEARX_PACKAGES_debian="\ +python3-dev python3-babel python3-venv +uwsgi uwsgi-plugin-python3 +git build-essential libxslt-dev zlib1g-dev libffi-dev libssl-dev" + +# pacman packages +SEARX_PACKAGES_arch="\ +python python-pip python-lxml python-babel +uwsgi uwsgi-plugin-python +git base-devel libxml2" + +# dnf packages +SEARX_PACKAGES_fedora="\ +python python-pip python-lxml python-babel +uwsgi uwsgi-plugin-python3 +git @development-tools libxml2" + case $DIST_ID in - ubuntu|debian) # apt packages - SEARX_PACKAGES="\ - python3-dev python3-babel python3-venv \ - uwsgi uwsgi-plugin-python3 \ - git build-essential libxslt-dev zlib1g-dev libffi-dev libssl-dev " - ;; - arch) # pacman packages - SEARX_PACKAGES="\ - python python-pip python-lxml python-babel \ - uwsgi uwsgi-plugin-python \ - git base-devel libxml2 " - ;; - fedora) # dnf packages - SEARX_PACKAGES="\ - python python-pip python-lxml python-babel \ - uwsgi uwsgi-plugin-python3 \ - git @development-tools libxml2 " - ;; + ubuntu|debian) SEARX_PACKAGES="${SEARX_PACKAGES_debian}" ;; + arch) SEARX_PACKAGES="${SEARX_PACKAGES_arch}" ;; + fedora) SEARX_PACKAGES="${SEARX_PACKAGES_fedora}" ;; esac # Apache Settings @@ -206,6 +209,7 @@ main() { remove) remove_apache_site ;; *) usage "$_usage"; exit 42;; esac ;; + doc) rst-doc;; *) usage "unknown or missing command $1"; exit 42;; esac @@ -443,7 +447,7 @@ test_local_searx() { tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" export SEARX_SETTINGS_PATH="${SEARX_SETTINGS_PATH}" cd ${SEARX_SRC} -timeout 10 python3 searx/webapp.py & +timeout 10 python searx/webapp.py & sleep 3 curl --location --verbose --head --insecure $SEARX_INTERNAL_URL EOF @@ -631,6 +635,178 @@ This removes apache site ${APACHE_SEARX_SITE}." apache_remove_site "${APACHE_SEARX_SITE}" } +rst-doc() { + local debian="${SEARX_PACKAGES_debian}" + local arch="${SEARX_PACKAGES_arch}" + local fedora="${SEARX_PACKAGES_fedora}" + debian="$(echo "${debian}" | sed 's/.*/ & \\/' | sed '$ s/.$//')" + arch="$(echo "${arch}" | sed 's/.*/ & \\/' | sed '$ s/.$//')" + fedora="$(echo "${fedora}" | sed 's/.*/ & \\/' | sed '$ s/.$//')" + + cat <> "$SERVICE_HOME/.profile" + +.. END create virtualenv + +.. START manage.sh update_packages + +.. tabs:: + + .. group-tab:: bash + + .. code-block:: sh + + $ sudo -H -u ${SERVICE_USER} -i + + (${SERVICE_USER})$ command -v python && python --version + $SEARX_PYENV/bin/python + Python 3.8.1 + + (${SERVICE_USER})$ cd "$SEARX_SRC" + (${SERVICE_USER})$ ./manage.sh update_packages + +.. END manage.sh update_packages + +.. START searx config + +.. tabs:: + + .. group-tab:: bash + + .. code-block:: sh + + $ sudo -H cp "$SEARX_SRC/searx/settings.yml" "${SEARX_SETTINGS_PATH}" + $ sudo -H sed -i -e "s/ultrasecretkey/\$(openssl rand -hex 16)/g" "$SEARX_SETTINGS_PATH" + $ sudo -H sed -i -e "s/{instance_name}/searx@\$(uname -n)/g" "$SEARX_SETTINGS_PATH" + +.. END searx config + +.. START check searx installation + +.. tabs:: + + .. group-tab:: bash + + .. code-block:: sh + + # enable debug .. + $ sudo -H sed -i -e "s/debug : False/debug : True/g" "$SEARX_SETTINGS_PATH" + + # start webapp + $ sudo -H -u ${SERVICE_USER} -i + (${SERVICE_USER})$ cd ${SEARX_SRC} + (${SERVICE_USER})$ export SEARX_SETTINGS_PATH="${SEARX_SETTINGS_PATH}" + (${SERVICE_USER})$ python searx/webapp.py + + # disable debug + $ sudo -H sed -i -e "s/debug : True/debug : False/g" "$SEARX_SETTINGS_PATH" + +Open WEB browser and visit http://$SEARX_INTERNAL_URL . If you are inside a +container or in a script, test with curl: + +.. tabs:: + + .. group-tab:: WEB browser + + .. code-block:: sh + + $ xgd-open http://$SEARX_INTERNAL_URL + + .. group-tab:: curl + + .. code-block:: none + + $ curl --location --verbose --head --insecure $SEARX_INTERNAL_URL + + * Trying 127.0.0.1:8888... + * TCP_NODELAY set + * Connected to 127.0.0.1 (127.0.0.1) port 8888 (#0) + > HEAD / HTTP/1.1 + > Host: 127.0.0.1:8888 + > User-Agent: curl/7.68.0 + > Accept: */* + > + * Mark bundle as not supporting multiuse + * HTTP 1.0, assume close after body + < HTTP/1.0 200 OK + HTTP/1.0 200 OK + ... + +.. END check searx installation + +EOF + +} + + # ---------------------------------------------------------------------------- main "$@" # ---------------------------------------------------------------------------- -- cgit v1.2.3 From f25da6070e398f17c24b194c8688595050dc473c Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Tue, 3 Mar 2020 16:26:02 +0100 Subject: docs: generic documentation get templating Signed-off-by: Markus Heiser --- utils/searx.sh | 162 +-------------------------------------------------------- 1 file changed, 1 insertion(+), 161 deletions(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index de903bc09..38ccfdcab 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -643,170 +643,10 @@ rst-doc() { arch="$(echo "${arch}" | sed 's/.*/ & \\/' | sed '$ s/.$//')" fedora="$(echo "${fedora}" | sed 's/.*/ & \\/' | sed '$ s/.$//')" - cat <> "$SERVICE_HOME/.profile" - -.. END create virtualenv - -.. START manage.sh update_packages - -.. tabs:: - - .. group-tab:: bash - - .. code-block:: sh - - $ sudo -H -u ${SERVICE_USER} -i - - (${SERVICE_USER})$ command -v python && python --version - $SEARX_PYENV/bin/python - Python 3.8.1 - - (${SERVICE_USER})$ cd "$SEARX_SRC" - (${SERVICE_USER})$ ./manage.sh update_packages - -.. END manage.sh update_packages - -.. START searx config - -.. tabs:: - - .. group-tab:: bash - - .. code-block:: sh - - $ sudo -H cp "$SEARX_SRC/searx/settings.yml" "${SEARX_SETTINGS_PATH}" - $ sudo -H sed -i -e "s/ultrasecretkey/\$(openssl rand -hex 16)/g" "$SEARX_SETTINGS_PATH" - $ sudo -H sed -i -e "s/{instance_name}/searx@\$(uname -n)/g" "$SEARX_SETTINGS_PATH" - -.. END searx config - -.. START check searx installation - -.. tabs:: - - .. group-tab:: bash - - .. code-block:: sh - - # enable debug .. - $ sudo -H sed -i -e "s/debug : False/debug : True/g" "$SEARX_SETTINGS_PATH" - - # start webapp - $ sudo -H -u ${SERVICE_USER} -i - (${SERVICE_USER})$ cd ${SEARX_SRC} - (${SERVICE_USER})$ export SEARX_SETTINGS_PATH="${SEARX_SETTINGS_PATH}" - (${SERVICE_USER})$ python searx/webapp.py - - # disable debug - $ sudo -H sed -i -e "s/debug : True/debug : False/g" "$SEARX_SETTINGS_PATH" - -Open WEB browser and visit http://$SEARX_INTERNAL_URL . If you are inside a -container or in a script, test with curl: - -.. tabs:: - - .. group-tab:: WEB browser - - .. code-block:: sh - - $ xgd-open http://$SEARX_INTERNAL_URL - - .. group-tab:: curl - - .. code-block:: none - - $ curl --location --verbose --head --insecure $SEARX_INTERNAL_URL - - * Trying 127.0.0.1:8888... - * TCP_NODELAY set - * Connected to 127.0.0.1 (127.0.0.1) port 8888 (#0) - > HEAD / HTTP/1.1 - > Host: 127.0.0.1:8888 - > User-Agent: curl/7.68.0 - > Accept: */* - > - * Mark bundle as not supporting multiuse - * HTTP 1.0, assume close after body - < HTTP/1.0 200 OK - HTTP/1.0 200 OK - ... - -.. END check searx installation - -EOF + eval "echo \"$(< ${REPO_ROOT}/docs/build-templates/searx.rst)\"" } - # ---------------------------------------------------------------------------- main "$@" # ---------------------------------------------------------------------------- -- cgit v1.2.3 From 3cb7daedb7c5c93a98dfefa191c161f31a1347c6 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Tue, 3 Mar 2020 19:57:15 +0100 Subject: docs: generic doocumentation for searx-uwsgi Signed-off-by: Markus Heiser --- utils/searx.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index 38ccfdcab..447e9911e 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -645,8 +645,38 @@ rst-doc() { eval "echo \"$(< ${REPO_ROOT}/docs/build-templates/searx.rst)\"" + # I use ubuntu-20.04 here to demonstrate that versions are also suported, + # normaly debian-* and ubuntu-* are most the same. + + for DIST_NAME in ubuntu-20.04 arch fedora; do + ( + DIST_ID=${DIST_NAME%-*} + DIST_VERS=${DIST_NAME#*-} + [[ $DIST_VERS =~ $DIST_ID ]] && DIST_VERS= + uWSGI_distro_setup + + echo -e "\n.. START searx uwsgi-description $DIST_NAME" + echo "location: ${uWSGI_APPS_ENABLED}/${SEARX_UWSGI_APP}" + case $DIST_ID-$DIST_VERS in + ubuntu-*|debian-*) + echo "restart: sudo -H service uwsgi restart ${SEARX_UWSGI_APP%.*}" ;; + arch-*) + echo "restart: sudo -H systemctl restart uwsgi@${SEARX_UWSGI_APP%.*}" ;; + fedora-*) + echo "restart: sudo -H touch ${uWSGI_APPS_ENABLED}/${SEARX_UWSGI_APP}";; + esac + echo -e ".. END searx uwsgi-description $DIST_NAME" + + echo -e "\n.. START searx uwsgi-appini $DIST_NAME" + eval "echo \"$(< ${TEMPLATES}/${uWSGI_APPS_AVAILABLE}/${SEARX_UWSGI_APP})\"" + echo -e "\n.. END searx uwsgi-appini $DIST_NAME" + + ) + done + } # ---------------------------------------------------------------------------- main "$@" # ---------------------------------------------------------------------------- + -- cgit v1.2.3 From 3aff2c19d16619d949dc52216b29ef637d1a44a1 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Wed, 4 Mar 2020 12:22:20 +0100 Subject: docs: complement uwsgi documentation for all distros Signed-off-by: Markus Heiser --- utils/searx.sh | 49 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 9 deletions(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index 447e9911e..03911dff6 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -643,7 +643,7 @@ rst-doc() { arch="$(echo "${arch}" | sed 's/.*/ & \\/' | sed '$ s/.$//')" fedora="$(echo "${fedora}" | sed 's/.*/ & \\/' | sed '$ s/.$//')" - eval "echo \"$(< ${REPO_ROOT}/docs/build-templates/searx.rst)\"" + eval "echo \"$(< "${REPO_ROOT}/docs/build-templates/searx.rst")\"" # I use ubuntu-20.04 here to demonstrate that versions are also suported, # normaly debian-* and ubuntu-* are most the same. @@ -656,19 +656,50 @@ rst-doc() { uWSGI_distro_setup echo -e "\n.. START searx uwsgi-description $DIST_NAME" - echo "location: ${uWSGI_APPS_ENABLED}/${SEARX_UWSGI_APP}" + case $DIST_ID-$DIST_VERS in - ubuntu-*|debian-*) - echo "restart: sudo -H service uwsgi restart ${SEARX_UWSGI_APP%.*}" ;; - arch-*) - echo "restart: sudo -H systemctl restart uwsgi@${SEARX_UWSGI_APP%.*}" ;; - fedora-*) - echo "restart: sudo -H touch ${uWSGI_APPS_ENABLED}/${SEARX_UWSGI_APP}";; + ubuntu-*|debian-*) cat < /usr/share/doc/uwsgi/README.Debian.gz +# For uWSGI debian uses the LSB init process, this might be changed +# one day, see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=833067 + +create ${uWSGI_APPS_AVAILABLE}/${SEARX_UWSGI_APP} +enable: sudo -H ln -s ${uWSGI_APPS_AVAILABLE}/${SEARX_UWSGI_APP} ${uWSGI_APPS_ENABLED}/ +start: sudo -H service uwsgi start ${SEARX_UWSGI_APP%.*} +restart: sudo -H service uwsgi restart ${SEARX_UWSGI_APP%.*} +stop: sudo -H service uwsgi stop ${SEARX_UWSGI_APP%.*} +disable: sudo -H rm ${uWSGI_APPS_ENABLED}/${CONF} +EOF + ;; + arch-*) cat < /usr/lib/systemd/system/uwsgi@.service +# For uWSGI archlinux uses systemd template units, see +# - http://0pointer.de/blog/projects/instances.html +# - https://uwsgi-docs.readthedocs.io/en/latest/Systemd.html#one-service-per-app-in-systemd + +create: ${uWSGI_APPS_ENABLED}/${SEARX_UWSGI_APP} +enable: sudo -H systemctl enable uwsgi@${SEARX_UWSGI_APP%.*} +start: sudo -H systemctl start uwsgi@${SEARX_UWSGI_APP%.*} +restart: sudo -H systemctl restart uwsgi@${SEARX_UWSGI_APP%.*} +stop: sudo -H systemctl stop uwsgi@${SEARX_UWSGI_APP%.*} +disable: sudo -H systemctl disable uwsgi@${SEARX_UWSGI_APP%.*} +EOF + ;; + fedora-*) cat < /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 + +create: ${uWSGI_APPS_ENABLED}/${SEARX_UWSGI_APP} +restart: sudo -H touch ${uWSGI_APPS_ENABLED}/${SEARX_UWSGI_APP} +disable: sudo -H rm ${uWSGI_APPS_ENABLED}/${SEARX_UWSGI_APP} +EOF + ;; esac echo -e ".. END searx uwsgi-description $DIST_NAME" echo -e "\n.. START searx uwsgi-appini $DIST_NAME" - eval "echo \"$(< ${TEMPLATES}/${uWSGI_APPS_AVAILABLE}/${SEARX_UWSGI_APP})\"" + eval "echo \"$(< "${TEMPLATES}/${uWSGI_APPS_AVAILABLE}/${SEARX_UWSGI_APP}")\"" echo -e "\n.. END searx uwsgi-appini $DIST_NAME" ) -- cgit v1.2.3 From cbc08fdc26e96bf2cb02b76a30be095f5f60df9f Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Wed, 4 Mar 2020 19:56:40 +0100 Subject: docs: describe uwsgi setup of all suported distributions Signed-off-by: Markus Heiser --- utils/searx.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index 03911dff6..a93e36c95 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -668,7 +668,7 @@ enable: sudo -H ln -s ${uWSGI_APPS_AVAILABLE}/${SEARX_UWSGI_APP} ${uWSGI_APPS start: sudo -H service uwsgi start ${SEARX_UWSGI_APP%.*} restart: sudo -H service uwsgi restart ${SEARX_UWSGI_APP%.*} stop: sudo -H service uwsgi stop ${SEARX_UWSGI_APP%.*} -disable: sudo -H rm ${uWSGI_APPS_ENABLED}/${CONF} +disable: sudo -H rm ${uWSGI_APPS_ENABLED}/${SEARX_UWSGI_APP} EOF ;; arch-*) cat < Date: Fri, 6 Mar 2020 14:47:00 +0100 Subject: docs: improve description of uwsgi & ngingx setup Signed-off-by: Markus Heiser --- utils/searx.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index a93e36c95..9d73f46e2 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -88,7 +88,7 @@ usage() { usage:: $(basename "$0") shell - $(basename "$0") install [all|user|searx-src|pyenv|apache] + $(basename "$0") install [all|user|searx-src|pyenv|uwsgi|apache] $(basename "$0") update [searx] $(basename "$0") remove [all|user|pyenv|searx-src] $(basename "$0") activate [service] @@ -104,6 +104,7 @@ install / remove :user: add/remove service user '$SERVICE_USER' ($SERVICE_HOME) :searx-src: clone $SEARX_GIT_URL :pyenv: create/remove virtualenv (python) in $SEARX_PYENV + :uwsgi: install searx uWSGI application :settings: reinstall settings from ${REPO_ROOT}/searx/settings.yml update searx Update searx installation ($SERVICE_HOME) @@ -165,6 +166,7 @@ main() { pyenv) create_pyenv ;; searx-src) clone_searx ;; settings) install_settings ;; + uwsgi) install_searx_uwsgi;; *) usage "$_usage"; exit 42;; esac ;; update) -- cgit v1.2.3 From b1e90cff23eae2181d2b430e77471f488947d1a9 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sat, 7 Mar 2020 20:24:08 +0100 Subject: LXC: separate lxc-suite from lxc & improved command line. Signed-off-by: Markus Heiser --- utils/searx.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index 9d73f46e2..205c7068d 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -6,7 +6,7 @@ # shellcheck source=utils/lib.sh source "$(dirname "${BASH_SOURCE[0]}")/lib.sh" source_dot_config -source "${REPO_ROOT}/utils/lxc.env" +source "${REPO_ROOT}/utils/lxc-searx.env" # ---------------------------------------------------------------------------- # config @@ -544,13 +544,13 @@ EOF uWSGI_app_available "$SEARX_UWSGI_APP" \ || err_msg "uWSGI app $SEARX_UWSGI_APP not available!" - if is_container; then + if in_container; then warn_msg "runnning inside container ..." - for ip in $(hostname -I); do + for ip in $(global_IPs); do if [[ $ip =~ .*:.* ]]; then - info_msg " public HTTP service (IPv6) --> http://[$ip]" + info_msg " public HTTP service (IPv6) --> http://${ip#*|}" else - info_msg " public HTTP service (IPv4) --> http://$ip" + info_msg " public HTTP service (IPv4) --> http://${ip#*|}" fi done warn_msg "SEARX_INTERNAL_URL not available from outside" @@ -564,7 +564,7 @@ EOF if ! service_is_available "${PUBLIC_URL}"; then warn_msg "Public service at ${PUBLIC_URL} is not available!" - if is_container; then + if in_container; then warn_msg "Check if public name is correct and routed or use the public IP from above." fi fi -- cgit v1.2.3 From e7f69b63f1169a60f6f15b827dfe4f5748a41d2c Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sun, 8 Mar 2020 02:41:45 +0100 Subject: LXC: from searx.sh, morty.sh and filtron.sh tests Signed-off-by: Markus Heiser --- utils/searx.sh | 51 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 19 deletions(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index 205c7068d..14af32d0f 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -7,6 +7,7 @@ source "$(dirname "${BASH_SOURCE[0]}")/lib.sh" source_dot_config source "${REPO_ROOT}/utils/lxc-searx.env" +in_container && lxc_set_suite_env # ---------------------------------------------------------------------------- # config @@ -223,6 +224,11 @@ install_all() { rst_title "Install $SEARX_INSTANCE_NAME (service)" pkg_install "$SEARX_PACKAGES" wait_key + case $DIST_ID-$DIST_VERS in + fedora-*) + systemctl enable uwsgi + ;; + esac assert_user wait_key clone_searx @@ -545,26 +551,21 @@ EOF || err_msg "uWSGI app $SEARX_UWSGI_APP not available!" if in_container; then - warn_msg "runnning inside container ..." - for ip in $(global_IPs); do - if [[ $ip =~ .*:.* ]]; then - info_msg " public HTTP service (IPv6) --> http://${ip#*|}" - else - info_msg " public HTTP service (IPv4) --> http://${ip#*|}" - fi - done - warn_msg "SEARX_INTERNAL_URL not available from outside" + lxc_suite_info + else + info_msg "public URL --> ${PUBLIC_URL}" + info_msg "internal URL --> http://${SEARX_INTERNAL_URL}" fi if ! service_is_available "http://${SEARX_INTERNAL_URL}"; then err_msg "uWSGI app (service) at http://${SEARX_INTERNAL_URL} is not available!" - echo -e "${_Green}stop with [${_BCyan}CTRL-C${_Green}] or .." - wait_key + MSG="${_Green}[${_BCyan}CTRL-C${_Green}] to stop or [${_BCyan}KEY${_Green}] to continue"\ + wait_key fi if ! service_is_available "${PUBLIC_URL}"; then warn_msg "Public service at ${PUBLIC_URL} is not available!" - if in_container; then + if ! in_container; then warn_msg "Check if public name is correct and routed or use the public IP from above." fi fi @@ -575,19 +576,31 @@ EOF _debug_on=1 fi echo - systemctl --no-pager -l status "${SERVICE_NAME}" - echo - info_msg "public URL --> ${PUBLIC_URL}" - info_msg "internal URL --> http://${SEARX_INTERNAL_URL}" + case $DIST_ID-$DIST_VERS in + ubuntu-*|debian-*) + systemctl --no-pager -l status "${SERVICE_NAME}" + ;; + arch-*) + systemctl --no-pager -l status "uwsgi@${SERVICE_NAME%.*}" + ;; + fedora-*) + systemctl --no-pager -l status uwsgi + ;; + esac + # shellcheck disable=SC2059 printf "// use ${_BCyan}CTRL-C${_creset} to stop monitoring the log" - read -r -s -n1 -t 2 + read -r -s -n1 -t 5 echo + while true; do trap break 2 - #journalctl -f -u "${SERVICE_NAME}" - tail -f /var/log/uwsgi/app/searx.log + case $DIST_ID-$DIST_VERS in + ubuntu-*|debian-*) tail -f /var/log/uwsgi/app/searx.log ;; + arch-*) journalctl -f -u "uwsgi@${SERVICE_NAME%.*}" ;; + fedora-*) journalctl -f -u uwsgi ;; + esac done if [[ $_debug_on == 1 ]]; then -- cgit v1.2.3 From 938bb0255045eb0f5e21027805fa018cd53d6cad Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sun, 8 Mar 2020 18:32:30 +0100 Subject: searx.sh: add commandline 'install packages' Signed-off-by: Markus Heiser --- utils/searx.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index 14af32d0f..9d33dc31a 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -41,19 +41,22 @@ SEARX_UWSGI_SOCKET="/run/uwsgi/app/searx/socket" SEARX_PACKAGES_debian="\ python3-dev python3-babel python3-venv uwsgi uwsgi-plugin-python3 -git build-essential libxslt-dev zlib1g-dev libffi-dev libssl-dev" +git build-essential libxslt-dev zlib1g-dev libffi-dev libssl-dev +shellcheck" # pacman packages SEARX_PACKAGES_arch="\ python python-pip python-lxml python-babel uwsgi uwsgi-plugin-python -git base-devel libxml2" +git base-devel libxml2 +shellcheck" # dnf packages SEARX_PACKAGES_fedora="\ python python-pip python-lxml python-babel uwsgi uwsgi-plugin-python3 -git @development-tools libxml2" +git @development-tools libxml2 +ShellCheck" case $DIST_ID in ubuntu|debian) SEARX_PACKAGES="${SEARX_PACKAGES_debian}" ;; @@ -89,7 +92,7 @@ usage() { usage:: $(basename "$0") shell - $(basename "$0") install [all|user|searx-src|pyenv|uwsgi|apache] + $(basename "$0") install [all|user|searx-src|pyenv|uwsgi|apache|packages] $(basename "$0") update [searx] $(basename "$0") remove [all|user|pyenv|searx-src] $(basename "$0") activate [service] @@ -107,6 +110,7 @@ install / remove :pyenv: create/remove virtualenv (python) in $SEARX_PYENV :uwsgi: install searx uWSGI application :settings: reinstall settings from ${REPO_ROOT}/searx/settings.yml + :packages: install needed packages from OS package manager update searx Update searx installation ($SERVICE_HOME) activate service @@ -168,6 +172,7 @@ main() { searx-src) clone_searx ;; settings) install_settings ;; uwsgi) install_searx_uwsgi;; + packages) pkg_install "$SEARX_PACKAGES" ;; *) usage "$_usage"; exit 42;; esac ;; update) -- cgit v1.2.3 From 80f7b658047a3541697ef5ae1aae897817b3f43c Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Mon, 9 Mar 2020 01:37:26 +0100 Subject: searx.sh: add buildhost cmd, installs OS packages for builds Signed-off-by: Markus Heiser --- utils/searx.sh | 48 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 11 deletions(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index 9d33dc31a..19cb41986 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -41,27 +41,47 @@ SEARX_UWSGI_SOCKET="/run/uwsgi/app/searx/socket" SEARX_PACKAGES_debian="\ python3-dev python3-babel python3-venv uwsgi uwsgi-plugin-python3 -git build-essential libxslt-dev zlib1g-dev libffi-dev libssl-dev -shellcheck" +git build-essential libxslt-dev zlib1g-dev libffi-dev libssl-dev" + +BUILD_PACKAGES_debian="\ +shellcheck graphviz imagemagick texlive-xetex librsvg2-bin +texlive-latex-recommended texlive-extra-utils ttf-dejavu" # pacman packages SEARX_PACKAGES_arch="\ python python-pip python-lxml python-babel uwsgi uwsgi-plugin-python -git base-devel libxml2 -shellcheck" +git base-devel libxml2" + +BUILD_PACKAGES_arch="\ +shellcheck graphviz imagemagick texlive-bin extra/librsvg +texlive-core texlive-latexextra ttf-dejavu" # dnf packages SEARX_PACKAGES_fedora="\ python python-pip python-lxml python-babel uwsgi uwsgi-plugin-python3 -git @development-tools libxml2 -ShellCheck" +git @development-tools libxml2" + +BUILD_PACKAGES_fedora="\ +ShellCheck graphviz graphviz-gd ImageMagick librsvg2-tools +texlive-xetex-bin texlive-collection-fontsrecommended +texlive-collection-latex dejavu-sans-fonts dejavu-serif-fonts +dejavu-sans-mono-fonts" case $DIST_ID in - ubuntu|debian) SEARX_PACKAGES="${SEARX_PACKAGES_debian}" ;; - arch) SEARX_PACKAGES="${SEARX_PACKAGES_arch}" ;; - fedora) SEARX_PACKAGES="${SEARX_PACKAGES_fedora}" ;; + ubuntu|debian) + SEARX_PACKAGES="${SEARX_PACKAGES_debian}" + BUILD_PACKAGES="${BUILD_PACKAGES_debian}" + ;; + arch) + SEARX_PACKAGES="${SEARX_PACKAGES_arch}" + BUILD_PACKAGES="${BUILD_PACKAGES_arch}" + ;; + fedora) + SEARX_PACKAGES="${SEARX_PACKAGES_fedora}" + BUILD_PACKAGES="${BUILD_PACKAGES_fedora}" + ;; esac # Apache Settings @@ -111,6 +131,7 @@ install / remove :uwsgi: install searx uWSGI application :settings: reinstall settings from ${REPO_ROOT}/searx/settings.yml :packages: install needed packages from OS package manager + :buildhost: install packages from OS package manager needed by buildhost update searx Update searx installation ($SERVICE_HOME) activate service @@ -172,7 +193,13 @@ main() { searx-src) clone_searx ;; settings) install_settings ;; uwsgi) install_searx_uwsgi;; - packages) pkg_install "$SEARX_PACKAGES" ;; + packages) + pkg_install "$SEARX_PACKAGES" + ;; + buildhost) + pkg_install "$SEARX_PACKAGES" + pkg_install "$BUILD_PACKAGES" + ;; *) usage "$_usage"; exit 42;; esac ;; update) @@ -730,4 +757,3 @@ EOF # ---------------------------------------------------------------------------- main "$@" # ---------------------------------------------------------------------------- - -- cgit v1.2.3 From 7b4cf2eb489d8f6c95ccac5af180254b78e7c460 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sun, 29 Mar 2020 15:09:34 +0200 Subject: tooling box: simplify build enviroments - no more need for a .config.mk - docs: use searx.brands environment - searx.sh, filtron.sh & morty.sh are sourcing utils/brand.env Signed-off-by: Markus Heiser --- utils/searx.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index 19cb41986..a6f2d5ee6 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -5,6 +5,8 @@ # shellcheck source=utils/lib.sh source "$(dirname "${BASH_SOURCE[0]}")/lib.sh" +# shellcheck source=utils/brand.env +source "${REPO_ROOT}/utils/brand.env" source_dot_config source "${REPO_ROOT}/utils/lxc-searx.env" in_container && lxc_set_suite_env @@ -13,6 +15,8 @@ in_container && lxc_set_suite_env # config # ---------------------------------------------------------------------------- +PUBLIC_URL="${PUBLIC_URL:-http://$(uname -n)/searx}" + SEARX_INTERNAL_URL="${SEARX_INTERNAL_URL:-127.0.0.1:8888}" SEARX_URL_PATH="${SEARX_URL_PATH:-$(echo "${PUBLIC_URL}" \ @@ -28,8 +32,7 @@ SERVICE_HOME="${SERVICE_HOME_BASE}/${SERVICE_USER}" # shellcheck disable=SC2034 SERVICE_GROUP="${SERVICE_USER}" -SEARX_GIT_URL="${SEARX_GIT_URL:-https://github.com/asciimoo/searx.git}" -SEARX_GIT_BRANCH="${SEARX_GIT_BRANCH:-master}" +GIT_BRANCH="${GIT_BRANCH:-master}" SEARX_PYENV="${SERVICE_HOME}/searx-pyenv" SEARX_SRC="${SERVICE_HOME}/searx-src" SEARX_SETTINGS_PATH="/etc/searx/settings.yml" @@ -126,7 +129,7 @@ shell install / remove :all: complete (de-) installation of searx service :user: add/remove service user '$SERVICE_USER' ($SERVICE_HOME) - :searx-src: clone $SEARX_GIT_URL + :searx-src: clone $GIT_URL :pyenv: create/remove virtualenv (python) in $SEARX_PYENV :uwsgi: install searx uWSGI application :settings: reinstall settings from ${REPO_ROOT}/searx/settings.yml @@ -151,7 +154,6 @@ searx settings: ${SEARX_SETTINGS_PATH} If needed, set PUBLIC_URL of your WEB service in the '${DOT_CONFIG#"$REPO_ROOT/"}' file:: PUBLIC_URL : ${PUBLIC_URL} - PUBLIC_HOST : ${PUBLIC_HOST} SEARX_INSTANCE_NAME : ${SEARX_INSTANCE_NAME} SERVICE_USER : ${SERVICE_USER} @@ -286,7 +288,7 @@ update_searx() { echo tee_stderr 0.3 <&1 | prefix_stdout "$_service_prefix" cd ${SEARX_SRC} -git checkout -B "$SEARX_GIT_BRANCH" +git checkout -B "$GIT_BRANCH" git pull ${SEARX_SRC}/manage.sh update_packages EOF @@ -344,12 +346,12 @@ clone_searx() { fi export SERVICE_HOME git_clone "$REPO_ROOT" "$SEARX_SRC" \ - "$SEARX_GIT_BRANCH" "$SERVICE_USER" + "$GIT_BRANCH" "$SERVICE_USER" pushd "${SEARX_SRC}" > /dev/null tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" cd "${SEARX_SRC}" -git remote set-url origin ${SEARX_GIT_URL} +git remote set-url origin ${GIT_URL} git config user.email "$ADMIN_EMAIL" git config user.name "$ADMIN_NAME" git config --list @@ -546,7 +548,6 @@ inspect_service() { sourced ${DOT_CONFIG#"$REPO_ROOT/"} : PUBLIC_URL : ${PUBLIC_URL} - PUBLIC_HOST : ${PUBLIC_HOST} SEARX_URL_PATH : ${SEARX_URL_PATH} SEARX_INSTANCE_NAME : ${SEARX_INSTANCE_NAME} SEARX_INTERNAL_URL : ${SEARX_INTERNAL_URL} -- cgit v1.2.3 From dd53c45a2cb46f882a856869de26215942749cba Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Mon, 30 Mar 2020 18:47:01 +0200 Subject: docs: add utils/lxc.sh docs, normalize filtron, morty & searx docs Signed-off-by: Markus Heiser --- utils/searx.sh | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index a6f2d5ee6..71ab978a1 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -44,30 +44,33 @@ SEARX_UWSGI_SOCKET="/run/uwsgi/app/searx/socket" SEARX_PACKAGES_debian="\ python3-dev python3-babel python3-venv uwsgi uwsgi-plugin-python3 -git build-essential libxslt-dev zlib1g-dev libffi-dev libssl-dev" +git build-essential libxslt-dev zlib1g-dev libffi-dev libssl-dev +shellcheck" BUILD_PACKAGES_debian="\ -shellcheck graphviz imagemagick texlive-xetex librsvg2-bin +graphviz imagemagick texlive-xetex librsvg2-bin texlive-latex-recommended texlive-extra-utils ttf-dejavu" # pacman packages SEARX_PACKAGES_arch="\ python python-pip python-lxml python-babel uwsgi uwsgi-plugin-python -git base-devel libxml2" +git base-devel libxml2 +shellcheck" BUILD_PACKAGES_arch="\ -shellcheck graphviz imagemagick texlive-bin extra/librsvg +graphviz imagemagick texlive-bin extra/librsvg texlive-core texlive-latexextra ttf-dejavu" # dnf packages SEARX_PACKAGES_fedora="\ python python-pip python-lxml python-babel uwsgi uwsgi-plugin-python3 -git @development-tools libxml2" +git @development-tools libxml2 +ShellCheck" BUILD_PACKAGES_fedora="\ -ShellCheck graphviz graphviz-gd ImageMagick librsvg2-tools +graphviz graphviz-gd ImageMagick librsvg2-tools texlive-xetex-bin texlive-collection-fontsrecommended texlive-collection-latex dejavu-sans-fonts dejavu-serif-fonts dejavu-sans-mono-fonts" @@ -76,23 +79,21 @@ case $DIST_ID in ubuntu|debian) SEARX_PACKAGES="${SEARX_PACKAGES_debian}" BUILD_PACKAGES="${BUILD_PACKAGES_debian}" + APACHE_APT_PACKAGES="libapache2-mod-uwsgi" ;; arch) SEARX_PACKAGES="${SEARX_PACKAGES_arch}" BUILD_PACKAGES="${BUILD_PACKAGES_arch}" + APACHE_APT_PACKAGES="uwsgi" ;; fedora) SEARX_PACKAGES="${SEARX_PACKAGES_fedora}" BUILD_PACKAGES="${BUILD_PACKAGES_fedora}" + APACHE_APT_PACKAGES="uwsgi" ;; esac # Apache Settings - -APACHE_APT_PACKAGES="\ - libapache2-mod-uwsgi \ -" - APACHE_SEARX_SITE="searx.conf" # shellcheck disable=SC2034 -- cgit v1.2.3 From f27f6c6c5d372b257dfe671ec26eb73f6e12ed28 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Tue, 31 Mar 2020 18:25:40 +0200 Subject: docs: use make and uitls/searx.sh in containers Signed-off-by: Markus Heiser --- utils/searx.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index 71ab978a1..17e8db84e 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -48,7 +48,7 @@ git build-essential libxslt-dev zlib1g-dev libffi-dev libssl-dev shellcheck" BUILD_PACKAGES_debian="\ -graphviz imagemagick texlive-xetex librsvg2-bin +firefox graphviz imagemagick texlive-xetex librsvg2-bin texlive-latex-recommended texlive-extra-utils ttf-dejavu" # pacman packages @@ -59,7 +59,7 @@ git base-devel libxml2 shellcheck" BUILD_PACKAGES_arch="\ -graphviz imagemagick texlive-bin extra/librsvg +firefox graphviz imagemagick texlive-bin extra/librsvg texlive-core texlive-latexextra ttf-dejavu" # dnf packages @@ -70,7 +70,7 @@ git @development-tools libxml2 ShellCheck" BUILD_PACKAGES_fedora="\ -graphviz graphviz-gd ImageMagick librsvg2-tools +firefox graphviz graphviz-gd ImageMagick librsvg2-tools texlive-xetex-bin texlive-collection-fontsrecommended texlive-collection-latex dejavu-sans-fonts dejavu-serif-fonts dejavu-sans-mono-fonts" @@ -116,7 +116,7 @@ usage() { usage:: $(basename "$0") shell - $(basename "$0") install [all|user|searx-src|pyenv|uwsgi|apache|packages] + $(basename "$0") install [all|user|searx-src|pyenv|uwsgi|apache|packages|buildhost] $(basename "$0") update [searx] $(basename "$0") remove [all|user|pyenv|searx-src] $(basename "$0") activate [service] @@ -135,7 +135,7 @@ install / remove :uwsgi: install searx uWSGI application :settings: reinstall settings from ${REPO_ROOT}/searx/settings.yml :packages: install needed packages from OS package manager - :buildhost: install packages from OS package manager needed by buildhost + :buildhost: install packages from OS package manager needed by buildhosts update searx Update searx installation ($SERVICE_HOME) activate service @@ -688,9 +688,15 @@ rst-doc() { local debian="${SEARX_PACKAGES_debian}" local arch="${SEARX_PACKAGES_arch}" local fedora="${SEARX_PACKAGES_fedora}" + local debian_build="${BUILD_PACKAGES_debian}" + local arch_build="${BUILD_PACKAGES_arch}" + local fedora_build="${BUILD_PACKAGES_fedora}" debian="$(echo "${debian}" | sed 's/.*/ & \\/' | sed '$ s/.$//')" arch="$(echo "${arch}" | sed 's/.*/ & \\/' | sed '$ s/.$//')" fedora="$(echo "${fedora}" | sed 's/.*/ & \\/' | sed '$ s/.$//')" + debian_build="$(echo "${debian_build}" | sed 's/.*/ & \\/' | sed '$ s/.$//')" + arch_build="$(echo "${arch_build}" | sed 's/.*/ & \\/' | sed '$ s/.$//')" + fedora_build="$(echo "${fedora_build}" | sed 's/.*/ & \\/' | sed '$ s/.$//')" eval "echo \"$(< "${REPO_ROOT}/docs/build-templates/searx.rst")\"" -- cgit v1.2.3 From f32b4fceddf698f6a33c42a866ca21c6cc202841 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Thu, 2 Apr 2020 20:27:44 +0200 Subject: LXC: add virtualenv to LXC_BASE_PACKAGES Commit 09a40625 adds virtualenv dependency. BTW remove deprecated --no-site-packages. Not having access to global site-packages is now the default behavior. Signed-off-by: Markus Heiser --- utils/searx.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index 17e8db84e..981c498fc 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -42,7 +42,7 @@ SEARX_UWSGI_SOCKET="/run/uwsgi/app/searx/socket" # apt packages SEARX_PACKAGES_debian="\ -python3-dev python3-babel python3-venv +virtualenv python3-dev python3-babel python3-venv uwsgi uwsgi-plugin-python3 git build-essential libxslt-dev zlib1g-dev libffi-dev libssl-dev shellcheck" @@ -53,7 +53,7 @@ texlive-latex-recommended texlive-extra-utils ttf-dejavu" # pacman packages SEARX_PACKAGES_arch="\ -python python-pip python-lxml python-babel +python-virtualenv python python-pip python-lxml python-babel uwsgi uwsgi-plugin-python git base-devel libxml2 shellcheck" @@ -64,7 +64,7 @@ texlive-core texlive-latexextra ttf-dejavu" # dnf packages SEARX_PACKAGES_fedora="\ -python python-pip python-lxml python-babel +virtualenv python python-pip python-lxml python-babel uwsgi uwsgi-plugin-python3 git @development-tools libxml2 ShellCheck" -- cgit v1.2.3 From 853be4e11cd8a82b6b08f04db1717329907a5aaf Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Fri, 3 Apr 2020 20:24:40 +0200 Subject: utils/filtron.sh: add generic documentation Signed-off-by: Markus Heiser --- utils/searx.sh | 1 - 1 file changed, 1 deletion(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index 981c498fc..5b118478e 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -248,7 +248,6 @@ main() { *) usage "$_usage"; exit 42;; esac ;; doc) rst-doc;; - *) usage "unknown or missing command $1"; exit 42;; esac } -- cgit v1.2.3 From c748047e926ce6979ab07a8a3ed3d0cc96f534ba Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sat, 4 Apr 2020 17:54:20 +0200 Subject: utils/searx.sh: add cmd to (un)set option image_proxy and result_proxy Signed-off-by: Markus Heiser --- utils/searx.sh | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index 5b118478e..b607d86ca 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -238,6 +238,9 @@ main() { case $2 in debug-on) echo; enable_debug ;; debug-off) echo; disable_debug ;; + result-proxy) set_result_proxy "$3" "$4" ;; + image-proxy-on) enable_image_proxy ;; + image-proxy-off) disable_image_proxy ;; *) usage "$_usage"; exit 42;; esac ;; apache) @@ -522,6 +525,24 @@ deactivate_service() { uWSGI_restart "$SEARX_UWSGI_APP" } +enable_image_proxy() { + info_msg "try to enable image_proxy ..." + tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" +cd ${SEARX_SRC} +sed -i -e "s/image_proxy : False/image_proxy : True/g" "$SEARX_SETTINGS_PATH" +EOF + uWSGI_restart "$SEARX_UWSGI_APP" +} + +disable_image_proxy() { + info_msg "try to enable image_proxy ..." + tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" +cd ${SEARX_SRC} +sed -i -e "s/image_proxy : True/image_proxy : False/g" "$SEARX_SETTINGS_PATH" +EOF + uWSGI_restart "$SEARX_UWSGI_APP" +} + enable_debug() { warn_msg "Do not enable debug in production enviroments!!" info_msg "try to enable debug mode ..." @@ -541,6 +562,59 @@ EOF uWSGI_restart "$SEARX_UWSGI_APP" } +set_result_proxy() { + info_msg "try to set result proxy ..." + local line + local stage=0 + local url=" url: $1" + local key=" key: $2" + if [[ -z $2 ]]; then + key= + fi + cp "${SEARX_SETTINGS_PATH}" "${SEARX_SETTINGS_PATH}.bak" + _set_result_proxy "$1" "$2" > "${SEARX_SETTINGS_PATH}" +} + +_set_result_proxy() { + local line + local stage=0 + local url=" url: $1" + local key=" key: $2" + if [[ -z $2 ]]; then + key= + fi + + while IFS= read -r line + do + if [[ $stage = 0 ]] || [[ $stage = 2 ]] ; then + if [[ $line =~ ^[[:space:]]*#*[[:space:]]*result_proxy[[:space:]]*:[[:space:]]*$ ]]; then + if [[ $stage = 0 ]]; then + stage=1 + echo "result_proxy:" + continue + elif [[ $stage = 2 ]]; then + continue + fi + fi + fi + if [[ $stage = 1 ]] || [[ $stage = 2 ]] ; then + if [[ $line =~ ^[[:space:]]*#*[[:space:]]*url[[:space:]]*:[[:space:]] ]]; then + [[ $stage = 1 ]] && echo "$url" + continue + elif [[ $line =~ ^[[:space:]]*#*[[:space:]]*key[[:space:]]*:[[:space:]] ]]; then + [[ $stage = 1 ]] && [[ -n $key ]] && echo "$key" + continue + elif [[ $line =~ ^[[:space:]]*$ ]]; then + stage=2 + fi + fi + echo "$line" + done < "${SEARX_SETTINGS_PATH}.bak" +} + +function has_substring() { + [[ "$1" != "${2/$1/}" ]] +} inspect_service() { rst_title "service status & log" cat < Date: Sun, 5 Apr 2020 17:40:37 +0200 Subject: filtron.sh & morty.sh: improve usage message (if used in containers) BTW: normalize soma variable names Signed-off-by: Markus Heiser --- utils/searx.sh | 55 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 22 deletions(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index b607d86ca..a74aec393 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -17,7 +17,7 @@ in_container && lxc_set_suite_env PUBLIC_URL="${PUBLIC_URL:-http://$(uname -n)/searx}" -SEARX_INTERNAL_URL="${SEARX_INTERNAL_URL:-127.0.0.1:8888}" +SEARX_INTERNAL_HTTP="${SEARX_INTERNAL_HTTP:-127.0.0.1:8888}" SEARX_URL_PATH="${SEARX_URL_PATH:-$(echo "${PUBLIC_URL}" \ | sed -e 's,^.*://[^/]*\(/.*\),\1,g')}" @@ -79,17 +79,17 @@ case $DIST_ID in ubuntu|debian) SEARX_PACKAGES="${SEARX_PACKAGES_debian}" BUILD_PACKAGES="${BUILD_PACKAGES_debian}" - APACHE_APT_PACKAGES="libapache2-mod-uwsgi" + APACHE_PACKAGES="libapache2-mod-uwsgi" ;; arch) SEARX_PACKAGES="${SEARX_PACKAGES_arch}" BUILD_PACKAGES="${BUILD_PACKAGES_arch}" - APACHE_APT_PACKAGES="uwsgi" + APACHE_PACKAGES="uwsgi" ;; fedora) SEARX_PACKAGES="${SEARX_PACKAGES_fedora}" BUILD_PACKAGES="${BUILD_PACKAGES_fedora}" - APACHE_APT_PACKAGES="uwsgi" + APACHE_PACKAGES="uwsgi" ;; esac @@ -116,13 +116,13 @@ usage() { usage:: $(basename "$0") shell - $(basename "$0") install [all|user|searx-src|pyenv|uwsgi|apache|packages|buildhost] + $(basename "$0") install [all|user|searx-src|pyenv|uwsgi|packages|buildhost] $(basename "$0") update [searx] $(basename "$0") remove [all|user|pyenv|searx-src] $(basename "$0") activate [service] $(basename "$0") deactivate [service] $(basename "$0") inspect [service] - $(basename "$0") option [debug-on|debug-off] + $(basename "$0") option [debug-[on|off]|image-proxy-[on|off]|result-proxy ] $(basename "$0") apache [install|remove] shell @@ -153,12 +153,25 @@ apache searx settings: ${SEARX_SETTINGS_PATH} If needed, set PUBLIC_URL of your WEB service in the '${DOT_CONFIG#"$REPO_ROOT/"}' file:: - PUBLIC_URL : ${PUBLIC_URL} SEARX_INSTANCE_NAME : ${SEARX_INSTANCE_NAME} SERVICE_USER : ${SERVICE_USER} - + SEARX_INTERNAL_HTTP : http://${SEARX_INTERNAL_HTTP} EOF + if in_container; then + # searx is listening on 127.0.0.1 and not available from outside container + # in containers the service is listening on 0.0.0.0 (see lxc-searx.env) + echo -e "${_BBlack}HINT:${_creset} searx only listen on loopback device" \ + "${_BBlack}inside${_creset} the container." + for ip in $(global_IPs) ; do + if [[ $ip =~ .*:.* ]]; then + echo " container (IPv6): [${ip#*|}]" + else + # IPv4: + echo " container (IPv4): ${ip#*|}" + fi + done + fi [[ -n ${1} ]] && err_msg "$1" } @@ -277,8 +290,8 @@ install_all() { test_local_searx wait_key install_searx_uwsgi - if ! service_is_available "http://$SEARX_INTERNAL_URL"; then - err_msg "URL http://$SEARX_INTERNAL_URL not available, check searx & uwsgi setup!" + if ! service_is_available "http://${SEARX_INTERNAL_HTTP}"; then + err_msg "URL http://${SEARX_INTERNAL_HTTP} not available, check searx & uwsgi setup!" fi if ask_yn "Do you want to inspect the installation?" Ny; then inspect_service @@ -481,8 +494,8 @@ test_local_searx() { rst_title "Testing searx instance localy" section echo - if service_is_available "http://$SEARX_INTERNAL_URL" &>/dev/null; then - err_msg "URL/port http://$SEARX_INTERNAL_URL is already in use, you" + if service_is_available "http://${SEARX_INTERNAL_HTTP}" &>/dev/null; then + err_msg "URL/port http://${SEARX_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 @@ -494,7 +507,7 @@ export SEARX_SETTINGS_PATH="${SEARX_SETTINGS_PATH}" cd ${SEARX_SRC} timeout 10 python searx/webapp.py & sleep 3 -curl --location --verbose --head --insecure $SEARX_INTERNAL_URL +curl --location --verbose --head --insecure $SEARX_INTERNAL_HTTP EOF sed -i -e "s/debug : True/debug : False/g" "$SEARX_SETTINGS_PATH" } @@ -624,12 +637,10 @@ sourced ${DOT_CONFIG#"$REPO_ROOT/"} : PUBLIC_URL : ${PUBLIC_URL} SEARX_URL_PATH : ${SEARX_URL_PATH} SEARX_INSTANCE_NAME : ${SEARX_INSTANCE_NAME} - SEARX_INTERNAL_URL : ${SEARX_INTERNAL_URL} + SEARX_INTERNAL_HTTP : ${SEARX_INTERNAL_HTTP} EOF - apache_is_installed && info_msg "Apache is installed." - if service_account_is_available "$SERVICE_USER"; then info_msg "Service account $SERVICE_USER exists." else @@ -661,11 +672,11 @@ EOF lxc_suite_info else info_msg "public URL --> ${PUBLIC_URL}" - info_msg "internal URL --> http://${SEARX_INTERNAL_URL}" + info_msg "internal URL --> http://${SEARX_INTERNAL_HTTP}" fi - if ! service_is_available "http://${SEARX_INTERNAL_URL}"; then - err_msg "uWSGI app (service) at http://${SEARX_INTERNAL_URL} is not available!" + if ! service_is_available "http://${SEARX_INTERNAL_HTTP}"; then + err_msg "uWSGI app (service) at http://${SEARX_INTERNAL_HTTP} is not available!" MSG="${_Green}[${_BCyan}CTRL-C${_Green}] to stop or [${_BCyan}KEY${_Green}] to continue"\ wait_key fi @@ -720,8 +731,8 @@ install_apache_site() { rst_title "Install Apache site $APACHE_SEARX_SITE" rst_para "\ -This installs the searx uwsgi app as apache site. If your server ist public to -the internet you should instead use a reverse proxy (filtron) to block +This installs the searx uwsgi app as apache site. If your server is public to +the internet, you should instead use a reverse proxy (filtron) to block excessively bot queries." ! apache_is_installed && err_msg "Apache is not installed." @@ -730,7 +741,7 @@ excessively bot queries." return fi - pkg_install "$APACHE_APT_PACKAGES" + pkg_install "$APACHE_PACKAGES" a2enmod uwsgi echo -- cgit v1.2.3 From eb0d4646d818fe12032379aae2fcd8b5bdb6467e Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Mon, 6 Apr 2020 17:59:06 +0200 Subject: docs: rework of chapter "Install with apache" BTW: normalize installation-nginx.rst --- utils/searx.sh | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index a74aec393..86b651696 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -735,6 +735,11 @@ This installs the searx uwsgi app as apache site. If your server is public to the internet, you should instead use a reverse proxy (filtron) to block excessively bot queries." + case $DIST_ID-$DIST_VERS in + ubuntu-*|debian-*) : ;; + *) err_msg "sorry distro $DIST_ID $DIST_VERS not yet supported"; exit 42 ;; + esac + ! apache_is_installed && err_msg "Apache is not installed." if ! ask_yn "Do you really want to install apache site for searx-uwsgi?"; then -- cgit v1.2.3 From ee39a098acb2386abd5382de5c9476cc4ffe2e03 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Tue, 7 Apr 2020 18:31:51 +0200 Subject: apache: normalize installation (docs and script)s over all distros Signed-off-by: Markus Heiser --- utils/searx.sh | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index 86b651696..6a8588c23 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -75,21 +75,23 @@ texlive-xetex-bin texlive-collection-fontsrecommended texlive-collection-latex dejavu-sans-fonts dejavu-serif-fonts dejavu-sans-mono-fonts" -case $DIST_ID in - ubuntu|debian) +case $DIST_ID-$DIST_VERS in + ubuntu-16.04|ubuntu-18.04) SEARX_PACKAGES="${SEARX_PACKAGES_debian}" BUILD_PACKAGES="${BUILD_PACKAGES_debian}" - APACHE_PACKAGES="libapache2-mod-uwsgi" + APACHE_PACKAGES="$APACHE_PACKAGES libapache2-mod-proxy-uwsgi" ;; - arch) + ubuntu-*|debian-*) + SEARX_PACKAGES="${SEARX_PACKAGES_debian}" + BUILD_PACKAGES="${BUILD_PACKAGES_debian}" + ;; + arch-*) SEARX_PACKAGES="${SEARX_PACKAGES_arch}" BUILD_PACKAGES="${BUILD_PACKAGES_arch}" - APACHE_PACKAGES="uwsgi" ;; - fedora) + fedora-*) SEARX_PACKAGES="${SEARX_PACKAGES_fedora}" BUILD_PACKAGES="${BUILD_PACKAGES_fedora}" - APACHE_PACKAGES="uwsgi" ;; esac @@ -462,6 +464,7 @@ EOF wait_key info_msg "install needed python packages" tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" +pip install wheel ${SEARX_SRC}/manage.sh update_packages EOF } @@ -735,21 +738,14 @@ This installs the searx uwsgi app as apache site. If your server is public to the internet, you should instead use a reverse proxy (filtron) to block excessively bot queries." - case $DIST_ID-$DIST_VERS in - ubuntu-*|debian-*) : ;; - *) err_msg "sorry distro $DIST_ID $DIST_VERS not yet supported"; exit 42 ;; - esac - ! apache_is_installed && err_msg "Apache is not installed." - if ! ask_yn "Do you really want to install apache site for searx-uwsgi?"; then + if ! ask_yn "Do you really want to continue?" Yn; then return + else + install_apache fi - pkg_install "$APACHE_PACKAGES" - a2enmod uwsgi - - echo apache_install_site --variant=uwsgi "${APACHE_SEARX_SITE}" if ! service_is_available "${PUBLIC_URL}"; then -- cgit v1.2.3 From f693149cded4f783380f8f02154bd9288b72cdd5 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Wed, 8 Apr 2020 18:38:36 +0200 Subject: Changes from the installation tests on (all) LXC containers. Tested and fixed HTTP & uWSGI installation on: ubu1604 ubu1804 ubu1910 ubu2004 fedora31 archlinux Signed-off-by: Markus Heiser --- utils/searx.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index 6a8588c23..681b9a0e3 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -748,6 +748,10 @@ excessively bot queries." apache_install_site --variant=uwsgi "${APACHE_SEARX_SITE}" + rst_title "Install searx's uWSGI app (searx.ini)" section + echo + uWSGI_install_app --variant=socket "$SEARX_UWSGI_APP" + if ! service_is_available "${PUBLIC_URL}"; then err_msg "Public service at ${PUBLIC_URL} is not available!" fi @@ -762,11 +766,15 @@ This removes apache site ${APACHE_SEARX_SITE}." ! apache_is_installed && err_msg "Apache is not installed." - if ! ask_yn "Do you really want to continue?"; then + if ! ask_yn "Do you really want to continue?" Yn; then return fi apache_remove_site "${APACHE_SEARX_SITE}" + + rst_title "Remove searx's uWSGI app (searx.ini)" section + echo + uWSGI_remove_app "$SEARX_UWSGI_APP" } rst-doc() { -- cgit v1.2.3 From 67afa6b1fbb635626f278958980b87d3e8fed12c Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Fri, 10 Apr 2020 14:00:52 +0200 Subject: bash scripts: source code cleaned up (shellcheck) Signed-off-by: Markus Heiser --- utils/searx.sh | 7 ------- 1 file changed, 7 deletions(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index 681b9a0e3..dde2b93ab 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -580,13 +580,6 @@ EOF set_result_proxy() { info_msg "try to set result proxy ..." - local line - local stage=0 - local url=" url: $1" - local key=" key: $2" - if [[ -z $2 ]]; then - key= - fi cp "${SEARX_SETTINGS_PATH}" "${SEARX_SETTINGS_PATH}.bak" _set_result_proxy "$1" "$2" > "${SEARX_SETTINGS_PATH}" } -- cgit v1.2.3 From 58d5da8b57c5aeab92f551e8d175be67537c351c Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sat, 11 Apr 2020 13:19:11 +0200 Subject: nginx: normalize installation (docs and script)s over all distros This is the revision of the documentation about the varous nginx installation variants. It also implements the nginx installation scripts for morty and filtron. Signed-off-by: Markus Heiser --- utils/searx.sh | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index dde2b93ab..9a73c58cc 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -114,9 +114,7 @@ usage() { # shellcheck disable=SC1117 cat < Date: Mon, 13 Apr 2020 11:34:28 +0200 Subject: tooling box: added nginx + polished bash scripts and environment - add installation method for nginx sites, morty and filtron - clean up PUBLIC_URL environment in and outside of containers - clean up comand lines - handle uWSGI quirks on fedora (emperor mode) - handle Python quirks on debian (there is no 'python' command anymore) - lib.sh: add die and die_caller functions - lxc_suite_install_info is now a function - lint: shellcheck Signed-off-by: Markus Heiser --- utils/searx.sh | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index 9a73c58cc..48521f606 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -81,6 +81,11 @@ case $DIST_ID-$DIST_VERS in BUILD_PACKAGES="${BUILD_PACKAGES_debian}" APACHE_PACKAGES="$APACHE_PACKAGES libapache2-mod-proxy-uwsgi" ;; + ubuntu-20.04) + # https://askubuntu.com/a/1224710 + SEARX_PACKAGES="${SEARX_PACKAGES_debian} python-is-python3" + BUILD_PACKAGES="${BUILD_PACKAGES_debian}" + ;; ubuntu-*|debian-*) SEARX_PACKAGES="${SEARX_PACKAGES_debian}" BUILD_PACKAGES="${BUILD_PACKAGES_debian}" @@ -206,7 +211,12 @@ main() { pyenv) create_pyenv ;; searx-src) clone_searx ;; settings) install_settings ;; - uwsgi) install_searx_uwsgi;; + uwsgi) + install_searx_uwsgi + if ! service_is_available "http://${SEARX_INTERNAL_HTTP}"; then + err_msg "URL http://${SEARX_INTERNAL_HTTP} not available, check searx & uwsgi setup!" + fi + ;; packages) pkg_install "$SEARX_PACKAGES" ;; @@ -272,11 +282,6 @@ install_all() { rst_title "Install $SEARX_INSTANCE_NAME (service)" pkg_install "$SEARX_PACKAGES" wait_key - case $DIST_ID-$DIST_VERS in - fedora-*) - systemctl enable uwsgi - ;; - esac assert_user wait_key clone_searx @@ -514,6 +519,7 @@ EOF install_searx_uwsgi() { rst_title "Install searx's uWSGI app (searx.ini)" section echo + install_uwsgi uWSGI_install_app "$SEARX_UWSGI_APP" } @@ -575,7 +581,10 @@ EOF } set_result_proxy() { - info_msg "try to set result proxy ..." + + # usage: set_result_proxy [] + + info_msg "try to set result proxy: $1" cp "${SEARX_SETTINGS_PATH}" "${SEARX_SETTINGS_PATH}.bak" _set_result_proxy "$1" "$2" > "${SEARX_SETTINGS_PATH}" } -- cgit v1.2.3 From ea3255835a259516c7a8b62eb319a338cebf7e9f Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Tue, 28 Apr 2020 16:21:45 +0200 Subject: utils/morty.sh: set morty key to avoid service abuse - https://github.com/asciimoo/searx/issues/1871#issuecomment-592459798 make install all generates random MORTY_KEY, install service with that key and sets option in the searx settingy.yml file. Signed-off-by: Markus Heiser --- utils/searx.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index 48521f606..7013ec750 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -584,7 +584,7 @@ set_result_proxy() { # usage: set_result_proxy [] - info_msg "try to set result proxy: $1" + info_msg "try to set result proxy: '$1' ($2)" cp "${SEARX_SETTINGS_PATH}" "${SEARX_SETTINGS_PATH}.bak" _set_result_proxy "$1" "$2" > "${SEARX_SETTINGS_PATH}" } @@ -593,7 +593,7 @@ _set_result_proxy() { local line local stage=0 local url=" url: $1" - local key=" key: $2" + local key=" key: !!binary \"$2\"" if [[ -z $2 ]]; then key= fi -- cgit v1.2.3 From 0973255aff6c7d1ea88147962ae04e9719423c7a Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Thu, 30 Apr 2020 17:49:26 +0200 Subject: [fix] fatal: repository '/root/searx' does not exist The $SERVICE_USER (searx) needs read permission to clone repository. The installation script stops if permission is not granted. - https://github.com/asciimoo/searx/pull/1803#issuecomment-616406528 Signed-off-by: Markus Heiser --- utils/searx.sh | 3 +++ 1 file changed, 3 insertions(+) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index 7013ec750..1499b928f 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -358,6 +358,9 @@ clone_is_available() { clone_searx() { rst_title "Clone searx sources" section echo + if ! sudo -i -u "$SERVICE_USER" ls -d "$REPO_ROOT" > /dev/null; then + die 42 "user '$SERVICE_USER' missed read permission: $REPO_ROOT" + fi SERVICE_HOME="$(sudo -i -u "$SERVICE_USER" echo \$HOME 2>/dev/null)" if [[ ! "${SERVICE_HOME}" ]]; then err_msg "to clone searx sources, user $SERVICE_USER hast to be created first" -- cgit v1.2.3 From f576cadfba11dd96788f5c70e63fba4a70899584 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Thu, 21 May 2020 15:46:43 +0200 Subject: [fix] installation instructions: pip install -e searx (setup.py) In the past we did not really install searx into the virtualenv. This is a problem, since entry-points and other python installation stuff is not trigger. See discussion: https://github.com/asciimoo/searx/pull/1938#issuecomment-632056508 Signed-off-by: Markus Heiser --- utils/searx.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index 1499b928f..d55ec5dba 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -309,7 +309,10 @@ update_searx() { cd ${SEARX_SRC} git checkout -B "$GIT_BRANCH" git pull -${SEARX_SRC}/manage.sh update_packages +pip install -U pip +pip install -U setuptools +pip install -U wheel +pip install -U -e . EOF install_settings uWSGI_restart "$SEARX_UWSGI_APP" @@ -468,8 +471,12 @@ EOF wait_key info_msg "install needed python packages" tee_stderr 0.1 <&1 | prefix_stdout "$_service_prefix" -pip install wheel -${SEARX_SRC}/manage.sh update_packages +pip install -U pip +pip install -U setuptools +pip install -U wheel +pip install -U -e . +cd ${SEARX_SRC} +pip install -e . EOF } -- cgit v1.2.3 From 51428de0fea8c1de10c4caf07ef16ae6eb6e9b24 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Thu, 18 Jun 2020 18:35:59 +0200 Subject: [fix] add missing latexmk package to debian's BUILD_PACKAGES Signed-off-by: Markus Heiser --- utils/searx.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'utils/searx.sh') diff --git a/utils/searx.sh b/utils/searx.sh index d55ec5dba..4009fddb0 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -49,7 +49,8 @@ shellcheck" BUILD_PACKAGES_debian="\ firefox graphviz imagemagick texlive-xetex librsvg2-bin -texlive-latex-recommended texlive-extra-utils ttf-dejavu" +texlive-latex-recommended texlive-extra-utils ttf-dejavu +latexmk" # pacman packages SEARX_PACKAGES_arch="\ -- cgit v1.2.3