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
tooling box: added nginx + polished bash scripts and environment
Markus Heiser99ff16c465ed
diff --git a/.config.sh b/.config.shindex 835bfecf4..4eff5f4c6 100644--- a/.config.sh+++ b/.config.sh@@ -18,7 +18,8 @@PUBLIC_URL="${SEARX_URL}"if [[ ${PUBLIC_URL} == "https://searx.me" ]]; then- PUBLIC_URL=+ # hint: Linux containers do not have DNS entries, lets use IPs+ PUBLIC_URL="http://$(primary_ip)/searx"fi# searx.shdiff --git a/utils/filtron.sh b/utils/filtron.shindex c82c2d0a3..8986fb0ef 100755--- a/utils/filtron.sh+++ b/utils/filtron.sh@@ -225,6 +225,11 @@ install_all() {if ask_yn "Do you want to install a reverse proxy (ProxyPass)" Yn; theninstall_apache_sitefi+ elif nginx_is_installed; then+ info_msg "nginx is installed on this host."+ if ask_yn "Do you want to install a reverse proxy (ProxyPass)" Yn; then+ install_nginx_site+ fifiif ask_yn "Do you want to inspect the installation?" Ny; theninspect_service@@ -315,8 +320,6 @@ sourced ${DOT_CONFIG#"$REPO_ROOT/"} :EOF- apache_is_installed && info_msg "Apache is installed."-if service_account_is_available "$SERVICE_USER"; theninfo_msg "service account $SERVICE_USER available."else@@ -445,7 +448,7 @@ install_apache_site() {rst_para "\This installs a reverse proxy (ProxyPass) into apache site (${APACHE_FILTRON_SITE})"- ! apache_is_installed && err_msg "Apache is not installed."+ ! apache_is_installed && info_msg "Apache is not installed."if ! ask_yn "Do you really want to continue?" Yn; thenreturn@@ -487,7 +490,7 @@ install_nginx_site() {rst_para "\This installs a reverse proxy (ProxyPass) into nginx site (${NGINX_FILTRON_SITE})"- ! nginx_is_installed && err_msg "nginx is not installed."+ ! nginx_is_installed && info_msg "nginx is not installed."if ! ask_yn "Do you really want to continue?" Yn; thenreturn@@ -497,7 +500,9 @@ This installs a reverse proxy (ProxyPass) into nginx site (${NGINX_FILTRON_SITE}"${REPO_ROOT}/utils/searx.sh" install uwsgi+ # shellcheck disable=SC2034SEARX_SRC=$("${REPO_ROOT}/utils/searx.sh" --getenv SEARX_SRC)+ # shellcheck disable=SC2034SEARX_URL_PATH=$("${REPO_ROOT}/utils/searx.sh" --getenv SEARX_URL_PATH)nginx_install_app --variant=filtron "${NGINX_FILTRON_SITE}"diff --git a/utils/lib.sh b/utils/lib.shindex 4fc50ff39..eb55f356b 100755--- a/utils/lib.sh+++ b/utils/lib.sh@@ -482,7 +482,7 @@ service_is_available() {# usage: service_is_available <URL>[[ -z $1 ]] && die_caller 42 "missing argument <URL>"-+ local URL="$1"http_code=$(curl -H 'Cache-Control: no-cache' \--silent -o /dev/null --head --write-out '%{http_code}' --insecure \"${URL}")@@ -969,6 +969,7 @@ uWSGI_distro_setup() {# one day, see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=833067uWSGI_APPS_AVAILABLE="${uWSGI_SETUP}/apps-available"uWSGI_APPS_ENABLED="${uWSGI_SETUP}/apps-enabled"+ uWSGI_PACKAGES="uwsgi";;arch-*)# systemd --> /usr/lib/systemd/system/[email protected]@@ -977,6 +978,7 @@ uWSGI_distro_setup() {# - https://uwsgi-docs.readthedocs.io/en/latest/Systemd.html#one-service-per-app-in-systemduWSGI_APPS_AVAILABLE="${uWSGI_SETUP}/apps-archlinux"uWSGI_APPS_ENABLED="${uWSGI_SETUP}"+ uWSGI_PACKAGES="uwsgi";;fedora-*)# systemd --> /usr/lib/systemd/system/uwsgi.service@@ -984,6 +986,7 @@ uWSGI_distro_setup() {# - https://uwsgi-docs.readthedocs.io/en/latest/Emperor.htmluWSGI_APPS_AVAILABLE="${uWSGI_SETUP}/apps-available"uWSGI_APPS_ENABLED="${uWSGI_SETUP}.d"+ uWSGI_PACKAGES="uwsgi"uWSGI_USER="uwsgi"uWSGI_GROUP="uwsgi";;@@ -995,18 +998,26 @@ esacuWSGI_distro_setup+install_uwsgi(){+ info_msg "installing uwsgi ..."+ pkg_install "$uWSGI_PACKAGES"+ case $DIST_ID-$DIST_VERS in+ fedora-*)+ # enable & start should be called once at uWSGI installation time+ systemctl enable uwsgi+ systemctl restart uwsgi+ ;;+ esac+}+uWSGI_restart() {# usage: uWSGI_restart() <myapp.ini>local CONF="$1"- if [[ -z $CONF ]]; then- err_msg "uWSGI_restart: missing arguments"- return 42- fi+ [[ -z $CONF ]] && die_caller 42 "missing argument <myapp.ini>"info_msg "restart uWSGI service"-case $DIST_ID-$DIST_VERS inubuntu-*|debian-*)# the 'service' method seems broken in that way, that it (re-)starts@@ -1025,6 +1036,9 @@ uWSGI_restart() {# in emperor mode, just touch the file to restartif uWSGI_app_enabled "${CONF}"; thentouch "${uWSGI_APPS_ENABLED}/${CONF}"+ # it seems, there is a polling time in between touch and restart+ # of the service.+ sleep 3elseinfo_msg "[uWSGI:emperor] ${CONF} not installed (no need to restart)"fi@@ -1040,11 +1054,9 @@ uWSGI_prepare_app() {# usage: uWSGI_prepare_app <myapp.ini>+ [[ -z $1 ]] && die_caller 42 "missing argument <myapp.ini>"+local APP="${1%.*}"- if [[ -z $APP ]]; then- err_msg "uWSGI_prepare_app: missing arguments"- return 42- ficase $DIST_ID-$DIST_VERS infedora-*)@@ -1065,10 +1077,8 @@ uWSGI_prepare_app() {uWSGI_app_available() {# usage: uWSGI_app_available <myapp.ini>local CONF="$1"- if [[ -z $CONF ]]; then- err_msg "uWSGI_app_available: missing arguments"- return 42- fi++ [[ -z $CONF ]] && die_caller 42 "missing argument <myapp.ini>"[[ -f "${uWSGI_APPS_AVAILABLE}/${CONF}" ]]}@@ -1101,6 +1111,8 @@ uWSGI_remove_app() {# usage: uWSGI_remove_app <myapp.ini>local CONF="$1"++ [[ -z $CONF ]] && die_caller 42 "missing argument <myapp.ini>"info_msg "remove uWSGI app: ${CONF}"uWSGI_disable_app "${CONF}"uWSGI_restart "${CONF}"@@ -1110,12 +1122,10 @@ uWSGI_remove_app() {uWSGI_app_enabled() {# usage: uWSGI_app_enabled <myapp.ini>- local CONF="$1"local exit_val=0- if [[ -z $CONF ]]; then- err_msg "uWSGI_app_enabled: missing arguments"- return 42- fi+ local CONF="$1"++ [[ -z $CONF ]] && die_caller 42 "missing argument <myapp.ini>"case $DIST_ID-$DIST_VERS inubuntu-*|debian-*)[[ -f "${uWSGI_APPS_ENABLED}/${CONF}" ]]@@ -1145,11 +1155,7 @@ uWSGI_enable_app() {local CONF="$1"- if [[ -z $CONF ]]; then- err_msg "uWSGI_enable_app: missing arguments"- return 42- fi-+ [[ -z $CONF ]] && die_caller 42 "missing argument <myapp.ini>"case $DIST_ID-$DIST_VERS inubuntu-*|debian-*)mkdir -p "${uWSGI_APPS_ENABLED}"@@ -1183,11 +1189,8 @@ uWSGI_disable_app() {# usage: uWSGI_disable_app <myapp.ini>local CONF="$1"- if [[ -z $CONF ]]; then- err_msg "uWSGI_disable_app: missing arguments"- return 42- fi+ [[ -z $CONF ]] && die_caller 42 "missing argument <myapp.ini>"case $DIST_ID-$DIST_VERS inubuntu-*|debian-*)service uwsgi stop "${CONF%.*}"diff --git a/utils/lxc-searx.env b/utils/lxc-searx.envindex fc5b33f06..a51312fb8 100644--- a/utils/lxc-searx.env+++ b/utils/lxc-searx.env@@ -32,13 +32,36 @@ lxc_set_suite_env() {# rolling releases see https://www.archlinux.org/releng/releases/"$LINUXCONTAINERS_ORG_NAME:archlinux" "archlinux")- export FILTRON_API="0.0.0.0:4005"- export FILTRON_LISTEN="0.0.0.0:4004"- export MORTY_LISTEN="0.0.0.0:3000"++ PUBLIC_URL="${PUBLIC_URL:-http://$(uname -n)/searx}"+ if in_container; then+ # container hostnames do not have a DNS entry: use primary IP!+ PUBLIC_URL="http://$(primary_ip)/searx"++ # make GUEST's services public to the HOST+ FILTRON_API="0.0.0.0:4005"+ FILTRON_LISTEN="0.0.0.0:4004"+ MORTY_LISTEN="0.0.0.0:3000"++ # export LXC specific environment+ export PUBLIC_URL FILTRON_API FILTRON_LISTEN MORTY_LISTEN+ fi}-# shellcheck disable=SC2034-LXC_SUITE_INSTALL_INFO="suite includes searx, morty & filtron"+lxc_suite_install_info() {+ (+ lxc_set_suite_env+ cat <<EOF+LXC suite: ${LXC_SUITE_NAME} --> ${PUBLIC_URL}+ suite includes searx, morty & filtron+suite images:+$(echo " ${LOCAL_IMAGES[*]}" | $FMT)+suite containers:+$(echo " ${CONTAINERS[*]}" | $FMT)+EOF+ )+ }+lxc_suite_install() {(lxc_set_suite_env@@ -62,8 +85,9 @@ lxc_suite_info() {info_msg "(${ip%|*}) IPv6: http://[${ip#*|}]"else# IPv4:- info_msg "(${ip%|*}) filtron: http://${ip#*|}:4004/"- info_msg "(${ip%|*}) morty: http://${ip#*|}:3000/"+ # shellcheck disable=SC2034,SC2031+ info_msg "(${ip%|*}) filtron: http://${ip#*|}:4004/ $PUBLIC_URL"+ info_msg "(${ip%|*}) morty: http://${ip#*|}:3000/ $PUBLIC_URL_MORTY"info_msg "(${ip%|*}) docs-live: http://${ip#*|}:8080/"fidonediff --git a/utils/lxc.sh b/utils/lxc.shindex ce306fe85..a324bdaf2 100755--- a/utils/lxc.sh+++ b/utils/lxc.sh@@ -112,14 +112,7 @@ EOF}usage_containers() {- cat <<EOF-LXC suite: ${LXC_SUITE_NAME}-$(echo " ${LXC_SUITE_INSTALL_INFO}" | $FMT)-suite images:-$(echo " ${LOCAL_IMAGES[*]}" | $FMT)-suite containers:-$(echo " ${CONTAINERS[*]}" | $FMT)-EOF+ lxc_suite_install_info[ -n "${1+x}" ] && err_msg "$1"}@@ -172,7 +165,7 @@ main() {''|--|containers) remove_containers ;;images) lxc_delete_images_localy ;;${LXC_HOST_PREFIX}-*)- ! lxc_exists "$2" && usage_containers "unknown container: $2" && exit 42+ ! lxc_exists "$2" && warn_msg "container not yet exists: $2" && exit 0if ask_yn "Do you really want to delete container $2"; thenlxc_delete_container "$2"fi@@ -201,7 +194,7 @@ main() {lxc exec -t "$3" -- "${LXC_REPO_ROOT}/utils/lxc.sh" __show suite \| prefix_stdout "[${_BBlue}$3${_creset}] ";;- *|--) show_suite;;+ *) show_suite;;esac;;images) show_images ;;@@ -211,7 +204,7 @@ main() {! lxc_exists "$3" && usage_containers "unknown container: $3" && exit 42lxc config show "$3" | prefix_stdout "[${_BBlue}${3}${_creset}] ";;- *|--)+ *)rst_title "container configurations"echolxc list "$LXC_HOST_PREFIX-"@@ -226,7 +219,7 @@ main() {! lxc_exists "$3" && usage_containers "unknown container: $3" && exit 42lxc info "$3" | prefix_stdout "[${_BBlue}${3}${_creset}] ";;- *|--)+ *)rst_title "container info"echolxc_cmd info@@ -350,7 +343,9 @@ remove_containers() {echolxc list "$LXC_HOST_PREFIX-"echo -en "\\n${_BRed}LXC containers to delete::${_creset}\\n\\n ${CONTAINERS[*]}\\n" | $FMT- if ask_yn "Do you really want to delete these containers"; then+ local default=Ny+ [[ $FORCE_TIMEOUT = 0 ]] && default=Yn+ if ask_yn "Do you really want to delete these containers" $default; thenfor i in "${CONTAINERS[@]}"; dolxc_delete_container "$i"donediff --git a/utils/morty.sh b/utils/morty.shindex eae1b5bbc..851b8864d 100755--- a/utils/morty.sh+++ b/utils/morty.sh@@ -7,6 +7,7 @@ source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"# shellcheck source=utils/brand.envsource "${REPO_ROOT}/utils/brand.env"source_dot_config+SEARX_URL="${PUBLIC_URL:-http://$(uname -n)/searx}"source "${REPO_ROOT}/utils/lxc-searx.env"in_container && lxc_set_suite_env@@ -17,12 +18,7 @@ in_container && lxc_set_suite_envMORTY_LISTEN="${MORTY_LISTEN:-127.0.0.1:3000}"PUBLIC_URL_PATH_MORTY="${PUBLIC_URL_PATH_MORTY:-/morty/}"-SEARX_URL="${PUBLIC_URL:-http://$(uname -n)/searx}"-PUBLIC_URL_MORTY="$(echo "$SEARX_URL" | sed -e's,^\(.*://[^/]*\).*,\1,g')${PUBLIC_URL_PATH_MORTY}"-if in_container; then- # container hostnames do not have a DNS entry, use primary IP- PUBLIC_URL_MORTY="$(url_replace_hostname "$PUBLIC_URL_MORTY" "$(primary_ip)")"-fi+PUBLIC_URL_MORTY="${PUBLIC_URL_MORTY:-$(echo "$SEARX_URL" | sed -e's,^\(.*://[^/]*\).*,\1,g')${PUBLIC_URL_PATH_MORTY}}"# shellcheck disable=SC2034MORTY_TIMEOUT=5@@ -229,6 +225,11 @@ install_all() {if ask_yn "Do you want to install a reverse proxy (ProxyPass)" Yn; theninstall_apache_sitefi+ elif nginx_is_installed; then+ info_msg "nginx is installed on this host."+ if ask_yn "Do you want to install a reverse proxy (ProxyPass)" Yn; then+ install_nginx_site+ fifiinfo_searxif ask_yn "Add image and result proxy to searx settings.yml?" Yn; then@@ -462,7 +463,9 @@ This installs a reverse proxy (ProxyPass) into nginx site (${NGINX_MORTY_SITE})""${REPO_ROOT}/utils/searx.sh" install uwsgi+ # shellcheck disable=SC2034SEARX_SRC=$("${REPO_ROOT}/utils/searx.sh" --getenv SEARX_SRC)+ # shellcheck disable=SC2034SEARX_URL_PATH=$("${REPO_ROOT}/utils/searx.sh" --getenv SEARX_URL_PATH)nginx_install_app "${NGINX_MORTY_SITE}"diff --git a/utils/searx.sh b/utils/searx.shindex 9a73c58cc..48521f606 100755--- a/utils/searx.sh+++ b/utils/searx.sh@@ -81,6 +81,11 @@ case $DIST_ID-$DIST_VERS inBUILD_PACKAGES="${BUILD_PACKAGES_debian}"APACHE_PACKAGES="$APACHE_PACKAGES libapache2-mod-proxy-uwsgi";;+ ubuntu-20.04)+ # https://askubuntu.com/a/1224710+ SEARX_PACKAGES="${SEARX_PACKAGES_debian} python-is-python3"+ BUILD_PACKAGES="${BUILD_PACKAGES_debian}"+ ;;ubuntu-*|debian-*)SEARX_PACKAGES="${SEARX_PACKAGES_debian}"BUILD_PACKAGES="${BUILD_PACKAGES_debian}"@@ -206,7 +211,12 @@ main() {pyenv) create_pyenv ;;searx-src) clone_searx ;;settings) install_settings ;;- uwsgi) install_searx_uwsgi;;+ uwsgi)+ install_searx_uwsgi+ if ! service_is_available "http://${SEARX_INTERNAL_HTTP}"; then+ err_msg "URL http://${SEARX_INTERNAL_HTTP} not available, check searx & uwsgi setup!"+ fi+ ;;packages)pkg_install "$SEARX_PACKAGES";;@@ -272,11 +282,6 @@ install_all() {rst_title "Install $SEARX_INSTANCE_NAME (service)"pkg_install "$SEARX_PACKAGES"wait_key- case $DIST_ID-$DIST_VERS in- fedora-*)- systemctl enable uwsgi- ;;- esacassert_userwait_keyclone_searx@@ -514,6 +519,7 @@ EOFinstall_searx_uwsgi() {rst_title "Install searx's uWSGI app (searx.ini)" sectionecho+ install_uwsgiuWSGI_install_app "$SEARX_UWSGI_APP"}@@ -575,7 +581,10 @@ EOF}set_result_proxy() {- info_msg "try to set result proxy ..."++ # usage: set_result_proxy <URL> [<key>]++ info_msg "try to set result proxy: $1"cp "${SEARX_SETTINGS_PATH}" "${SEARX_SETTINGS_PATH}.bak"_set_result_proxy "$1" "$2" > "${SEARX_SETTINGS_PATH}"}