mirror of
https://github.com/searxng/searxng.git
synced 2025-08-02 18:12:21 +02:00
utils/morty.sh: add script to install morty result proxy
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
parent
709ac51d33
commit
a4437c47ac
7 changed files with 506 additions and 49 deletions
|
@ -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 <<EOF
|
||||
|
||||
usage:
|
||||
usage::
|
||||
|
||||
$(basename "$0") shell
|
||||
$(basename "$0") install [all|user]
|
||||
|
@ -64,12 +66,11 @@ usage:
|
|||
$(basename "$0") option [debug-on|debug-off]
|
||||
$(basename "$0") apache [install|remove]
|
||||
|
||||
|
||||
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
|
||||
: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 service
|
||||
|
@ -80,12 +81,11 @@ 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}
|
||||
apache : ${PUBLIC_URL}
|
||||
: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:
|
||||
If needed, set PUBLIC_URL of your WEB service in the '${DOT_CONFIG#"$REPO_ROOT/"}' file::
|
||||
|
||||
PUBLIC_URL : ${PUBLIC_URL}
|
||||
PUBLIC_HOST : ${PUBLIC_HOST}
|
||||
|
@ -203,8 +203,9 @@ remove_all() {
|
|||
It goes without saying that this script can only be used to remove
|
||||
installations that were installed with this script."
|
||||
|
||||
systemd_remove_service "${SERVICE_NAME}" "${SERVICE_SYSTEMD_UNIT}"
|
||||
wait_key
|
||||
if ! systemd_remove_service "${SERVICE_NAME}" "${SERVICE_SYSTEMD_UNIT}"; then
|
||||
return 42
|
||||
fi
|
||||
drop_service_account "${SERVICE_USER}"
|
||||
rm -r "$FILTRON_ETC" 2>&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 <<EOF | sudo -i -u $SERVICE_USER
|
||||
tee_stderr <<EOF | sudo -i -u "$SERVICE_USER"
|
||||
grep -qFs -- 'source $GO_ENV' ~/.profile || echo 'source $GO_ENV' >> ~/.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 <<EOF | sudo -i -u "$SERVICE_USER" 2>&1 | prefix_stdout "$_service_prefix"
|
||||
tee_stderr <<EOF | sudo -i -u "$SERVICE_USER" 2>&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 <<EOF | sudo -i -u "$SERVICE_USER" 2>&1 | prefix_stdout "$_service_prefix"
|
||||
tee_stderr <<EOF | sudo -i -u "$SERVICE_USER" 2>&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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue