diff options
Diffstat (limited to 'utils')
| -rwxr-xr-x | utils/filtron.sh | 93 | ||||
| -rwxr-xr-x | utils/morty.sh | 88 | ||||
| -rwxr-xr-x | utils/searx.sh | 6 | ||||
| -rw-r--r-- | utils/searxng_check.py | 27 |
4 files changed, 147 insertions, 67 deletions
diff --git a/utils/filtron.sh b/utils/filtron.sh index a608f7769..eb34b2413 100755 --- a/utils/filtron.sh +++ b/utils/filtron.sh @@ -42,7 +42,8 @@ SERVICE_GROUP="${SERVICE_USER}" 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_VERSION="go1.17.2" +GO_PKG_URL="https://golang.org/dl/${GO_VERSION}.linux-amd64.tar.gz" GO_TAR=$(basename "$GO_PKG_URL") APACHE_FILTRON_SITE="searx.conf" @@ -76,6 +77,7 @@ shell start interactive shell from user ${SERVICE_USER} install / remove :all: complete setup of filtron service + :check: check the filtron installation :user: add/remove service user '$SERVICE_USER' ($SERVICE_HOME) :rules: reinstall filtron rules $FILTRON_RULES update filtron @@ -135,6 +137,10 @@ main() { rst_title "$SERVICE_NAME" part sudo_or_exit case $2 in + check) + rst_title "Check filtron installation" part + install_check + ;; all) install_all ;; user) assert_user ;; rules) @@ -226,6 +232,56 @@ install_all() { } +install_check() { + + 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 "$SERVICE_USER"; 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 ! service_is_available "http://${FILTRON_API}"; then + err_msg "API not available at: http://${FILTRON_API}" + fi + + if ! service_is_available "http://${FILTRON_LISTEN}" ; then + err_msg "Filtron is not listening on: http://${FILTRON_LISTEN}" + fi + + 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 + 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 [[ "${GO_VERSION}" > "$(go_version)" ]]; then + warn_msg "golang ($(go_version)) needs to be $GO_VERSION at least" + else + info_msg "golang $(go_version) is installed (min needed is: $GO_VERSION)" + fi +} + +go_version(){ + sudo -i -u "$SERVICE_USER" <<EOF +go version | cut -d' ' -f 3 +EOF +} + remove_all() { rst_title "De-Install $SERVICE_NAME (service)" @@ -354,40 +410,7 @@ sourced ${DOT_CONFIG} : EOF install_log_searx_instance - 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 "$SERVICE_USER"; 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 ! service_is_available "http://${FILTRON_API}"; then - err_msg "API not available at: http://${FILTRON_API}" - fi - - if ! service_is_available "http://${FILTRON_LISTEN}" ; then - err_msg "Filtron is not listening on: http://${FILTRON_LISTEN}" - fi - - 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 - 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 + install_check if in_container; then lxc_suite_info diff --git a/utils/morty.sh b/utils/morty.sh index 0c5401eeb..60220df02 100755 --- a/utils/morty.sh +++ b/utils/morty.sh @@ -28,7 +28,8 @@ SERVICE_GROUP="${SERVICE_USER}" SERVICE_ENV_DEBUG=false GO_ENV="${SERVICE_HOME}/.go_env" -GO_PKG_URL="https://dl.google.com/go/go1.13.5.linux-amd64.tar.gz" +GO_VERSION="go1.17.2" +GO_PKG_URL="https://golang.org/dl/${GO_VERSION}.linux-amd64.tar.gz" GO_TAR=$(basename "$GO_PKG_URL") # shellcheck disable=SC2034 @@ -47,7 +48,7 @@ usage() { cat <<EOF usage:: $(basename "$0") shell - $(basename "$0") install [all|user] + $(basename "$0") install [all|check|user] $(basename "$0") update [morty] $(basename "$0") remove [all] $(basename "$0") activate [service] @@ -61,8 +62,10 @@ usage:: shell start interactive shell from user ${SERVICE_USER} install / remove - all: complete setup of morty service - user: add/remove service user '$SERVICE_USER' ($SERVICE_HOME) + :all: complete setup of morty service + :user: add/remove service user '$SERVICE_USER' ($SERVICE_HOME) +install + :check: check the morty installation update morty Update morty installation ($SERVICE_HOME) activate service @@ -147,6 +150,10 @@ main() { sudo_or_exit case $2 in all) install_all ;; + check) + rst_title "Check morty installation" part + install_check + ;; user) assert_user ;; *) usage "$_usage"; exit 42;; esac ;; @@ -246,6 +253,50 @@ install_all() { } +install_check() { + + 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 "$SERVICE_USER"; then + info_msg "~$SERVICE_USER: go is installed" + else + err_msg "~$SERVICE_USER: go is not installed" + fi + if morty_is_installed; then + info_msg "~$SERVICE_USER: morty app is installed" + else + err_msg "~$SERVICE_USER: morty app is not installed!" + fi + + if ! service_is_available "http://${MORTY_LISTEN}" ; then + err_msg "Morty is not listening on: http://${MORTY_LISTEN}" + echo -e "${_Green}stop with [${_BCyan}CTRL-C${_Green}] or .." + wait_key + fi + + if ! service_is_available "${PUBLIC_URL_MORTY}"; then + warn_msg "Public service at ${PUBLIC_URL_MORTY} 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 [[ "${GO_VERSION}" > "$(go_version)" ]]; then + warn_msg "golang ($(go_version)) needs to be $GO_VERSION at least" + else + info_msg "golang $(go_version) is installed (min needed is: $GO_VERSION)" + fi +} + +go_version(){ + sudo -i -u "$SERVICE_USER" <<EOF +go version | cut -d' ' -f 3 +EOF +} + remove_all() { rst_title "De-Install $SERVICE_NAME (service)" @@ -342,34 +393,7 @@ sourced ${DOT_CONFIG} : EOF install_log_searx_instance - 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 "$SERVICE_USER"; then - info_msg "~$SERVICE_USER: go is installed" - else - err_msg "~$SERVICE_USER: go is not installed" - fi - if morty_is_installed; then - info_msg "~$SERVICE_USER: morty app is installed" - else - err_msg "~$SERVICE_USER: morty app is not installed!" - fi - - if ! service_is_available "http://${MORTY_LISTEN}" ; then - err_msg "Morty is not listening on: http://${MORTY_LISTEN}" - echo -e "${_Green}stop with [${_BCyan}CTRL-C${_Green}] or .." - wait_key - fi - - if ! service_is_available "${PUBLIC_URL_MORTY}"; then - warn_msg "Public service at ${PUBLIC_URL_MORTY} 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 + install_check if in_container; then lxc_suite_info diff --git a/utils/searx.sh b/utils/searx.sh index 178a185b6..e3393835c 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -154,6 +154,7 @@ shell start interactive shell from user ${SERVICE_USER} install / remove :all: complete (de-) installation of searx service + :check: check the SearXNG installation :user: add/remove service user '$SERVICE_USER' ($SERVICE_HOME) :dot-config: copy ./config.sh to ${SEARX_SRC} :searx-src: clone $GIT_URL @@ -215,6 +216,11 @@ main() { install) sudo_or_exit case $2 in + check) + rst_title "SearXNG (check installation)" part + verify_continue_install + sudo -H -u "${SERVICE_USER}" "${SEARX_PYENV}/bin/python" "utils/searxng_check.py" + ;; all) rst_title "SearXNG (install)" part install_all diff --git a/utils/searxng_check.py b/utils/searxng_check.py new file mode 100644 index 000000000..afd0c4056 --- /dev/null +++ b/utils/searxng_check.py @@ -0,0 +1,27 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +# lint: pylint +"""Implement some checks in the active installation +""" + +import os +import sys +import logging +import warnings + +LOG_FORMAT_DEBUG = '%(levelname)-7s %(name)-30.30s: %(message)s' +logging.basicConfig(level=logging.getLevelName('DEBUG'), format=LOG_FORMAT_DEBUG) +os.environ['SEARXNG_DEBUG'] = '1' + +# from here on implement the checks of the installation + +import searx + +OLD_SETTING = '/etc/searx/settings.yml' + +if os.path.isfile(OLD_SETTING): + msg = ( + '%s is no longer valid, move setting to %s' % ( + OLD_SETTING, + os.environ.get('SEARXNG_SETTINGS_PATH', '/etc/searxng/settings.yml') + )) + warnings.warn(msg, DeprecationWarning) |