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