Merge branch 'filtron' of https://github.com/return42/searx into filtron

This commit is contained in:
Markus Heiser 2020-01-13 18:39:46 +01:00
commit c2b27d9120
3 changed files with 44 additions and 15 deletions

View file

@ -17,6 +17,13 @@ filtron & go
.. _Go: https://golang.org/ .. _Go: https://golang.org/
.. _filtron README: https://github.com/asciimoo/filtron/blob/master/README.md .. _filtron README: https://github.com/asciimoo/filtron/blob/master/README.md
.. sidebar:: init system
ATM the ``filtron.sh`` supports only systemd init process used by debian,
ubuntu and many other dists. If you have a working init.d file to start/stop
filtron service, please contribute.
Filtron needs Go_ installed. If Go_ is preinstalled, filtron_ is simply Filtron needs Go_ installed. If Go_ is preinstalled, filtron_ is simply
installed by ``go get`` package management (see `filtron README`_). If you use installed by ``go get`` package management (see `filtron README`_). If you use
filtron as middleware, a more isolated setup is recommended. filtron as middleware, a more isolated setup is recommended.

View file

@ -12,8 +12,12 @@ source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
FILTRON_ETC="/etc/filtron" FILTRON_ETC="/etc/filtron"
FILTRON_RULES="$FILTRON_ETC/rules.json" FILTRON_RULES="$FILTRON_ETC/rules.json"
# shellcheck disable=SC2034
FILTRON_API="127.0.0.1:4005" FILTRON_API="127.0.0.1:4005"
# shellcheck disable=SC2034
FILTRON_LISTEN="127.0.0.1:4004" FILTRON_LISTEN="127.0.0.1:4004"
# shellcheck disable=SC2034
FILTRON_TARGET="127.0.0.1:8888" FILTRON_TARGET="127.0.0.1:8888"
SERVICE_NAME="filtron" 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_PKG_URL="https://dl.google.com/go/go1.13.5.linux-amd64.tar.gz"
GO_TAR=$(basename "$GO_PKG_URL") GO_TAR=$(basename "$GO_PKG_URL")
# shellcheck disable=SC2034
CONFIG_FILES=( CONFIG_FILES=(
"${FILTRON_RULES}" "${FILTRON_RULES}"
"${SERVICE_SYSTEMD_UNIT}" "${SERVICE_SYSTEMD_UNIT}"
@ -44,6 +49,7 @@ usage:
$(basename "$0") shell $(basename "$0") shell
$(basename "$0") install [all|user] $(basename "$0") install [all|user]
$(basename "$0") update [filtron]
$(basename "$0") remove [all] $(basename "$0") remove [all]
$(basename "$0") activate [service] $(basename "$0") activate [service]
$(basename "$0") deactivate [service] $(basename "$0") deactivate [service]
@ -53,6 +59,8 @@ shell
start interactive shell from user ${SERVICE_USER} start interactive shell from user ${SERVICE_USER}
install / remove all install / remove all
complete setup of filtron service complete setup of filtron service
update filtron
Update filtron installation of user ${SERVICE_USER}
activate activate
activate and start service daemon (systemd unit) activate and start service daemon (systemd unit)
deactivate service deactivate service
@ -93,6 +101,12 @@ main(){
user) assert_user ;; user) assert_user ;;
*) usage "$_usage"; exit 42;; *) usage "$_usage"; exit 42;;
esac ;; esac ;;
update)
sudo_or_exit
case $2 in
filtron) update_filtron ;;
*) usage "$_usage"; exit 42;;
esac ;;
remove) remove)
sudo_or_exit sudo_or_exit
case $2 in case $2 in
@ -242,12 +256,20 @@ EOF
install_template --no-eval "$FILTRON_RULES" root root 644 install_template --no-eval "$FILTRON_RULES" root root 644
} }
update_filtron() {
rst_title "Update filtron" section
echo
tee_stderr <<EOF | sudo -i -u "$SERVICE_USER" 2>&1 | prefix_stdout "$_service_prefix"
go get -v -u github.com/asciimoo/filtron
EOF
}
show_service () { show_service () {
rst_title "service status & log" rst_title "service status & log"
echo echo
systemctl status filtron.service systemctl status filtron.service
echo 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 echo
while true; do while true; do
trap break 2 trap break 2

View file

@ -75,7 +75,7 @@ info_msg() { echo -e "INFO: $*"; }
clean_stdin() { clean_stdin() {
if [[ $(uname -s) != 'Darwin' ]]; then if [[ $(uname -s) != 'Darwin' ]]; then
while $(read -n1 -t 0.1); do : ; done while read -n1 -t 0.1; do : ; done
fi fi
} }