From 79b41478ac7290453b73bf00c4cdcd84e588f051 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Tue, 16 Nov 2021 18:03:34 +0100 Subject: [PATCH] [fix] filtron & morty - install golang binary that fits to arch & os Closes: https://github.com/searxng/searxng/issues/507 Signed-off-by: Markus Heiser --- docs/build-templates/filtron.rst | 9 ++++---- docs/build-templates/morty.rst | 9 ++++---- utils/filtron.sh | 26 ++++++------------------ utils/lib.sh | 35 -------------------------------- utils/morty.sh | 26 ++++++------------------ 5 files changed, 22 insertions(+), 83 deletions(-) diff --git a/docs/build-templates/filtron.rst b/docs/build-templates/filtron.rst index 79b25439..6a39d1f5 100644 --- a/docs/build-templates/filtron.rst +++ b/docs/build-templates/filtron.rst @@ -19,7 +19,8 @@ .. tabs:: - .. group-tab:: bash + .. group-tab:: os: linux / arch: amd64 + .. code-block:: bash @@ -30,9 +31,9 @@ $ sudo -i -u \"${SERVICE_USER}\" (${SERVICE_USER}) $ echo 'source $GO_ENV' >> ~/.profile (${SERVICE_USER}) $ mkdir ${SERVICE_HOME}/local - (${SERVICE_USER}) $ wget --progress=bar -O \"${GO_TAR}\" \\ - \"${GO_PKG_URL}\" - (${SERVICE_USER}) $ tar -C ${SERVICE_HOME}/local -xzf \"${GO_TAR}\" + (${SERVICE_USER}) $ wget --progress=bar -O \"${GO_VERSION}.linux-amd64.tar.gz\" \\ + \"${GO_DL_URL}/${GO_VERSION}.linux-amd64.tar.gz\" + (${SERVICE_USER}) $ tar -C ${SERVICE_HOME}/local -xzf \"${GO_VERSION}.linux-amd64.tar.gz\" (${SERVICE_USER}) $ which go ${SERVICE_HOME}/local/go/bin/go diff --git a/docs/build-templates/morty.rst b/docs/build-templates/morty.rst index 2be24da5..b03a54f9 100644 --- a/docs/build-templates/morty.rst +++ b/docs/build-templates/morty.rst @@ -19,7 +19,8 @@ .. tabs:: - .. group-tab:: bash + .. group-tab:: os: linux / arch: amd64 + .. code-block:: bash @@ -30,9 +31,9 @@ $ sudo -i -u \"${SERVICE_USER}\" (${SERVICE_USER}) $ echo 'source $GO_ENV' >> ~/.profile (${SERVICE_USER}) $ mkdir ${SERVICE_HOME}/local - (${SERVICE_USER}) $ wget --progress=bar -O \"${GO_TAR}\" \\ - \"${GO_PKG_URL}\" - (${SERVICE_USER}) $ tar -C ${SERVICE_HOME}/local -xzf \"${GO_TAR}\" + (${SERVICE_USER}) $ wget --progress=bar -O \"${GO_VERSION}.linux-amd64.tar.gz\" \\ + \"${GO_DL_URL}/${GO_VERSION}.linux-amd64.tar.gz\" + (${SERVICE_USER}) $ tar -C ${SERVICE_HOME}/local -xzf \"${GO_VERSION}.linux-amd64.tar.gz\" (${SERVICE_USER}) $ which go ${SERVICE_HOME}/local/go/bin/go diff --git a/utils/filtron.sh b/utils/filtron.sh index 4e8d6aa5..ff380a32 100755 --- a/utils/filtron.sh +++ b/utils/filtron.sh @@ -4,6 +4,8 @@ # shellcheck source=utils/lib.sh source "$(dirname "${BASH_SOURCE[0]}")/lib.sh" +# shellcheck source=utils/lib_go.sh +source "${REPO_ROOT}/utils/lib_go.sh" # shellcheck source=utils/lib_install.sh source "${REPO_ROOT}/utils/lib_install.sh" @@ -43,8 +45,6 @@ SERVICE_GROUP="${SERVICE_USER}" GO_ENV="${SERVICE_HOME}/.go_env" 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="searxng.conf" NGINX_FILTRON_SITE="searxng.conf" @@ -218,7 +218,7 @@ install_all() { rst_title "Install $SERVICE_NAME (service)" assert_user wait_key - install_go "${GO_PKG_URL}" "${GO_TAR}" "${SERVICE_USER}" + go.golang "${GO_VERSION}" "${SERVICE_USER}" wait_key install_filtron install_rules @@ -301,9 +301,7 @@ install_check() { } go_version(){ - sudo -i -u "$SERVICE_USER" < "$GO_ENV" <> ~/.profile EOF @@ -353,22 +345,16 @@ filtron_is_installed() { [[ -f $SERVICE_HOME/go-apps/bin/filtron ]] } -_svcpr=" ${_Yellow}|${SERVICE_USER}|${_creset} " - install_filtron() { rst_title "Install filtron in user's ~/go-apps" section echo - tee_stderr <&1 | prefix_stdout "$_svcpr" -go install -v github.com/asciimoo/filtron@latest -EOF + go.install github.com/asciimoo/filtron@latest "${SERVICE_USER}" } update_filtron() { rst_title "Update filtron" section echo - tee_stderr <&1 | prefix_stdout "$_svcpr" -go install -v github.com/asciimoo/filtron@latest -EOF + go.install github.com/asciimoo/filtron@latest "${SERVICE_USER}" } install_rules() { diff --git a/utils/lib.sh b/utils/lib.sh index 7f6ff58c..4472b9d3 100755 --- a/utils/lib.sh +++ b/utils/lib.sh @@ -504,7 +504,6 @@ install_template() { done } - service_is_available() { # usage: service_is_available @@ -825,40 +824,6 @@ EOF build_msg GH-PAGES "deployed" } -# golang -# ------ - -go_is_available() { - - # usage: go_is_available $SERVICE_USER && echo "go is installed!" - - sudo -i -u "${1}" which go &>/dev/null -} - -install_go() { - - # usage: install_go "${GO_PKG_URL}" "${GO_TAR}" "${SERVICE_USER}" - - local _svcpr=" ${_Yellow}|${3}|${_creset} " - - rst_title "Install Go in user's HOME" section - - rst_para "download and install go binary .." - cache_download "${1}" "${2}" - - 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 -} - # system accounts # --------------- diff --git a/utils/morty.sh b/utils/morty.sh index c04df7a0..c1f2bc96 100755 --- a/utils/morty.sh +++ b/utils/morty.sh @@ -3,6 +3,8 @@ # shellcheck source=utils/lib.sh source "$(dirname "${BASH_SOURCE[0]}")/lib.sh" +# shellcheck source=utils/lib_go.sh +source "${REPO_ROOT}/utils/lib_go.sh" # shellcheck source=utils/lib_install.sh source "${REPO_ROOT}/utils/lib_install.sh" @@ -29,8 +31,6 @@ SERVICE_ENV_DEBUG=false GO_ENV="${SERVICE_HOME}/.go_env" 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 CONFIG_FILES=() @@ -234,7 +234,7 @@ install_all() { rst_title "Install $SERVICE_NAME (service)" assert_user wait_key - install_go "${GO_PKG_URL}" "${GO_TAR}" "${SERVICE_USER}" + go.golang "${GO_VERSION}" "${SERVICE_USER}" wait_key install_morty wait_key @@ -306,9 +306,7 @@ install_check() { } go_version(){ - sudo -i -u "$SERVICE_USER" < "$GO_ENV" <> ~/.profile EOF @@ -353,22 +345,16 @@ morty_is_installed() { [[ -f $SERVICE_HOME/go-apps/bin/morty ]] } -_svcpr=" ${_Yellow}|${SERVICE_USER}|${_creset} " - install_morty() { rst_title "Install morty in user's ~/go-apps" section echo - tee_stderr <&1 | prefix_stdout "$_svcpr" -go install -v github.com/asciimoo/morty@latest -EOF + go.install github.com/asciimoo/morty@latest "${SERVICE_USER}" } update_morty() { rst_title "Update morty" section echo - tee_stderr <&1 | prefix_stdout "$_svcpr" -go install -v github.com/asciimoo/morty@latest -EOF + go.install github.com/asciimoo/morty@latest "${SERVICE_USER}" } set_service_env_debug() {