From 4139c63d23a1f4cc427eb428bcff0594c395c1c5 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Wed, 8 Jan 2020 19:21:07 +0100 Subject: utils/filtron.sh: add script to install filtron middleware Signed-off-by: Markus Heiser --- utils/filtron.sh | 214 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 214 insertions(+) create mode 100755 utils/filtron.sh (limited to 'utils/filtron.sh') diff --git a/utils/filtron.sh b/utils/filtron.sh new file mode 100755 index 000000000..f310991a0 --- /dev/null +++ b/utils/filtron.sh @@ -0,0 +1,214 @@ +#!/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 +# ---------------------------------------------------------------------------- + +FILTRON_ETC="/etc/filtron" + +SERVICE_NAME="filtron" +SERVICE_USER="${SERVICE_NAME}" +SERVICE_HOME="/home/${SERVICE_USER}" +SERVICE_SYSTEMD_UNIT="${SYSTEMD_UNITS}/${SERVICE_NAME}.service" + +# shellcheck disable=SC2034 +SERVICE_GROUP="${SERVICE_USER}" + +GO_ENV="${SERVICE_HOME}/.go_env" +GO_PKG_URL="https://dl.google.com/go/go1.13.5.linux-amd64.tar.gz" +GO_TAR=$(basename "$GO_PKG_URL") + +# ---------------------------------------------------------------------------- +usage(){ +# ---------------------------------------------------------------------------- + + # shellcheck disable=SC1117 + cat <&1 | prefix_stdout +systemctl enable $SERVICE_NAME.service +systemctl restart $SERVICE_NAME.service +EOF + tee_stderr <&1 | prefix_stdout +systemctl status $SERVICE_NAME.service +EOF + wait_key +} + +deactivate_server () { + rst_title "De-Activate $SERVICE_NAME (service)" section + echo + tee_stderr <&1 | prefix_stdout +systemctl stop $SERVICE_NAME.service +systemctl disable $SERVICE_NAME.service +EOF + wait_key +} + +assert_user() { + rst_title "user $SERVICE_USER" section + echo + tee_stderr 1 < "$GO_ENV" <> ~/.profile +EOF +} + +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" + else + rst_para "Leave HOME folder $(du -sh "$SERVICE_HOME") unchanged." + fi +} + +interactive_shell(){ + echo "// exit with STRG-D" + sudo -H -u ${SERVICE_USER} -i +} + +_service_prefix="$SERVICE_USER@$(hostname) -->| " + +install_go(){ + rst_title "Install Go in user's HOME" section + + rst_para "download and install go binary .." + cache_download "${GO_PKG_URL}" "${GO_TAR}" + + tee_stderr 0.1 </dev/null && echo "Go Installation not found in PATH!?!" +which go >/dev/null && go version && echo "congratulations -- Go installation OK :)" +EOF + wait_key +} + +install_filtron() { + tee_stderr <&1 +EOF + install_template "$FILTRON_ETC/rules.json" root root 644 +} + +# ---------------------------------------------------------------------------- +main "$@" +# ---------------------------------------------------------------------------- -- cgit v1.2.3 From 4990b07b4bc42b0caf0d890f8c81c3545bbb807b Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Thu, 9 Jan 2020 16:25:05 +0100 Subject: utils/filtron.sh: various fix from first installation test (WIP) Signed-off-by: Markus Heiser --- utils/filtron.sh | 77 +++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 60 insertions(+), 17 deletions(-) (limited to 'utils/filtron.sh') diff --git a/utils/filtron.sh b/utils/filtron.sh index f310991a0..593c0fcf7 100755 --- a/utils/filtron.sh +++ b/utils/filtron.sh @@ -11,6 +11,11 @@ source "$(dirname "${BASH_SOURCE[0]}")/lib.sh" FILTRON_ETC="/etc/filtron" +FILTRON_RULES="$FILTRON_ETC/rules.json" +FILTRON_API="127.0.0.1:4005" +FILTRON_LISTEN="127.0.0.1:4004" +FILTRON_TARGET="127.0.0.1:8888" + SERVICE_NAME="filtron" SERVICE_USER="${SERVICE_NAME}" SERVICE_HOME="/home/${SERVICE_USER}" @@ -23,6 +28,11 @@ GO_ENV="${SERVICE_HOME}/.go_env" GO_PKG_URL="https://dl.google.com/go/go1.13.5.linux-amd64.tar.gz" GO_TAR=$(basename "$GO_PKG_URL") +CONFIG_FILES=( + "${FILTRON_RULES}" + "${SERVICE_SYSTEMD_UNIT}" +) + # ---------------------------------------------------------------------------- usage(){ # ---------------------------------------------------------------------------- @@ -37,10 +47,16 @@ usage: $(basename "$0") remove [all] $(basename "$0") activate [server] $(basename "$0") deactivate [server] - -shell - start interactive shell with user ${SERVICE_USER} -install user - add service user '$SERVICE_USER' at $SERVICE_HOME - + $(basename "$0") show [server] + +shell + start interactive shell from user ${SERVICE_USER} +show server + show server status and log +install / remove + all - complete setup of filtron server +install user + add service user '$SERVICE_USER' at $SERVICE_HOME EOF [ ! -z ${1+x} ] && echo -e "$1" } @@ -58,6 +74,14 @@ main(){ sudo_or_exit interactive_shell ;; + show) + case $2 in + server) + sudo_or_exit + show_server + ;; + *) usage "$_usage"; exit 42;; + esac ;; install) sudo_or_exit case $2 in @@ -91,21 +115,27 @@ main(){ install_all() { rst_title "Install $SERVICE_NAME (service)" assert_user + wait_key install_go + wait_key install_filtron + wait_key install_server + wait_key } remove_all() { rst_title "De-Install $SERVICE_NAME (service)" remove_server + wait_key remove_user - rm -rf "$FILTRON_ETC" + rm -r "$FILTRON_ETC" 2>&1 | prefix_stdout wait_key } install_server() { - rst_title "Install System-D Unit ${SERVICE_NAME}.service ..." section + rst_title "Install System-D Unit ${SERVICE_NAME}.service" section + echo install_template ${SERVICE_SYSTEMD_UNIT} root root 644 wait_key activate_server @@ -116,12 +146,12 @@ remove_server() { return fi deactivate_server - rm "${SERVICE_SYSTEMD_UNIT}" + rm "${SERVICE_SYSTEMD_UNIT}" 2>&1 | prefix_stdout } - activate_server () { rst_title "Activate $SERVICE_NAME (service)" section + echo tee_stderr <&1 | prefix_stdout systemctl enable $SERVICE_NAME.service systemctl restart $SERVICE_NAME.service @@ -129,7 +159,6 @@ EOF tee_stderr <&1 | prefix_stdout systemctl status $SERVICE_NAME.service EOF - wait_key } deactivate_server () { @@ -139,7 +168,6 @@ deactivate_server () { systemctl stop $SERVICE_NAME.service systemctl disable $SERVICE_NAME.service EOF - wait_key } assert_user() { @@ -168,18 +196,18 @@ EOF 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" + userdel -r -f "$SERVICE_USER" 2>&1 | prefix_stdout else rst_para "Leave HOME folder $(du -sh "$SERVICE_HOME") unchanged." fi } interactive_shell(){ - echo "// exit with STRG-D" + echo "// exit with CTRL-D" sudo -H -u ${SERVICE_USER} -i } -_service_prefix="$SERVICE_USER@$(hostname) -->| " +_service_prefix=" |$SERVICE_USER| " install_go(){ rst_title "Install Go in user's HOME" section @@ -199,14 +227,29 @@ EOF ! which go >/dev/null && echo "Go Installation not found in PATH!?!" which go >/dev/null && go version && echo "congratulations -- Go installation OK :)" EOF - wait_key } install_filtron() { - tee_stderr <&1 + rst_title "Install filtron in user's ~/go-apps" section + echo + tee_stderr <&1 | prefix_stdout "$_service_prefix" +go get -v -u github.com/asciimoo/filtron EOF - install_template "$FILTRON_ETC/rules.json" root root 644 + install_template --no-eval "$FILTRON_RULES" root root 644 +} + +show_server () { + rst_title "server status & log" + echo + systemctl status filtron.service + echo + read -s -n1 -t 5 -p "// use CTRL-C to stop monitoring the log" + echo + while true; do + trap break 2 + journalctl -f -u filtron + done + return 0 } # ---------------------------------------------------------------------------- -- cgit v1.2.3 From 39feb141bc8361915b3d80a976852b38851e0419 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sat, 11 Jan 2020 12:50:40 +0100 Subject: docs(admin): add description of the utils/filtron.sh script Signed-off-by: Markus Heiser --- utils/filtron.sh | 48 ++++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 22 deletions(-) (limited to 'utils/filtron.sh') diff --git a/utils/filtron.sh b/utils/filtron.sh index 593c0fcf7..597d0c634 100755 --- a/utils/filtron.sh +++ b/utils/filtron.sh @@ -45,18 +45,22 @@ usage: $(basename "$0") shell $(basename "$0") install [all|user] $(basename "$0") remove [all] - $(basename "$0") activate [server] - $(basename "$0") deactivate [server] - $(basename "$0") show [server] + $(basename "$0") activate [service] + $(basename "$0") deactivate [service] + $(basename "$0") show [service] shell start interactive shell from user ${SERVICE_USER} -show server - show server status and log -install / remove - all - complete setup of filtron server +install / remove all + complete setup of filtron service +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 [ ! -z ${1+x} ] && echo -e "$1" } @@ -68,7 +72,7 @@ main(){ case $1 in --source-only) ;; - -h|--help) usage ;; + -h|--help) usage; exit 0;; shell) sudo_or_exit @@ -76,9 +80,9 @@ main(){ ;; show) case $2 in - server) + service) sudo_or_exit - show_server + show_service ;; *) usage "$_usage"; exit 42;; esac ;; @@ -99,13 +103,13 @@ main(){ activate) sudo_or_exit case $2 in - server) activate_server ;; + service) activate_service ;; *) usage "$_usage"; exit 42;; esac ;; deactivate) sudo_or_exit case $2 in - server) deactivate_server ;; + service) deactivate_service ;; *) usage "$_usage"; exit 42;; esac ;; *) usage "ERROR: unknown or missing command $1"; exit 42;; @@ -120,36 +124,36 @@ install_all() { wait_key install_filtron wait_key - install_server + install_service wait_key } remove_all() { rst_title "De-Install $SERVICE_NAME (service)" - remove_server + remove_service wait_key remove_user rm -r "$FILTRON_ETC" 2>&1 | prefix_stdout wait_key } -install_server() { +install_service() { rst_title "Install System-D Unit ${SERVICE_NAME}.service" section echo install_template ${SERVICE_SYSTEMD_UNIT} root root 644 wait_key - activate_server + activate_service } -remove_server() { +remove_service() { if ! ask_yn "Do you really want to deinstall $SERVICE_NAME?"; then return fi - deactivate_server + deactivate_service rm "${SERVICE_SYSTEMD_UNIT}" 2>&1 | prefix_stdout } -activate_server () { +activate_service () { rst_title "Activate $SERVICE_NAME (service)" section echo tee_stderr <&1 | prefix_stdout @@ -161,7 +165,7 @@ systemctl status $SERVICE_NAME.service EOF } -deactivate_server () { +deactivate_service () { rst_title "De-Activate $SERVICE_NAME (service)" section echo tee_stderr <&1 | prefix_stdout @@ -238,8 +242,8 @@ EOF install_template --no-eval "$FILTRON_RULES" root root 644 } -show_server () { - rst_title "server status & log" +show_service () { + rst_title "service status & log" echo systemctl status filtron.service echo -- cgit v1.2.3 From 3ed82a97af4f0c65d59bbf748a19ac907db40753 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sun, 12 Jan 2020 15:51:04 +0100 Subject: utils/filtron.sh: add command 'update filtron' BTW: tidy up some code style and fix some issues reported by the linter. Signed-off-by: Markus Heiser --- utils/filtron.sh | 50 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 14 deletions(-) (limited to 'utils/filtron.sh') diff --git a/utils/filtron.sh b/utils/filtron.sh index 597d0c634..5c8a738b0 100755 --- a/utils/filtron.sh +++ b/utils/filtron.sh @@ -12,8 +12,12 @@ source "$(dirname "${BASH_SOURCE[0]}")/lib.sh" FILTRON_ETC="/etc/filtron" FILTRON_RULES="$FILTRON_ETC/rules.json" + +# shellcheck disable=SC2034 FILTRON_API="127.0.0.1:4005" +# shellcheck disable=SC2034 FILTRON_LISTEN="127.0.0.1:4004" +# shellcheck disable=SC2034 FILTRON_TARGET="127.0.0.1:8888" SERVICE_NAME="filtron" @@ -28,6 +32,7 @@ GO_ENV="${SERVICE_HOME}/.go_env" GO_PKG_URL="https://dl.google.com/go/go1.13.5.linux-amd64.tar.gz" GO_TAR=$(basename "$GO_PKG_URL") +# shellcheck disable=SC2034 CONFIG_FILES=( "${FILTRON_RULES}" "${SERVICE_SYSTEMD_UNIT}" @@ -44,6 +49,7 @@ usage: $(basename "$0") shell $(basename "$0") install [all|user] + $(basename "$0") update [filtron] $(basename "$0") remove [all] $(basename "$0") activate [service] $(basename "$0") deactivate [service] @@ -51,8 +57,10 @@ usage: shell start interactive shell from user ${SERVICE_USER} -install / remove all +install / remove all complete setup of filtron service +update filtron + Update filtron installation of user ${SERVICE_USER} activate activate and start service daemon (systemd unit) deactivate service @@ -71,33 +79,39 @@ main(){ local _usage="ERROR: unknown or missing $1 command $2" case $1 in - --source-only) ;; + --source-only) ;; -h|--help) usage; exit 0;; - shell) - sudo_or_exit - interactive_shell - ;; + shell) + sudo_or_exit + interactive_shell + ;; show) case $2 in service) - sudo_or_exit - show_service - ;; + sudo_or_exit + show_service + ;; *) usage "$_usage"; exit 42;; esac ;; install) sudo_or_exit case $2 in all) install_all ;; - user) assert_user ;; + user) assert_user ;; + *) usage "$_usage"; exit 42;; + esac ;; + update) + sudo_or_exit + case $2 in + filtron) update_filtron ;; *) usage "$_usage"; exit 42;; esac ;; remove) sudo_or_exit case $2 in all) remove_all;; - user) remove_user ;; + user) remove_user ;; *) usage "$_usage"; exit 42;; esac ;; activate) @@ -242,16 +256,24 @@ EOF install_template --no-eval "$FILTRON_RULES" root root 644 } +update_filtron() { + rst_title "Update filtron" section + echo + tee_stderr <&1 | prefix_stdout "$_service_prefix" +go get -v -u github.com/asciimoo/filtron +EOF +} + show_service () { rst_title "service status & log" echo systemctl status filtron.service echo - read -s -n1 -t 5 -p "// use CTRL-C to stop monitoring the log" + read -r -s -n1 -t 5 -p "// use CTRL-C to stop monitoring the log" echo while true; do - trap break 2 - journalctl -f -u filtron + trap break 2 + journalctl -f -u filtron done return 0 } -- cgit v1.2.3 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/filtron.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'utils/filtron.sh') diff --git a/utils/filtron.sh b/utils/filtron.sh index 5c8a738b0..50cce6e65 100755 --- a/utils/filtron.sh +++ b/utils/filtron.sh @@ -192,7 +192,8 @@ assert_user() { rst_title "user $SERVICE_USER" section echo tee_stderr 1 < 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/filtron.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'utils/filtron.sh') diff --git a/utils/filtron.sh b/utils/filtron.sh index 50cce6e65..bf6016b0f 100755 --- a/utils/filtron.sh +++ b/utils/filtron.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 -- 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/filtron.sh | 98 ++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 84 insertions(+), 14 deletions(-) (limited to 'utils/filtron.sh') diff --git a/utils/filtron.sh b/utils/filtron.sh index bf6016b0f..bb6597fa5 100755 --- a/utils/filtron.sh +++ b/utils/filtron.sh @@ -13,11 +13,8 @@ FILTRON_ETC="/etc/filtron" FILTRON_RULES="$FILTRON_ETC/rules.json" -# shellcheck disable=SC2034 FILTRON_API="127.0.0.1:4005" -# shellcheck disable=SC2034 FILTRON_LISTEN="127.0.0.1:4004" -# shellcheck disable=SC2034 FILTRON_TARGET="127.0.0.1:8888" SERVICE_NAME="filtron" @@ -32,6 +29,8 @@ GO_ENV="${SERVICE_HOME}/.go_env" GO_PKG_URL="https://dl.google.com/go/go1.13.5.linux-amd64.tar.gz" GO_TAR=$(basename "$GO_PKG_URL") +APACHE_SITE="searx.conf" + # shellcheck disable=SC2034 CONFIG_FILES=( "${FILTRON_RULES}" @@ -39,7 +38,7 @@ CONFIG_FILES=( ) # ---------------------------------------------------------------------------- -usage(){ +usage() { # ---------------------------------------------------------------------------- # shellcheck disable=SC1117 @@ -73,7 +72,7 @@ EOF [ ! -z ${1+x} ] && echo -e "$1" } -main(){ +main() { rst_title "$SERVICE_NAME" part local _usage="ERROR: unknown or missing $1 command $2" @@ -140,6 +139,10 @@ install_all() { wait_key install_service wait_key + if apache_is_installed; then + install_apache_site + wait_key + fi } remove_all() { @@ -151,10 +154,22 @@ remove_all() { wait_key } +filtron_is_available() { + curl --insecure "http://${FILTRON_LISTEN}" &>/dev/null +} + +api_is_available() { + curl --insecure "http://${FILTRON_API}" &>/dev/null +} + +target_is_available() { + curl --insecure "http://${FILTRON_TARGET}" &>/dev/null +} + install_service() { rst_title "Install System-D Unit ${SERVICE_NAME}.service" section echo - install_template ${SERVICE_SYSTEMD_UNIT} root root 644 + install_template "${SERVICE_SYSTEMD_UNIT}" root root 644 wait_key activate_service } @@ -167,19 +182,19 @@ remove_service() { rm "${SERVICE_SYSTEMD_UNIT}" 2>&1 | prefix_stdout } -activate_service () { +activate_service() { rst_title "Activate $SERVICE_NAME (service)" section echo - tee_stderr <&1 | prefix_stdout + tee_stderr <&1 systemctl enable $SERVICE_NAME.service systemctl restart $SERVICE_NAME.service EOF - tee_stderr <&1 | prefix_stdout + tee_stderr <&1 systemctl status $SERVICE_NAME.service EOF } -deactivate_service () { +deactivate_service() { rst_title "De-Activate $SERVICE_NAME (service)" section echo tee_stderr <&1 | prefix_stdout @@ -188,6 +203,10 @@ systemctl disable $SERVICE_NAME.service EOF } +user_is_available() { + sudo -i -u "$SERVICE_USER" echo \$HOME &>/dev/null +} + assert_user() { rst_title "user $SERVICE_USER" section echo @@ -228,7 +247,11 @@ interactive_shell(){ _service_prefix=" |$SERVICE_USER| " -install_go(){ +go_is_available() { + sudo -i -u "$SERVICE_USER" which go &>/dev/null +} + +install_go() { rst_title "Install Go in user's HOME" section rst_para "download and install go binary .." @@ -248,6 +271,10 @@ which go >/dev/null && go version && echo "congratulations -- Go installation O EOF } +filtron_is_installed() { + [[ -f $SERVICE_HOME/go-apps/bin/filtron ]] +} + install_filtron() { rst_title "Install filtron in user's ~/go-apps" section echo @@ -265,12 +292,48 @@ go get -v -u github.com/asciimoo/filtron EOF } -show_service () { +show_service() { rst_title "service status & log" echo - systemctl status filtron.service + + 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 go_is_available; then + info_msg "~$SERVICE_USER: go is installed" + else + err_msg "~$SERVICE_USER: go is not installed" + fi + if filtron_is_installed; then + info_msg "~$SERVICE_USER: filtron app is installed" + else + err_msg "~$SERVICE_USER: filtron app is not installed!" + fi + if api_is_available; then + info_msg "API available at: http://${FILTRON_API}" + else + err_msg "API not available at: http://${FILTRON_API}" + fi + if filtron_is_available; then + info_msg "Filtron listening on: http://${FILTRON_LISTEN}" + else + err_msg "Filtron does not listening on: http://${FILTRON_LISTEN}" + fi + if target_is_available; then + info_msg "Filtron's target is available at: http://${FILTRON_TARGET}" + else + err_msg "Filtron's target is not available at: http://${FILTRON_TARGET}" + fi + + wait_key echo - read -r -s -n1 -t 5 -p "// use CTRL-C to stop monitoring the log" + systemctl --no-pager -l status filtron.service + echo + read -r -s -n1 -t 2 -p "// use CTRL-C to stop monitoring the log" echo while true; do trap break 2 @@ -279,6 +342,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 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/filtron.sh | 1 + 1 file changed, 1 insertion(+) (limited to 'utils/filtron.sh') diff --git a/utils/filtron.sh b/utils/filtron.sh index bb6597fa5..7defe1ec5 100755 --- a/utils/filtron.sh +++ b/utils/filtron.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 -- 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/filtron.sh | 155 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 114 insertions(+), 41 deletions(-) (limited to 'utils/filtron.sh') diff --git a/utils/filtron.sh b/utils/filtron.sh index 7defe1ec5..6ea001d42 100755 --- a/utils/filtron.sh +++ b/utils/filtron.sh @@ -5,6 +5,7 @@ # shellcheck source=utils/lib.sh source "$(dirname "${BASH_SOURCE[0]}")/lib.sh" +source_dot_config # ---------------------------------------------------------------------------- # config @@ -30,7 +31,9 @@ GO_ENV="${SERVICE_HOME}/.go_env" GO_PKG_URL="https://dl.google.com/go/go1.13.5.linux-amd64.tar.gz" GO_TAR=$(basename "$GO_PKG_URL") -APACHE_SITE="searx.conf" +# Apache Settings + +APACHE_FILTRON_SITE="searx.conf" # shellcheck disable=SC2034 CONFIG_FILES=( @@ -53,22 +56,32 @@ usage: $(basename "$0") remove [all] $(basename "$0") activate [service] $(basename "$0") deactivate [service] - $(basename "$0") show [service] + $(basename "$0") inspect [service] + $(basename "$0") apache [install|remove] + shell start interactive shell from user ${SERVICE_USER} -install / remove all - complete setup of filtron service +install / remove + all: complete setup of filtron service + user: add/remove service user '$SERVICE_USER' at $SERVICE_HOME update filtron Update filtron installation of user ${SERVICE_USER} -activate +activate service 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 +inspect service show service status and log +apache + install: apache site with a reverse proxy (ProxyPass) + remove: apache site ${APACHE_FILTRON_SITE} + +If needed change the environment variable PUBLIC_URL of your WEB service in the +${DOT_CONFIG#"$REPO_ROOT/"} file: + + PUBLIC_URL : ${PUBLIC_URL} + EOF [ ! -z ${1+x} ] && echo -e "$1" } @@ -76,6 +89,10 @@ EOF main() { rst_title "$SERVICE_NAME" part + required_commands \ + dpkg apt-get install git wget curl \ + || exit + local _usage="ERROR: unknown or missing $1 command $2" case $1 in @@ -86,11 +103,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 ;; @@ -126,6 +143,14 @@ main() { service) deactivate_service ;; *) 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 } @@ -140,14 +165,29 @@ install_all() { wait_key install_service wait_key + echo + if ! service_is_available "http://${FILTRON_LISTEN}" ; then + err_msg "Filtron does not listening on: http://${FILTRON_LISTEN}" + fi if apache_is_installed; then - install_apache_site - wait_key + info_msg "Apache is installed on this host." + if ask_yn "Do you want to install a reverse proxy (ProxyPass)" Yn; then + install_apache_site + fi + fi + if ask_yn "Do you want to inspect the installation?" Yn; then + inspect_service fi + } 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." + remove_service wait_key remove_user @@ -155,18 +195,6 @@ remove_all() { wait_key } -filtron_is_available() { - curl --insecure "http://${FILTRON_LISTEN}" &>/dev/null -} - -api_is_available() { - curl --insecure "http://${FILTRON_API}" &>/dev/null -} - -target_is_available() { - curl --insecure "http://${FILTRON_TARGET}" &>/dev/null -} - install_service() { rst_title "Install System-D Unit ${SERVICE_NAME}.service" section echo @@ -191,7 +219,7 @@ systemctl enable $SERVICE_NAME.service systemctl restart $SERVICE_NAME.service EOF tee_stderr <&1 -systemctl status $SERVICE_NAME.service +systemctl status --no-pager $SERVICE_NAME.service EOF } @@ -265,9 +293,8 @@ mkdir -p \$HOME/local rm -rf \$HOME/local/go tar -C \$HOME/local -xzf ${CACHE}/${GO_TAR} EOF - echo sudo -i -u "$SERVICE_USER" </dev/null && echo "Go Installation not found in PATH!?!" +! which go >/dev/null && echo "ERROR - Go Installation not found in PATH!?!" which go >/dev/null && go version && echo "congratulations -- Go installation OK :)" EOF } @@ -293,9 +320,20 @@ go get -v -u github.com/asciimoo/filtron EOF } -show_service() { +inspect_service() { + rst_title "service status & log" - echo + + cat < 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/filtron.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'utils/filtron.sh') diff --git a/utils/filtron.sh b/utils/filtron.sh index 6ea001d42..d6e5b6a1b 100755 --- a/utils/filtron.sh +++ b/utils/filtron.sh @@ -11,6 +11,10 @@ source_dot_config # config # ---------------------------------------------------------------------------- +FILTRON_URL_PATH="${FILTRON_URL_PATH:-$(echo "${PUBLIC_URL}" \ +| sed -e 's,^.*://[^/]*\(/.*\),\1,g')}" +[[ "${FILTRON_URL_PATH}" == "${PUBLIC_URL}" ]] && FILTRON_URL_PATH=/ + FILTRON_ETC="/etc/filtron" FILTRON_RULES="$FILTRON_ETC/rules.json" @@ -192,7 +196,9 @@ installations that were installed with this script." wait_key remove_user rm -r "$FILTRON_ETC" 2>&1 | prefix_stdout - wait_key + if service_is_available "${PUBLIC_URL}"; then + MSG="** Don't forget to remove your public site! (${PUBLIC_URL}) **" wait_key 10 + fi } install_service() { @@ -329,6 +335,7 @@ inspect_service() { sourced ${DOT_CONFIG#"$REPO_ROOT/"} : PUBLIC_URL : ${PUBLIC_URL} + FILTRON_URL_PATH : ${FILTRON_URL_PATH} FILTRON_API : ${FILTRON_API} FILTRON_LISTEN : ${FILTRON_LISTEN} FILTRON_TARGET : ${FILTRON_TARGET} @@ -395,6 +402,7 @@ This installs a reverse proxy (ProxyPass) into apache site (${APACHE_FILTRON_SIT return fi + a2enmod headers a2enmod proxy a2enmod proxy_http -- 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/filtron.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'utils/filtron.sh') diff --git a/utils/filtron.sh b/utils/filtron.sh index d6e5b6a1b..9559902dd 100755 --- a/utils/filtron.sh +++ b/utils/filtron.sh @@ -1,7 +1,7 @@ #!/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=SC2119,SC2001 # shellcheck source=utils/lib.sh source "$(dirname "${BASH_SOURCE[0]}")/lib.sh" @@ -84,7 +84,8 @@ apache If needed change the environment variable PUBLIC_URL of your WEB service in the ${DOT_CONFIG#"$REPO_ROOT/"} file: - PUBLIC_URL : ${PUBLIC_URL} + PUBLIC_URL : ${PUBLIC_URL} + PUBLIC_HOST : ${PUBLIC_HOST} EOF [ ! -z ${1+x} ] && echo -e "$1" @@ -335,6 +336,7 @@ inspect_service() { sourced ${DOT_CONFIG#"$REPO_ROOT/"} : PUBLIC_URL : ${PUBLIC_URL} + PUBLIC_HOST : ${PUBLIC_HOST} FILTRON_URL_PATH : ${FILTRON_URL_PATH} FILTRON_API : ${FILTRON_API} FILTRON_LISTEN : ${FILTRON_LISTEN} -- cgit v1.2.3 From 0bb884708745a708b35a3185afc6ad99f20c1838 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Fri, 31 Jan 2020 17:25:38 +0100 Subject: utils/filtron.sh: add option to debug filtron requests Signed-off-by: Markus Heiser --- utils/filtron.sh | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-) (limited to 'utils/filtron.sh') diff --git a/utils/filtron.sh b/utils/filtron.sh index 9559902dd..528bedff2 100755 --- a/utils/filtron.sh +++ b/utils/filtron.sh @@ -61,6 +61,7 @@ usage: $(basename "$0") activate [service] $(basename "$0") deactivate [service] $(basename "$0") inspect [service] + $(basename "$0") option [debug-on|debug-off] $(basename "$0") apache [install|remove] @@ -77,6 +78,8 @@ deactivate service stop and deactivate service daemon (systemd unit) inspect service show service status and log +option + set one of the available options apache install: apache site with a reverse proxy (ProxyPass) remove: apache site ${APACHE_FILTRON_SITE} @@ -155,6 +158,13 @@ main() { remove) remove_apache_site ;; *) 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;; esac @@ -378,7 +388,12 @@ EOF err_msg "Public service at ${PUBLIC_URL} is not available!" fi - wait_key + local _debug_on + if ask_yn "Enable filtron debug mode?"; then + enable_debug + _debug_on=1 + fi + echo systemctl --no-pager -l status filtron.service echo @@ -388,9 +403,66 @@ EOF trap break 2 journalctl -f -u filtron done + + if [[ $_debug_on == 1 ]]; then + disable_debug + fi return 0 } + +enable_debug() { + info_msg "try to enable debug mode ..." + python < Date: Fri, 31 Jan 2020 18:24:31 +0100 Subject: utils/lib.sh: colorize messages Signed-off-by: Markus Heiser --- utils/filtron.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'utils/filtron.sh') diff --git a/utils/filtron.sh b/utils/filtron.sh index 528bedff2..8283c9664 100755 --- a/utils/filtron.sh +++ b/utils/filtron.sh @@ -287,7 +287,7 @@ remove_user() { } interactive_shell(){ - echo "// exit with CTRL-D" + echo "// exit with ${_BCyan}CTRL-D${_creset}" sudo -H -u ${SERVICE_USER} -i } @@ -397,7 +397,9 @@ EOF echo systemctl --no-pager -l status filtron.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/filtron.sh | 99 ++++++-------------------------------------------------- 1 file changed, 10 insertions(+), 89 deletions(-) (limited to 'utils/filtron.sh') diff --git a/utils/filtron.sh b/utils/filtron.sh index 8283c9664..2aa8cf4f5 100755 --- a/utils/filtron.sh +++ b/utils/filtron.sh @@ -109,7 +109,7 @@ main() { shell) sudo_or_exit - interactive_shell + interactive_shell "${SERVICE_USER}" ;; inspect) case $2 in @@ -136,19 +136,19 @@ main() { sudo_or_exit case $2 in all) remove_all;; - user) remove_user ;; + user) drop_service_account "${SERVICE_USER}" ;; *) usage "$_usage"; exit 42;; esac ;; activate) sudo_or_exit case $2 in - service) activate_service ;; + service) systemd_activate_service "${SERVICE_NAME}" ;; *) usage "$_usage"; exit 42;; esac ;; deactivate) sudo_or_exit case $2 in - service) deactivate_service ;; + service) systemd_deactivate_service "${SERVICE_NAME}" ;; *) usage "$_usage"; exit 42;; esac ;; apache) @@ -174,11 +174,11 @@ install_all() { rst_title "Install $SERVICE_NAME (service)" assert_user wait_key - install_go + install_go "${GO_PKG_URL}" "${GO_TAR}" "${SERVICE_USER}" wait_key install_filtron wait_key - install_service + systemd_install_service "${SERVICE_NAME}" "${SERVICE_SYSTEMD_UNIT}" wait_key echo if ! service_is_available "http://${FILTRON_LISTEN}" ; then @@ -203,56 +203,15 @@ remove_all() { It goes without saying that this script can only be used to remove installations that were installed with this script." - remove_service + systemd_remove_service "${SERVICE_NAME}" "${SERVICE_SYSTEMD_UNIT}" wait_key - remove_user + drop_service_account "${SERVICE_USER}" rm -r "$FILTRON_ETC" 2>&1 | prefix_stdout if service_is_available "${PUBLIC_URL}"; then MSG="** Don't forget to remove your public site! (${PUBLIC_URL}) **" wait_key 10 fi } -install_service() { - rst_title "Install System-D Unit ${SERVICE_NAME}.service" section - echo - install_template "${SERVICE_SYSTEMD_UNIT}" root root 644 - wait_key - activate_service -} - -remove_service() { - if ! ask_yn "Do you really want to deinstall $SERVICE_NAME?"; then - return - fi - deactivate_service - rm "${SERVICE_SYSTEMD_UNIT}" 2>&1 | prefix_stdout -} - -activate_service() { - rst_title "Activate $SERVICE_NAME (service)" section - echo - tee_stderr <&1 -systemctl enable $SERVICE_NAME.service -systemctl restart $SERVICE_NAME.service -EOF - tee_stderr <&1 -systemctl status --no-pager $SERVICE_NAME.service -EOF -} - -deactivate_service() { - rst_title "De-Activate $SERVICE_NAME (service)" section - echo - tee_stderr <&1 | prefix_stdout -systemctl stop $SERVICE_NAME.service -systemctl disable $SERVICE_NAME.service -EOF -} - -user_is_available() { - sudo -i -u "$SERVICE_USER" echo \$HOME &>/dev/null -} - assert_user() { rst_title "user $SERVICE_USER" section echo @@ -277,44 +236,6 @@ grep -qFs -- 'source $GO_ENV' ~/.profile || echo 'source $GO_ENV' >> ~/.profile EOF } -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 -} - -interactive_shell(){ - echo "// exit with ${_BCyan}CTRL-D${_creset}" - sudo -H -u ${SERVICE_USER} -i -} - -_service_prefix=" |$SERVICE_USER| " - -go_is_available() { - sudo -i -u "$SERVICE_USER" which go &>/dev/null -} - -install_go() { - rst_title "Install Go in user's HOME" section - - rst_para "download and install go binary .." - cache_download "${GO_PKG_URL}" "${GO_TAR}" - - tee_stderr 0.1 </dev/null && echo "ERROR - Go Installation not found in PATH!?!" -which go >/dev/null && go version && echo "congratulations -- Go installation OK :)" -EOF -} filtron_is_installed() { [[ -f $SERVICE_HOME/go-apps/bin/filtron ]] @@ -356,12 +277,12 @@ EOF apache_is_installed && info_msg "Apache is installed." - if user_is_available; then + if service_account_is_available "$SERVICE_USER"; then info_msg "service account $SERVICE_USER available." else err_msg "service account $SERVICE_USER not available!" fi - if go_is_available; then + if go_is_available "$SERVICE_USER"; then info_msg "~$SERVICE_USER: go is installed" else err_msg "~$SERVICE_USER: go is not installed" -- cgit v1.2.3 From a4437c47ac0bd22cd7f5aaa8e7895cdd8e93a317 Mon Sep 17 00:00:00 2001 From: Markus Heiser 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/filtron.sh | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) (limited to 'utils/filtron.sh') diff --git a/utils/filtron.sh b/utils/filtron.sh index 2aa8cf4f5..dd49a3d1e 100755 --- a/utils/filtron.sh +++ b/utils/filtron.sh @@ -24,9 +24,11 @@ FILTRON_LISTEN="127.0.0.1:4004" FILTRON_TARGET="127.0.0.1:8888" SERVICE_NAME="filtron" -SERVICE_USER="${SERVICE_NAME}" +SERVICE_USER="${SERVICE_USER:-${SERVICE_NAME}}" SERVICE_HOME="/home/${SERVICE_USER}" SERVICE_SYSTEMD_UNIT="${SYSTEMD_UNITS}/${SERVICE_NAME}.service" +# shellcheck disable=SC2034 +SERVICE_GROUP="${SERVICE_USER}" # shellcheck disable=SC2034 SERVICE_GROUP="${SERVICE_USER}" @@ -52,7 +54,7 @@ usage() { # shellcheck disable=SC1117 cat <&1 | prefix_stdout if service_is_available "${PUBLIC_URL}"; then @@ -231,7 +232,7 @@ export PATH=\$PATH:\$HOME/local/go/bin:\$GOPATH/bin EOF echo "Environment $GO_ENV has been setup." - tee_stderr <> ~/.profile EOF } @@ -241,10 +242,12 @@ filtron_is_installed() { [[ -f $SERVICE_HOME/go-apps/bin/filtron ]] } +_svcpr=" |${SERVICE_USER}| " + install_filtron() { rst_title "Install filtron in user's ~/go-apps" section echo - tee_stderr <&1 | prefix_stdout "$_service_prefix" + tee_stderr <&1 | prefix_stdout "$_svcpr" go get -v -u github.com/asciimoo/filtron EOF install_template --no-eval "$FILTRON_RULES" root root 644 @@ -253,7 +256,7 @@ EOF update_filtron() { rst_title "Update filtron" section echo - tee_stderr <&1 | prefix_stdout "$_service_prefix" + tee_stderr <&1 | prefix_stdout "$_svcpr" go get -v -u github.com/asciimoo/filtron EOF } @@ -301,12 +304,14 @@ EOF err_msg "Filtron does not listening on: http://${FILTRON_LISTEN}" fi - if ! service_is_available ""http://${FILTRON_TARGET}"" ; then + if service_is_available ""http://${FILTRON_TARGET}"" ; then info_msg "Filtron's target is available at: http://${FILTRON_TARGET}" fi if ! service_is_available "${PUBLIC_URL}"; then err_msg "Public service at ${PUBLIC_URL} is not available!" + echo -e "${_Green}stop with [${_BCyan}CTRL-C${_Green}] or .." + wait_key fi local _debug_on @@ -316,15 +321,17 @@ EOF fi echo - systemctl --no-pager -l status filtron.service + systemctl --no-pager -l status "${SERVICE_NAME}" echo + + info_msg "public URL --> ${PUBLIC_URL}" # 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 - journalctl -f -u filtron + journalctl -f -u "${SERVICE_NAME}" done if [[ $_debug_on == 1 ]]; then -- 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/filtron.sh | 1 + 1 file changed, 1 insertion(+) (limited to 'utils/filtron.sh') diff --git a/utils/filtron.sh b/utils/filtron.sh index dd49a3d1e..2a68f1728 100755 --- a/utils/filtron.sh +++ b/utils/filtron.sh @@ -89,6 +89,7 @@ If needed, set PUBLIC_URL of your WEB service in the '${DOT_CONFIG#"$REPO_ROOT/" PUBLIC_URL : ${PUBLIC_URL} PUBLIC_HOST : ${PUBLIC_HOST} + 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/filtron.sh | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'utils/filtron.sh') diff --git a/utils/filtron.sh b/utils/filtron.sh index 2a68f1728..3c545ff14 100755 --- a/utils/filtron.sh +++ b/utils/filtron.sh @@ -19,13 +19,14 @@ FILTRON_ETC="/etc/filtron" FILTRON_RULES="$FILTRON_ETC/rules.json" -FILTRON_API="127.0.0.1:4005" -FILTRON_LISTEN="127.0.0.1:4004" -FILTRON_TARGET="127.0.0.1:8888" +FILTRON_API="${FILTRON_API:-127.0.0.1:4005}" +FILTRON_LISTEN="${FILTRON_LISTEN:-127.0.0.1:4004}" +FILTRON_TARGET="${FILTRON_TARGET:-127.0.0.1:8888}" SERVICE_NAME="filtron" 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}" SERVICE_SYSTEMD_UNIT="${SYSTEMD_UNITS}/${SERVICE_NAME}.service" # shellcheck disable=SC2034 SERVICE_GROUP="${SERVICE_USER}" @@ -70,9 +71,9 @@ shell start interactive shell from user ${SERVICE_USER} install / remove :all: complete setup of filtron service - :user: add/remove service user '$SERVICE_USER' at $SERVICE_HOME + :user: add/remove service user '$SERVICE_USER' ($SERVICE_HOME) update filtron - Update filtron installation of user ${SERVICE_USER} + Update filtron installation ($SERVICE_HOME) activate service activate and start service daemon (systemd unit) deactivate service @@ -87,10 +88,12 @@ apache : ${PUBLIC_URL} If needed, set PUBLIC_URL of your WEB service in the '${DOT_CONFIG#"$REPO_ROOT/"}' file:: - PUBLIC_URL : ${PUBLIC_URL} - PUBLIC_HOST : ${PUBLIC_HOST} - SERVICE_USER : ${SERVICE_USER} - + PUBLIC_URL : ${PUBLIC_URL} + PUBLIC_HOST : ${PUBLIC_HOST} + SERVICE_USER : ${SERVICE_USER} + FILTRON_API : ${FILTRON_API} + FILTRON_LISTEN : ${FILTRON_LISTEN} + FILTRON_TARGET : ${FILTRON_TARGET} EOF [ ! -z ${1+x} ] && echo -e "$1" } @@ -305,7 +308,7 @@ EOF err_msg "Filtron does not listening on: http://${FILTRON_LISTEN}" fi - if service_is_available ""http://${FILTRON_TARGET}"" ; then + if service_is_available "http://${FILTRON_TARGET}" ; then info_msg "Filtron's target is available at: http://${FILTRON_TARGET}" fi -- 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/filtron.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'utils/filtron.sh') diff --git a/utils/filtron.sh b/utils/filtron.sh index 3c545ff14..c1e360067 100755 --- a/utils/filtron.sh +++ b/utils/filtron.sh @@ -94,8 +94,9 @@ If needed, set PUBLIC_URL of your WEB service in the '${DOT_CONFIG#"$REPO_ROOT/" FILTRON_API : ${FILTRON_API} FILTRON_LISTEN : ${FILTRON_LISTEN} FILTRON_TARGET : ${FILTRON_TARGET} + EOF - [ ! -z ${1+x} ] && echo -e "$1" + [ ! -z ${1+x} ] && err_msg "$1" } main() { @@ -105,7 +106,7 @@ main() { dpkg 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) ;; @@ -170,7 +171,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/filtron.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'utils/filtron.sh') diff --git a/utils/filtron.sh b/utils/filtron.sh index c1e360067..e97b9f014 100755 --- a/utils/filtron.sh +++ b/utils/filtron.sh @@ -96,7 +96,7 @@ If needed, set PUBLIC_URL of your WEB service in the '${DOT_CONFIG#"$REPO_ROOT/" FILTRON_TARGET : ${FILTRON_TARGET} EOF - [ ! -z ${1+x} ] && err_msg "$1" + [ ! -z "${1+x}" ] && err_msg "$1" } main() { -- cgit v1.2.3 From 5c0f9c8c79f8eca72c206e2f9bb7c6d26bf80fa4 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sat, 8 Feb 2020 17:12:01 +0100 Subject: tooling box: varius fix from tests Signed-off-by: Markus Heiser --- utils/filtron.sh | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'utils/filtron.sh') diff --git a/utils/filtron.sh b/utils/filtron.sh index e97b9f014..1bea7a717 100755 --- a/utils/filtron.sh +++ b/utils/filtron.sh @@ -129,6 +129,11 @@ main() { case $2 in all) install_all ;; user) assert_user ;; + rules) + rst_title "Re-Install filtron rules" + echo + install_template --no-eval "$FILTRON_RULES" root root 644 + ;; *) usage "$_usage"; exit 42;; esac ;; update) -- cgit v1.2.3 From e6bf2038c38599a278ca110276c942e7e111d207 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Tue, 11 Feb 2020 15:58:35 +0100 Subject: filtron.sh: add 'install rules' command Signed-off-by: Markus Heiser --- utils/filtron.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'utils/filtron.sh') diff --git a/utils/filtron.sh b/utils/filtron.sh index 1bea7a717..df6932723 100755 --- a/utils/filtron.sh +++ b/utils/filtron.sh @@ -58,7 +58,7 @@ usage() { usage:: $(basename "$0") shell - $(basename "$0") install [all|user] + $(basename "$0") install [all|user|rules] $(basename "$0") update [filtron] $(basename "$0") remove [all] $(basename "$0") activate [service] @@ -72,6 +72,7 @@ shell install / remove :all: complete setup of filtron service :user: add/remove service user '$SERVICE_USER' ($SERVICE_HOME) + :rules: reinstall filtron rules $FILTRON_RULES update filtron Update filtron installation ($SERVICE_HOME) activate service @@ -133,6 +134,7 @@ main() { rst_title "Re-Install filtron rules" echo install_template --no-eval "$FILTRON_RULES" root root 644 + systemd_restart_service "${SERVICE_NAME}" ;; *) usage "$_usage"; exit 42;; esac ;; -- 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/filtron.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'utils/filtron.sh') diff --git a/utils/filtron.sh b/utils/filtron.sh index df6932723..2cbea4023 100755 --- a/utils/filtron.sh +++ b/utils/filtron.sh @@ -97,7 +97,7 @@ If needed, set PUBLIC_URL of your WEB service in the '${DOT_CONFIG#"$REPO_ROOT/" FILTRON_TARGET : ${FILTRON_TARGET} 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/filtron.sh | 1 - 1 file changed, 1 deletion(-) (limited to 'utils/filtron.sh') diff --git a/utils/filtron.sh b/utils/filtron.sh index 2cbea4023..13bb76751 100755 --- a/utils/filtron.sh +++ b/utils/filtron.sh @@ -322,7 +322,6 @@ EOF if ! service_is_available "${PUBLIC_URL}"; then err_msg "Public service at ${PUBLIC_URL} is not available!" - echo -e "${_Green}stop with [${_BCyan}CTRL-C${_Green}] or .." wait_key fi -- 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/filtron.sh | 2 ++ 1 file changed, 2 insertions(+) (limited to 'utils/filtron.sh') diff --git a/utils/filtron.sh b/utils/filtron.sh index 13bb76751..2d2270812 100755 --- a/utils/filtron.sh +++ b/utils/filtron.sh @@ -87,6 +87,8 @@ apache : ${PUBLIC_URL} :install: apache site with a reverse proxy (ProxyPass) :remove: apache site ${APACHE_FILTRON_SITE} +filtron rules: ${FILTRON_RULES} + If needed, set PUBLIC_URL of your WEB service in the '${DOT_CONFIG#"$REPO_ROOT/"}' file:: PUBLIC_URL : ${PUBLIC_URL} -- 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/filtron.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'utils/filtron.sh') diff --git a/utils/filtron.sh b/utils/filtron.sh index 2d2270812..ba284787e 100755 --- a/utils/filtron.sh +++ b/utils/filtron.sh @@ -106,7 +106,7 @@ main() { rst_title "$SERVICE_NAME" part required_commands \ - dpkg apt-get install git wget curl \ + sudo install git wget curl \ || exit local _usage="unknown or missing $1 command $2" @@ -231,9 +231,11 @@ assert_user() { rst_title "user $SERVICE_USER" section echo tee_stderr 1 < 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/filtron.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'utils/filtron.sh') diff --git a/utils/filtron.sh b/utils/filtron.sh index ba284787e..56b27dc78 100755 --- a/utils/filtron.sh +++ b/utils/filtron.sh @@ -204,7 +204,7 @@ install_all() { install_apache_site fi 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 @@ -253,7 +253,6 @@ grep -qFs -- 'source $GO_ENV' ~/.profile || echo 'source $GO_ENV' >> ~/.profile EOF } - filtron_is_installed() { [[ -f $SERVICE_HOME/go-apps/bin/filtron ]] } -- 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/filtron.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'utils/filtron.sh') diff --git a/utils/filtron.sh b/utils/filtron.sh index 56b27dc78..663c2b1dc 100755 --- a/utils/filtron.sh +++ b/utils/filtron.sh @@ -257,7 +257,7 @@ filtron_is_installed() { [[ -f $SERVICE_HOME/go-apps/bin/filtron ]] } -_svcpr=" |${SERVICE_USER}| " +_svcpr=" ${_Yellow}|${SERVICE_USER}|${_creset} " install_filtron() { rst_title "Install filtron in user's ~/go-apps" section -- 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/filtron.sh | 1 + 1 file changed, 1 insertion(+) (limited to 'utils/filtron.sh') diff --git a/utils/filtron.sh b/utils/filtron.sh index 663c2b1dc..c53acc607 100755 --- a/utils/filtron.sh +++ b/utils/filtron.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/filtron.sh | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'utils/filtron.sh') diff --git a/utils/filtron.sh b/utils/filtron.sh index c53acc607..89971d61d 100755 --- a/utils/filtron.sh +++ b/utils/filtron.sh @@ -180,6 +180,10 @@ main() { debug-off) echo; disable_debug ;; *) usage "$_usage"; exit 42;; esac ;; + doc) + echo + echo ".. generic utils/filtron.sh documentation" + ;; *) usage "unknown or missing command $1"; exit 42;; esac -- 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/filtron.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'utils/filtron.sh') diff --git a/utils/filtron.sh b/utils/filtron.sh index 89971d61d..537cea145 100755 --- a/utils/filtron.sh +++ b/utils/filtron.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 -- 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/filtron.sh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'utils/filtron.sh') diff --git a/utils/filtron.sh b/utils/filtron.sh index 537cea145..85000c592 100755 --- a/utils/filtron.sh +++ b/utils/filtron.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 @@ -329,16 +330,25 @@ EOF fi if ! service_is_available "${PUBLIC_URL}"; then - err_msg "Public service at ${PUBLIC_URL} is not available!" - wait_key + warn_msg "Public service at ${PUBLIC_URL} is not available!" + if ! in_container; then + warn_msg "Check if public name is correct and routed or use the public IP from above." + fi fi + if in_container; then + lxc_suite_info + else + info_msg "public URL --> ${PUBLIC_URL}" + info_msg "internal URL --> http://${FILTRON_LISTEN}" + fi + + local _debug_on if ask_yn "Enable filtron debug mode?"; then enable_debug _debug_on=1 fi - echo systemctl --no-pager -l status "${SERVICE_NAME}" echo @@ -346,7 +356,7 @@ EOF info_msg "public URL --> ${PUBLIC_URL}" # 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 -- 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/filtron.sh | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'utils/filtron.sh') diff --git a/utils/filtron.sh b/utils/filtron.sh index 85000c592..c81a252a5 100755 --- a/utils/filtron.sh +++ b/utils/filtron.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,9 @@ in_container && lxc_set_suite_env # config # ---------------------------------------------------------------------------- +PUBLIC_URL="${PUBLIC_URL:-http://$(uname -n)/searx}" +PUBLIC_HOST="${PUBLIC_HOST:-$(echo "$PUBLIC_URL" | sed -e 's/[^/]*\/\/\([^@]*@\)\?\([^:/]*\).*/\2/')}" + FILTRON_URL_PATH="${FILTRON_URL_PATH:-$(echo "${PUBLIC_URL}" \ | sed -e 's,^.*://[^/]*\(/.*\),\1,g')}" [[ "${FILTRON_URL_PATH}" == "${PUBLIC_URL}" ]] && FILTRON_URL_PATH=/ -- 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/filtron.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'utils/filtron.sh') diff --git a/utils/filtron.sh b/utils/filtron.sh index c81a252a5..208166fda 100755 --- a/utils/filtron.sh +++ b/utils/filtron.sh @@ -90,7 +90,7 @@ inspect service show service status and log option set one of the available options -apache : ${PUBLIC_URL} +apache (${PUBLIC_URL}) :install: apache site with a reverse proxy (ProxyPass) :remove: apache site ${APACHE_FILTRON_SITE} -- 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/filtron.sh | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'utils/filtron.sh') diff --git a/utils/filtron.sh b/utils/filtron.sh index 208166fda..d2be60737 100755 --- a/utils/filtron.sh +++ b/utils/filtron.sh @@ -186,11 +186,7 @@ main() { debug-off) echo; disable_debug ;; *) usage "$_usage"; exit 42;; esac ;; - doc) - echo - echo ".. generic utils/filtron.sh documentation" - ;; - + doc) rst-doc ;; *) usage "unknown or missing command $1"; exit 42;; esac } @@ -469,6 +465,32 @@ This removes apache site ${APACHE_FILTRON_SITE}." apache_remove_site "$APACHE_FILTRON_SITE" } +rst-doc() { + + eval "echo \"$(< "${REPO_ROOT}/docs/build-templates/filtron.rst")\"" + + echo -e "\n.. START install systemd unit" + 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/filtron.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'utils/filtron.sh') diff --git a/utils/filtron.sh b/utils/filtron.sh index d2be60737..6c58b07a2 100755 --- a/utils/filtron.sh +++ b/utils/filtron.sh @@ -97,15 +97,24 @@ apache (${PUBLIC_URL}) filtron rules: ${FILTRON_RULES} If needed, set PUBLIC_URL of your WEB service in the '${DOT_CONFIG#"$REPO_ROOT/"}' file:: - PUBLIC_URL : ${PUBLIC_URL} PUBLIC_HOST : ${PUBLIC_HOST} SERVICE_USER : ${SERVICE_USER} + FILTRON_TARGET : ${FILTRON_TARGET} FILTRON_API : ${FILTRON_API} FILTRON_LISTEN : ${FILTRON_LISTEN} - FILTRON_TARGET : ${FILTRON_TARGET} - EOF + if in_container; then + # in containers the service is listening on 0.0.0.0 (see lxc-searx.env) + for ip in $(global_IPs) ; do + if [[ $ip =~ .*:.* ]]; then + echo " container URL (IPv6): http://[${ip#*|}]:4005/" + else + # IPv4: + echo " container URL (IPv4): http://${ip#*|}:4005/" + fi + done + fi [[ -n ${1} ]] && err_msg "$1" } -- 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/filtron.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'utils/filtron.sh') diff --git a/utils/filtron.sh b/utils/filtron.sh index 6c58b07a2..0fbf74787 100755 --- a/utils/filtron.sh +++ b/utils/filtron.sh @@ -441,14 +441,12 @@ This installs a reverse proxy (ProxyPass) into apache site (${APACHE_FILTRON_SIT ! 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 + else + install_apache fi - a2enmod headers - a2enmod proxy - a2enmod proxy_http - echo apache_install_site --variant=filtron "${APACHE_FILTRON_SITE}" -- 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/filtron.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'utils/filtron.sh') diff --git a/utils/filtron.sh b/utils/filtron.sh index 0fbf74787..d24b6c39e 100755 --- a/utils/filtron.sh +++ b/utils/filtron.sh @@ -23,7 +23,6 @@ FILTRON_URL_PATH="${FILTRON_URL_PATH:-$(echo "${PUBLIC_URL}" \ [[ "${FILTRON_URL_PATH}" == "${PUBLIC_URL}" ]] && FILTRON_URL_PATH=/ FILTRON_ETC="/etc/filtron" - FILTRON_RULES="$FILTRON_ETC/rules.json" FILTRON_API="${FILTRON_API:-127.0.0.1:4005}" @@ -447,7 +446,8 @@ This installs a reverse proxy (ProxyPass) into apache site (${APACHE_FILTRON_SIT install_apache fi - echo + "${REPO_ROOT}/utils/searx.sh" install uwsgi + apache_install_site --variant=filtron "${APACHE_FILTRON_SITE}" info_msg "testing public url .." @@ -465,11 +465,12 @@ This removes apache site ${APACHE_FILTRON_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_FILTRON_SITE" + } rst-doc() { -- 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/filtron.sh | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 59 insertions(+), 7 deletions(-) (limited to 'utils/filtron.sh') diff --git a/utils/filtron.sh b/utils/filtron.sh index d24b6c39e..c82c2d0a3 100755 --- a/utils/filtron.sh +++ b/utils/filtron.sh @@ -44,9 +44,8 @@ GO_ENV="${SERVICE_HOME}/.go_env" GO_PKG_URL="https://dl.google.com/go/go1.13.5.linux-amd64.tar.gz" GO_TAR=$(basename "$GO_PKG_URL") -# Apache Settings - APACHE_FILTRON_SITE="searx.conf" +NGINX_FILTRON_SITE="searx.conf" # shellcheck disable=SC2034 CONFIG_FILES=( @@ -60,9 +59,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/filtron.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'utils/filtron.sh') diff --git a/utils/filtron.sh b/utils/filtron.sh index c82c2d0a3..8986fb0ef 100755 --- a/utils/filtron.sh +++ b/utils/filtron.sh @@ -225,6 +225,11 @@ install_all() { if ask_yn "Do you want to install a reverse proxy (ProxyPass)" Yn; then install_apache_site fi + elif nginx_is_installed; then + info_msg "nginx is installed on this host." + if ask_yn "Do you want to install a reverse proxy (ProxyPass)" Yn; then + install_nginx_site + fi fi if ask_yn "Do you want to inspect the installation?" Ny; then inspect_service @@ -315,8 +320,6 @@ sourced ${DOT_CONFIG#"$REPO_ROOT/"} : EOF - apache_is_installed && info_msg "Apache is installed." - if service_account_is_available "$SERVICE_USER"; then info_msg "service account $SERVICE_USER available." else @@ -445,7 +448,7 @@ install_apache_site() { rst_para "\ This installs a reverse proxy (ProxyPass) into apache site (${APACHE_FILTRON_SITE})" - ! apache_is_installed && err_msg "Apache is not installed." + ! apache_is_installed && info_msg "Apache is not installed." if ! ask_yn "Do you really want to continue?" Yn; then return @@ -487,7 +490,7 @@ install_nginx_site() { rst_para "\ This installs a reverse proxy (ProxyPass) into nginx site (${NGINX_FILTRON_SITE})" - ! nginx_is_installed && err_msg "nginx is not installed." + ! nginx_is_installed && info_msg "nginx is not installed." if ! ask_yn "Do you really want to continue?" Yn; then return @@ -497,7 +500,9 @@ This installs a reverse proxy (ProxyPass) into nginx site (${NGINX_FILTRON_SITE} "${REPO_ROOT}/utils/searx.sh" install uwsgi + # shellcheck disable=SC2034 SEARX_SRC=$("${REPO_ROOT}/utils/searx.sh" --getenv SEARX_SRC) + # shellcheck disable=SC2034 SEARX_URL_PATH=$("${REPO_ROOT}/utils/searx.sh" --getenv SEARX_URL_PATH) nginx_install_app --variant=filtron "${NGINX_FILTRON_SITE}" -- cgit v1.2.3