SearXNG is a free internet metasearch engine which aggregates results from various search services and databases. Users are neither tracked nor profiled.
Python bingbravedegoogleduckduckgogooglemetasearchprivacypythonqwantsearchsearch-enginesearxsearxngstartpageyahoo
utils & Makefile: add .config.mk & .config.sh for searx brands
Markus Heiser79e1f837ef7e
diff --git a/.config.mk b/.config.mknew file mode 100644index 000000000..3349a7602--- /dev/null+++ b/.config.mk@@ -0,0 +1,13 @@+# -*- coding: utf-8; mode: makefile-gmake -*-+# SPDX-License-Identifier: AGPL-3.0-or-later+#+# This environment is used by Makefile targets. If you not maintain your own+# searx brand, you normally not need to change the defaults (except SEARX_URL).+# Compare your settings here with file .config.sh used by the toolboxing in+# utils.++export SEARX_URL=https://searx.me++export GIT_URL=https://github.com/asciimoo/searx+export DOCS_URL=https://asciimoo.github.io/searx+diff --git a/.config.sh b/.config.shnew file mode 100644index 000000000..346cb9018--- /dev/null+++ b/.config.sh@@ -0,0 +1,54 @@+# -*- coding: utf-8; mode: sh -*-+# SPDX-License-Identifier: AGPL-3.0-or-later+# shellcheck shell=bash+#+# This environment is used by ./utils scripts like filtron.sh or searx.sh. The+# default values are *most flexible* and *best maintained*, you normally not+# need to change the defaults (except PUBLIC_URL).+#+# Before you change any value here you have to uninstall any previous+# installation. Further is it recommended to backup your changes simply by+# adding them to you local brand (git branch)::+#+# git add .config+#+# Compare your settings here with file .config.mk used by the Makefile targets.++# The public URL of the searx instance: PUBLIC_URL="https://mydomain.xy/searx"+PUBLIC_URL="${PUBLIC_URL:-http://$(uname -n)/searx}"+PUBLIC_HOST="${PUBLIC_HOST:-$(echo "$PUBLIC_URL" | sed -e 's/[^/]*\/\/\([^@]*@\)\?\([^:/]*\).*/\2/')}"++# searx.sh+# ---------++SEARX_INTERNAL_URL="${SEARX_INTERNAL_URL:-127.0.0.1:8888}"++# Only change, if you maintain a searx brand in your searx fork+SEARX_DOCS_URL="${SEARX_DOCS_URL:-https://asciimoo.github.io/searx}"+SEARX_GIT_URL="${SEARX_GIT_URL:-https://github.com/asciimoo/searx.git}"+SEARX_GIT_BRANCH="${SEARX_GIT_BRANCH:-master}"++# filtron.sh+# ----------++FILTRON_API="${FILTRON_API:-127.0.0.1:4005}"+FILTRON_LISTEN="${FILTRON_LISTEN:-127.0.0.1:4004}"+FILTRON_TARGET="${FILTRON_TARGET:-127.0.0.1:8888}"++# morty.sh+# --------++# morty listen address+MORTY_LISTEN="${MORTY_LISTEN:-127.0.0.1:3000}"++# system services+# ---------------++# **experimental**: Set SERVICE_USER to run all services by one account, but be+# aware that removing discrete components might conflict!+#+# SERVICE_USER=searx++# Common $HOME folder of the service accounts+SERVICE_HOME_BASE="${SERVICE_HOME_BASE:-/usr/local}"+diff --git a/.gitignore b/.gitignoreindex 42b76ca9e..3c998afae 100644--- a/.gitignore+++ b/.gitignore@@ -25,4 +25,3 @@ dist/local/gh-pages/searx.egg-info/-.configdiff --git a/Makefile b/Makefileindex 6577b374e..500910d8e 100644--- a/Makefile+++ b/Makefile@@ -1,8 +1,6 @@# -*- coding: utf-8; mode: makefile-gmake -*--export GIT_URL=https://github.com/asciimoo/searx-export SEARX_URL=https://searx.me-export DOCS_URL=https://asciimoo.github.io/searx+include ./.config.mkPYOBJECTS = searxDOC = docs@@ -80,6 +78,8 @@ test.sh:shellcheck -x utils/lib.shshellcheck -x utils/filtron.shshellcheck -x utils/searx.sh+ shellcheck -x utils/morty.sh+ shellcheck -x .config.shtest.pep8: pyenvinstall$(PY_ENV_ACT); ./manage.sh pep8_checkdiff --git a/utils/dot_config b/utils/dot_configdeleted file mode 100644index 1ddfa868c..000000000--- a/utils/dot_config+++ /dev/null@@ -1,17 +0,0 @@-# -*- coding: utf-8; mode: sh -*--# SPDX-License-Identifier: AGPL-3.0-or-later-#-# This environment is used by ./utils scripts like filtron.sh or searx.sh. The-# default values are *most flexible* and *best maintained*, you normally not-# need to change them. Before you change any value here you have to uninstall-# any previous installation. It is recommended to backup your changes simply by-# adding them to you local brand (git branch).--# The public URL of the searx instance-PUBLIC_URL="${PUBLIC_URL:-http://$(uname -n)/searx}"-PUBLIC_HOST="${PUBLIC_HOST:-$(echo "$PUBLIC_URL" | sed -e 's/[^/]*\/\/\([^@]*@\)\?\([^:/]*\).*/\2/')}"--# Run all services by one account, but be aware that removing discrete-# components might conflict! **experimental**-#-# SERVICE_USER=service_account42diff --git a/utils/filtron.sh b/utils/filtron.shindex 2a68f1728..3c545ff14 100755--- a/utils/filtron.sh+++ b/utils/filtron.sh@@ -19,13 +19,14 @@ FILTRON_ETC="/etc/filtron"FILTRON_RULES="$FILTRON_ETC/rules.json"-FILTRON_API="127.0.0.1:4005"-FILTRON_LISTEN="127.0.0.1:4004"-FILTRON_TARGET="127.0.0.1:8888"+FILTRON_API="${FILTRON_API:-127.0.0.1:4005}"+FILTRON_LISTEN="${FILTRON_LISTEN:-127.0.0.1:4004}"+FILTRON_TARGET="${FILTRON_TARGET:-127.0.0.1:8888}"SERVICE_NAME="filtron"SERVICE_USER="${SERVICE_USER:-${SERVICE_NAME}}"-SERVICE_HOME="/home/${SERVICE_USER}"+SERVICE_HOME_BASE="${SERVICE_HOME_BASE:-/usr/local}"+SERVICE_HOME="${SERVICE_HOME_BASE}/${SERVICE_USER}"SERVICE_SYSTEMD_UNIT="${SYSTEMD_UNITS}/${SERVICE_NAME}.service"# shellcheck disable=SC2034SERVICE_GROUP="${SERVICE_USER}"@@ -70,9 +71,9 @@ shellstart interactive shell from user ${SERVICE_USER}install / remove:all: complete setup of filtron service- :user: add/remove service user '$SERVICE_USER' at $SERVICE_HOME+ :user: add/remove service user '$SERVICE_USER' ($SERVICE_HOME)update filtron- Update filtron installation of user ${SERVICE_USER}+ Update filtron installation ($SERVICE_HOME)activate serviceactivate and start service daemon (systemd unit)deactivate service@@ -87,10 +88,12 @@ apache : ${PUBLIC_URL}If needed, set PUBLIC_URL of your WEB service in the '${DOT_CONFIG#"$REPO_ROOT/"}' file::- PUBLIC_URL : ${PUBLIC_URL}- PUBLIC_HOST : ${PUBLIC_HOST}- SERVICE_USER : ${SERVICE_USER}-+ PUBLIC_URL : ${PUBLIC_URL}+ PUBLIC_HOST : ${PUBLIC_HOST}+ SERVICE_USER : ${SERVICE_USER}+ FILTRON_API : ${FILTRON_API}+ FILTRON_LISTEN : ${FILTRON_LISTEN}+ FILTRON_TARGET : ${FILTRON_TARGET}EOF[ ! -z ${1+x} ] && echo -e "$1"}@@ -305,7 +308,7 @@ EOFerr_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}" ; theninfo_msg "Filtron's target is available at: http://${FILTRON_TARGET}"fidiff --git a/utils/lib.sh b/utils/lib.shindex 78641cc0b..05ff5e594 100755--- a/utils/lib.sh+++ b/utils/lib.sh@@ -32,18 +32,15 @@ if [[ -z ${DIFF_CMD} ]]; thenfifi-DOT_CONFIG="${DOT_CONFIG:-${REPO_ROOT}/.config}"+DOT_CONFIG="${DOT_CONFIG:-${REPO_ROOT}/.config.sh}"source_dot_config() {- if [[ ! -e "$DOT_CONFIG" ]]; then- info_msg "installing $DOT_CONFIG"- cp "$(dirname "${BASH_SOURCE[0]}")/dot_config" "$DOT_CONFIG"- if [[ ! -z ${SUDO_USER} ]]; then- chown "${SUDO_USER}:${SUDO_USER}" "$DOT_CONFIG"- fi+ if [[ ! -e "${DOT_CONFIG}" ]]; then+ err_msg "configuration does not extsts at: ${DOT_CONFIG}"+ return 42fi# shellcheck disable=SC1090- source "${REPO_ROOT}/.config"+ source "${DOT_CONFIG}"}sudo_or_exit() {diff --git a/utils/morty.sh b/utils/morty.shindex be741c2a4..ba4e7dd2e 100755--- a/utils/morty.sh+++ b/utils/morty.sh@@ -11,17 +11,20 @@ source_dot_config# ----------------------------------------------------------------------------PUBLIC_URL_PATH_MORTY="/morty"-PUBLIC_URL_MORTY="$(dirname ${PUBLIC_URL})${PUBLIC_URL_PATH_MORTY}"+PUBLIC_URL_MORTY="$(dirname "${PUBLIC_URL}")${PUBLIC_URL_PATH_MORTY}"MORTY_LISTEN="${MORTY_LISTEN:-127.0.0.1:3000}"+# shellcheck disable=SC2034MORTY_TIMEOUT=5SERVICE_NAME="morty"SERVICE_USER="${SERVICE_USER:-${SERVICE_NAME}}"-SERVICE_HOME="/home/${SERVICE_USER}"+SERVICE_HOME_BASE="${SERVICE_HOME_BASE:-/usr/local}"+SERVICE_HOME="${SERVICE_HOME_BASE}/${SERVICE_USER}"SERVICE_SYSTEMD_UNIT="${SYSTEMD_UNITS}/${SERVICE_NAME}.service"# shellcheck disable=SC2034SERVICE_GROUP="${SERVICE_USER}"+# shellcheck disable=SC2034SERVICE_ENV_DEBUG=falseGO_ENV="${SERVICE_HOME}/.go_env"@@ -53,14 +56,15 @@ usage::$(basename "$0") inspect [service]$(basename "$0") option [debug-on|debug-off]$(basename "$0") apache [install|remove]+ $(basename "$0") info [searx]shellstart interactive shell from user ${SERVICE_USER}install / removeall: complete setup of morty service- user: add/remove service user '$SERVICE_USER' at $SERVICE_HOME+ user: add/remove service user '$SERVICE_USER' ($SERVICE_HOME)update morty- Update morty installation of user ${SERVICE_USER}+ Update morty installation ($SERVICE_HOME)activate serviceactivate and start service daemon (systemd unit)deactivate service@@ -77,17 +81,24 @@ If needed, set the environment variable MORTY_LISTEN in the${DOT_CONFIG#"$REPO_ROOT/"} file::MORTY_LISTEN : ${MORTY_LISTEN}- SERVICE_USER : ${SERVICE_USER}+ SERVICE_USER : ${SERVICE_USER}+EOF+ info_searx+ [ ! -z ${1+x} ] && echo -e "$1"+}++info_searx() {+ # shellcheck disable=SC1117+ cat <<EOFTo activate morty in searx, add result_proxy to your settings.yml::result_proxy:url : ${PUBLIC_URL_MORTY}/-further read: https://asciimoo.github.io/searx/admin/morty.html+further read: ${DOCS_URL}/admin/morty.htmlEOF- [ ! -z ${1+x} ] && echo -e "$1"}main() {@@ -154,6 +165,11 @@ main() {remove) remove_apache_site ;;*) usage "$_usage"; exit 42;;esac ;;+ info)+ case $2 in+ searx) info_searx ;;+ *) usage "$_usage"; exit 42;;+ esac ;;option)sudo_or_exitcase $2 in@@ -176,7 +192,7 @@ install_all() {wait_keysystemd_install_service "${SERVICE_NAME}" "${SERVICE_SYSTEMD_UNIT}"wait_key- echo+ info_searxif ! service_is_available "http://${MORTY_LISTEN}" ; thenerr_msg "Morty does not listening on: http://${MORTY_LISTEN}"fi@@ -258,6 +274,7 @@ set_service_env_debug() {# usage: set_service_env_debug [false|true]+ # shellcheck disable=SC2034local SERVICE_ENV_DEBUG="${1:-false}"if systemd_remove_service "${SERVICE_NAME}" "${SERVICE_SYSTEMD_UNIT}"; thensystemd_install_service "${SERVICE_NAME}" "${SERVICE_SYSTEMD_UNIT}"@@ -308,9 +325,9 @@ EOFsystemctl --no-pager -l status "${SERVICE_NAME}"echo- # shellcheck disable=SC2059info_msg "morty URL --> http://${MORTY_LISTEN}"info_msg "public URL --> ${PUBLIC_URL_MORTY}"+ # shellcheck disable=SC2059printf "// use ${_BCyan}CTRL-C${_creset} to stop monitoring the log"read -r -s -n1 -t 2echodiff --git a/utils/searx.sh b/utils/searx.shindex ec4eaacce..2b5e92c40 100755--- a/utils/searx.sh+++ b/utils/searx.sh@@ -11,6 +11,8 @@ source_dot_config# config# ----------------------------------------------------------------------------+SEARX_INTERNAL_URL="${SEARX_INTERNAL_URL:-127.0.0.1:8888}"+SEARX_URL_PATH="${SEARX_URL_PATH:-$(echo "${PUBLIC_URL}" \| sed -e 's,^.*://[^/]*\(/.*\),\1,g')}"[[ "${SEARX_URL_PATH}" == "${PUBLIC_URL}" ]] && SEARX_URL_PATH=/@@ -19,13 +21,13 @@ SEARX_INSTANCE_NAME="${SEARX_INSTANCE_NAME:-searx@$(echo "$PUBLIC_URL" \SERVICE_NAME="searx"SERVICE_USER="${SERVICE_USER:-${SERVICE_NAME}}"-SERVICE_HOME="/home/${SERVICE_USER}"+SERVICE_HOME_BASE="${SERVICE_HOME_BASE:-/usr/local}"+SERVICE_HOME="${SERVICE_HOME_BASE}/${SERVICE_USER}"# shellcheck disable=SC2034SERVICE_GROUP="${SERVICE_USER}"-SEARX_INTERNAL_URL="127.0.0.1:8888"-SEARX_GIT_URL="https://github.com/asciimoo/searx.git"-SEARX_GIT_BRANCH="master"+SEARX_GIT_URL="${SEARX_GIT_URL:-https://github.com/asciimoo/searx.git}"+SEARX_GIT_BRANCH="${SEARX_GIT_BRANCH:-master}"SEARX_PYENV="${SERVICE_HOME}/searx-pyenv"SEARX_SRC="${SERVICE_HOME}/searx-src"SEARX_SETTINGS="${SEARX_SRC}/searx/settings.yml"@@ -82,11 +84,11 @@ shellstart interactive shell from user ${SERVICE_USER}install / remove:all: complete (de-) installation of searx service- :user: add/remove service user '$SERVICE_USER' at $SERVICE_HOME+ :user: add/remove service user '$SERVICE_USER' ($SERVICE_HOME):searx-src: clone $SEARX_GIT_URL:pyenv: create/remove virtualenv (python) in $SEARX_PYENVupdate searx- Update searx installation of user ${SERVICE_USER}+ Update searx installation ($SERVICE_HOME)activate serviceactivate and start service daemon (systemd unit)deactivate service@@ -521,9 +523,9 @@ EOFsystemctl --no-pager -l status "${SERVICE_NAME}"echo- # shellcheck disable=SC2059info_msg "public URL --> ${PUBLIC_URL}"info_msg "internal URL --> http://${SEARX_INTERNAL_URL}"+ # shellcheck disable=SC2059printf "// use ${_BCyan}CTRL-C${_creset} to stop monitoring the log"read -r -s -n1 -t 2echo