2# -*- coding: utf-8; mode: sh indent-tabs-mode: nil -*-
3# SPDX-License-Identifier: AGPL-3.0-or-later
4# shellcheck disable=SC2001
6# shellcheck source=utils/lib.sh
7source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
8# shellcheck source=utils/brand.env
9source "${REPO_ROOT}/utils/brand.env"
11source "${REPO_ROOT}/utils/lxc-searx.env"
12in_container && lxc_set_suite_env
14# ----------------------------------------------------------------------------
16# ----------------------------------------------------------------------------
18PUBLIC_URL="${PUBLIC_URL:-http://$(uname -n)/searx}"
20SEARX_INTERNAL_HTTP="${SEARX_INTERNAL_HTTP:-127.0.0.1:8888}"
22SEARX_URL_PATH="${SEARX_URL_PATH:-$(echo "${PUBLIC_URL}" \
23| sed -e 's,^.*://[^/]*\(/.*\),\1,g')}"
24[[ "${SEARX_URL_PATH}" == "${PUBLIC_URL}" ]] && SEARX_URL_PATH=/
25SEARX_INSTANCE_NAME="${SEARX_INSTANCE_NAME:-searx@$(echo "$PUBLIC_URL" \
26| sed -e 's,^.*://\([^\:/]*\).*,\1,g') }"
29SERVICE_USER="${SERVICE_USER:-${SERVICE_NAME}}"
30SERVICE_HOME_BASE="${SERVICE_HOME_BASE:-/usr/local}"
31SERVICE_HOME="${SERVICE_HOME_BASE}/${SERVICE_USER}"
32# shellcheck disable=SC2034
33SERVICE_GROUP="${SERVICE_USER}"
35GIT_BRANCH="${GIT_BRANCH:-master}"
36SEARX_PYENV="${SERVICE_HOME}/searx-pyenv"
37SEARX_SRC="${SERVICE_HOME}/searx-src"
38SEARX_SETTINGS_PATH="${SEARX_SETTINGS_PATH:-/etc/searx/settings.yml}"
39SEARX_SETTINGS_TEMPLATE="${SEARX_SETTINGS_TEMPLATE:-${REPO_ROOT}/utils/templates/etc/searx/use_default_settings.yml}"
40SEARX_UWSGI_APP="searx.ini"
41# shellcheck disable=SC2034
42SEARX_UWSGI_SOCKET="/run/uwsgi/app/searx/socket"
45SEARX_PACKAGES_debian="\
46python3-dev python3-babel python3-venv
47uwsgi uwsgi-plugin-python3
48git build-essential libxslt-dev zlib1g-dev libffi-dev libssl-dev
51BUILD_PACKAGES_debian="\
52firefox graphviz imagemagick texlive-xetex librsvg2-bin
53texlive-latex-recommended texlive-extra-utils fonts-dejavu
58python python-pip python-lxml python-babel
59uwsgi uwsgi-plugin-python
64firefox graphviz imagemagick texlive-bin extra/librsvg
65texlive-core texlive-latexextra ttf-dejavu"
68SEARX_PACKAGES_fedora="\
69python python-pip python-lxml python-babel
70uwsgi uwsgi-plugin-python3
71git @development-tools libxml2
74BUILD_PACKAGES_fedora="\
75firefox graphviz graphviz-gd ImageMagick librsvg2-tools
76texlive-xetex-bin texlive-collection-fontsrecommended
77texlive-collection-latex dejavu-sans-fonts dejavu-serif-fonts
78dejavu-sans-mono-fonts"
81SEARX_PACKAGES_centos="\
82python36 python36-pip python36-lxml python-babel
83uwsgi uwsgi-plugin-python3
84git @development-tools libxml2
87BUILD_PACKAGES_centos="\
88firefox graphviz graphviz-gd ImageMagick librsvg2-tools
89texlive-xetex-bin texlive-collection-fontsrecommended
90texlive-collection-latex dejavu-sans-fonts dejavu-serif-fonts
91dejavu-sans-mono-fonts"
93case $DIST_ID-$DIST_VERS in
94 ubuntu-16.04|ubuntu-18.04)
95 SEARX_PACKAGES="${SEARX_PACKAGES_debian}"
96 BUILD_PACKAGES="${BUILD_PACKAGES_debian}"
97 APACHE_PACKAGES="$APACHE_PACKAGES libapache2-mod-proxy-uwsgi"
100 # https://askubuntu.com/a/1224710
101 SEARX_PACKAGES="${SEARX_PACKAGES_debian} python-is-python3"
102 BUILD_PACKAGES="${BUILD_PACKAGES_debian}"
105 SEARX_PACKAGES="${SEARX_PACKAGES_debian}"
106 BUILD_PACKAGES="${BUILD_PACKAGES_debian}"
109 SEARX_PACKAGES="${SEARX_PACKAGES_arch}"
110 BUILD_PACKAGES="${BUILD_PACKAGES_arch}"
113 SEARX_PACKAGES="${SEARX_PACKAGES_fedora}"
114 BUILD_PACKAGES="${BUILD_PACKAGES_fedora}"
117 SEARX_PACKAGES="${SEARX_PACKAGES_centos}"
118 BUILD_PACKAGES="${BUILD_PACKAGES_centos}"
123APACHE_SEARX_SITE="searx.conf"
125# shellcheck disable=SC2034
127 "${uWSGI_APPS_AVAILABLE}/${SEARX_UWSGI_APP}"
130# shellcheck disable=SC2034
131CONFIG_BACKUP_ENCRYPTED=(
132 "${SEARX_SETTINGS_PATH}"
135# ----------------------------------------------------------------------------
137# ----------------------------------------------------------------------------
139 # shellcheck disable=SC1117
142 $(basename "$0") shell
143 $(basename "$0") install [all|user|searx-src|pyenv|uwsgi|packages|settings|buildhost]
144 $(basename "$0") update [searx]
145 $(basename "$0") remove [all|user|pyenv|searx-src]
146 $(basename "$0") activate [service]
147 $(basename "$0") deactivate [service]
148 $(basename "$0") inspect [service]
149 $(basename "$0") option [debug-[on|off]|image-proxy-[on|off]|result-proxy <url> <key>]
150 $(basename "$0") apache [install|remove]
153 start interactive shell from user ${SERVICE_USER}
155 :all: complete (de-) installation of searx service
156 :user: add/remove service user '$SERVICE_USER' ($SERVICE_HOME)
157 :searx-src: clone $GIT_URL
158 :pyenv: create/remove virtualenv (python) in $SEARX_PYENV
159 :uwsgi: install searx uWSGI application
160 :settings: reinstall settings from ${SEARX_SETTINGS_TEMPLATE}
161 :packages: install needed packages from OS package manager
162 :buildhost: install packages from OS package manager needed by buildhosts
164 Update searx installation ($SERVICE_HOME)
166 activate and start service daemon (systemd unit)
168 stop and deactivate service daemon (systemd unit)
170 run some small tests and inspect service's status and log
172 set one of the available options
174 :install: apache site with the searx uwsgi app
175 :remove: apache site ${APACHE_FILTRON_SITE}
177searx settings: ${SEARX_SETTINGS_PATH}
179If needed, set PUBLIC_URL of your WEB service in the '${DOT_CONFIG#"$REPO_ROOT/"}' file::
180 PUBLIC_URL : ${PUBLIC_URL}
181 SEARX_INSTANCE_NAME : ${SEARX_INSTANCE_NAME}
182 SERVICE_USER : ${SERVICE_USER}
183 SEARX_INTERNAL_HTTP : http://${SEARX_INTERNAL_HTTP}
185 if in_container; then
186 # searx is listening on 127.0.0.1 and not available from outside container
187 # in containers the service is listening on 0.0.0.0 (see lxc-searx.env)
188 echo -e "${_BBlack}HINT:${_creset} searx only listen on loopback device" \
189 "${_BBlack}inside${_creset} the container."
190 for ip in $(global_IPs) ; do
191 if [[ $ip =~ .*:.* ]]; then
192 echo " container (IPv6): [${ip#*|}]"
195 echo " container (IPv4): ${ip#*|}"
199 [[ -n ${1} ]] && err_msg "$1"
204 sudo systemctl install git wget curl \
207 local _usage="unknown or missing $1 command $2"
210 --getenv) var="$2"; echo "${!var}"; exit 0;;
211 -h|--help) usage; exit 0;;
214 interactive_shell "${SERVICE_USER}"
222 *) usage "$_usage"; exit 42;;
225 rst_title "$SEARX_INSTANCE_NAME" part
230 pyenv) create_pyenv ;;
231 searx-src) clone_searx ;;
232 settings) install_settings ;;
235 if ! service_is_available "http://${SEARX_INTERNAL_HTTP}"; then
236 err_msg "URL http://${SEARX_INTERNAL_HTTP} not available, check searx & uwsgi setup!"
240 pkg_install "$SEARX_PACKAGES"
243 pkg_install "$SEARX_PACKAGES"
244 pkg_install "$BUILD_PACKAGES"
246 *) usage "$_usage"; exit 42;;
251 searx) update_searx;;
252 *) usage "$_usage"; exit 42;;
258 user) drop_service_account "${SERVICE_USER}";;
259 pyenv) remove_pyenv ;;
260 searx-src) remove_searx ;;
261 *) usage "$_usage"; exit 42;;
268 *) usage "$_usage"; exit 42;;
273 service) deactivate_service ;;
274 *) usage "$_usage"; exit 42;;
279 debug-on) echo; enable_debug ;;
280 debug-off) echo; disable_debug ;;
281 result-proxy) set_result_proxy "$3" "$4" ;;
282 image-proxy-on) enable_image_proxy ;;
283 image-proxy-off) disable_image_proxy ;;
284 *) usage "$_usage"; exit 42;;
289 install) install_apache_site ;;
290 remove) remove_apache_site ;;
291 *) usage "$_usage"; exit 42;;
294 *) usage "unknown or missing command $1"; exit 42;;
298_service_prefix=" ${_Yellow}|$SERVICE_USER|${_creset} "
301 rst_title "Install $SEARX_INSTANCE_NAME (service)"
302 pkg_install "$SEARX_PACKAGES"
315 if ! service_is_available "http://${SEARX_INTERNAL_HTTP}"; then
316 err_msg "URL http://${SEARX_INTERNAL_HTTP} not available, check searx & uwsgi setup!"
318 if ask_yn "Do you want to inspect the installation?" Ny; then
324 rst_title "Update searx instance"
327 tee_stderr 0.3 <<EOF | sudo -H -u "${SERVICE_USER}" -i 2>&1 | prefix_stdout "$_service_prefix"
329git checkout -B "$GIT_BRANCH"
332pip install -U setuptools
338 uWSGI_restart "$SEARX_UWSGI_APP"
342 rst_title "De-Install $SEARX_INSTANCE_NAME (service)"
345It goes without saying that this script can only be used to remove
346installations that were installed with this script."
348 if ! ask_yn "Do you really want to deinstall $SEARX_INSTANCE_NAME?"; then
352 drop_service_account "${SERVICE_USER}"
355 if service_is_available "${PUBLIC_URL}"; then
356 MSG="** Don't forgett to remove your public site! (${PUBLIC_URL}) **" wait_key 10
361 rst_title "user $SERVICE_USER" section
363 tee_stderr 1 <<EOF | bash | prefix_stdout
364useradd --shell /bin/bash --system \
365 --home-dir "$SERVICE_HOME" \
366 --comment 'Privacy-respecting metasearch engine' $SERVICE_USER
368chown -R "$SERVICE_GROUP:$SERVICE_GROUP" "$SERVICE_HOME"
371 #SERVICE_HOME="$(sudo -i -u "$SERVICE_USER" echo \$HOME)"
373 #echo "export SERVICE_HOME=$SERVICE_HOME"
376clone_is_available() {
377 [[ -f "$SEARX_SRC/.git/config" ]]
380# shellcheck disable=SC2164
382 rst_title "Clone searx sources" section
384 if ! sudo -i -u "$SERVICE_USER" ls -d "$REPO_ROOT" > /dev/null; then
385 die 42 "user '$SERVICE_USER' missed read permission: $REPO_ROOT"
387 SERVICE_HOME="$(sudo -i -u "$SERVICE_USER" echo \$HOME 2>/dev/null)"
388 if [[ ! "${SERVICE_HOME}" ]]; then
389 err_msg "to clone searx sources, user $SERVICE_USER hast to be created first"
392 if [[ ! $(git show-ref "refs/heads/${GIT_BRANCH}") ]]; then
393 warn_msg "missing local branch ${GIT_BRANCH}"
394 info_msg "create local branch ${GIT_BRANCH} from start point: origin/${GIT_BRANCH}"
395 git branch "${GIT_BRANCH}" "origin/${GIT_BRANCH}"
397 if [[ ! $(git rev-parse --abbrev-ref HEAD) == "${GIT_BRANCH}" ]]; then
398 warn_msg "take into account, installing branch $GIT_BRANCH while current branch is $(git rev-parse --abbrev-ref HEAD)"
401 git_clone "$REPO_ROOT" "$SEARX_SRC" \
402 "$GIT_BRANCH" "$SERVICE_USER"
404 pushd "${SEARX_SRC}" > /dev/null
405 tee_stderr 0.1 <<EOF | sudo -H -u "${SERVICE_USER}" -i 2>&1 | prefix_stdout "$_service_prefix"
407git remote set-url origin ${GIT_URL}
408git config user.email "$ADMIN_EMAIL"
409git config user.name "$ADMIN_NAME"
416 rst_title "${SEARX_SETTINGS_PATH}" section
417 if ! clone_is_available; then
418 err_msg "you have to install searx first"
421 mkdir -p "$(dirname "${SEARX_SETTINGS_PATH}")"
423 if [[ ! -f ${SEARX_SETTINGS_PATH} ]]; then
424 info_msg "install settings ${SEARX_SETTINGS_TEMPLATE}"
425 info_msg " --> ${SEARX_SETTINGS_PATH}"
426 cp "${SEARX_SETTINGS_TEMPLATE}" "${SEARX_SETTINGS_PATH}"
431 rst_para "Diff between origin's setting file (+) and current (-):"
432 echo "${SEARX_SETTINGS_PATH}" "${SEARX_SETTINGS_TEMPLATE}"
433 $DIFF_CMD "${SEARX_SETTINGS_PATH}" "${SEARX_SETTINGS_TEMPLATE}"
436 choose_one action "What should happen to the settings file? " \
437 "keep configuration unchanged" \
438 "use origin settings" \
439 "start interactiv shell"
441 "keep configuration unchanged")
442 info_msg "leave settings file unchanged"
444 "use origin settings")
445 backup_file "${SEARX_SETTINGS_PATH}"
446 info_msg "install origin settings"
447 cp "${SEARX_SETTINGS_TEMPLATE}" "${SEARX_SETTINGS_PATH}"
449 "start interactiv shell")
450 backup_file "${SEARX_SETTINGS_PATH}"
451 echo -e "// exit with [${_BCyan}CTRL-D${_creset}]"
453 rst_para 'Diff between new setting file (-) and current (+):'
455 $DIFF_CMD "${SEARX_SETTINGS_TEMPLATE}" "${SEARX_SETTINGS_PATH}"
462 rst_title "remove searx settings" section
464 info_msg "delete ${SEARX_SETTINGS_PATH}"
465 rm -f "${SEARX_SETTINGS_PATH}"
469 rst_title "Drop searx sources" section
470 if ask_yn "Do you really want to drop searx sources ($SEARX_SRC)?"; then
473 rst_para "Leave searx sources unchanged."
477pyenv_is_available() {
478 [[ -f "${SEARX_PYENV}/bin/activate" ]]
482 rst_title "Create virtualenv (python)" section
484 if [[ ! -f "${SEARX_SRC}/manage" ]]; then
485 err_msg "to create pyenv for searx, searx has to be cloned first"
488 info_msg "create pyenv in ${SEARX_PYENV}"
489 tee_stderr 0.1 <<EOF | sudo -H -u "${SERVICE_USER}" -i 2>&1 | prefix_stdout "$_service_prefix"
490rm -rf "${SEARX_PYENV}"
491python3 -m venv "${SEARX_PYENV}"
492grep -qFs -- 'source ${SEARX_PYENV}/bin/activate' ~/.profile \
493 || echo 'source ${SEARX_PYENV}/bin/activate' >> ~/.profile
495 info_msg "inspect python's virtual environment"
496 tee_stderr 0.1 <<EOF | sudo -H -u "${SERVICE_USER}" -i 2>&1 | prefix_stdout "$_service_prefix"
497command -v python && python --version
500 info_msg "install needed python packages"
501 tee_stderr 0.1 <<EOF | sudo -H -u "${SERVICE_USER}" -i 2>&1 | prefix_stdout "$_service_prefix"
503pip install -U setuptools
512 rst_title "Remove virtualenv (python)" section
513 if ! ask_yn "Do you really want to drop ${SEARX_PYENV} ?"; then
516 info_msg "remove pyenv activation from ~/.profile"
517 tee_stderr 0.1 <<EOF | sudo -H -u "${SERVICE_USER}" -i 2>&1 | prefix_stdout "$_service_prefix"
518grep -v 'source ${SEARX_PYENV}/bin/activate' ~/.profile > ~/.profile.##
519mv ~/.profile.## ~/.profile
521 rm -rf "${SEARX_PYENV}"
525 rst_title "Configure searx" section
526 rst_para "Setup searx config located at $SEARX_SETTINGS_PATH"
528 tee_stderr 0.1 <<EOF | sudo -H -i 2>&1 | prefix_stdout "$_service_prefix"
530sed -i -e "s/ultrasecretkey/$(openssl rand -hex 16)/g" "$SEARX_SETTINGS_PATH"
531sed -i -e "s/{instance_name}/${SEARX_INSTANCE_NAME}/g" "$SEARX_SETTINGS_PATH"
536 rst_title "Testing searx instance localy" section
539 if service_is_available "http://${SEARX_INTERNAL_HTTP}" &>/dev/null; then
540 err_msg "URL/port http://${SEARX_INTERNAL_HTTP} is already in use, you"
541 err_msg "should stop that service before starting local tests!"
542 if ! ask_yn "Continue with local tests?"; then
546 sed -i -e "s/debug : False/debug : True/g" "$SEARX_SETTINGS_PATH"
547 tee_stderr 0.1 <<EOF | sudo -H -u "${SERVICE_USER}" -i 2>&1 | prefix_stdout "$_service_prefix"
548export SEARX_SETTINGS_PATH="${SEARX_SETTINGS_PATH}"
550timeout 10 python searx/webapp.py &
552curl --location --verbose --head --insecure $SEARX_INTERNAL_HTTP
554 sed -i -e "s/debug : True/debug : False/g" "$SEARX_SETTINGS_PATH"
557install_searx_uwsgi() {
558 rst_title "Install searx's uWSGI app (searx.ini)" section
561 uWSGI_install_app "$SEARX_UWSGI_APP"
564remove_searx_uwsgi() {
565 rst_title "Remove searx's uWSGI app (searx.ini)" section
567 uWSGI_remove_app "$SEARX_UWSGI_APP"
571 rst_title "Activate $SEARX_INSTANCE_NAME (service)" section
573 uWSGI_enable_app "$SEARX_UWSGI_APP"
574 uWSGI_restart "$SEARX_UWSGI_APP"
577deactivate_service() {
578 rst_title "De-Activate $SEARX_INSTANCE_NAME (service)" section
580 uWSGI_disable_app "$SEARX_UWSGI_APP"
581 uWSGI_restart "$SEARX_UWSGI_APP"
584enable_image_proxy() {
585 info_msg "try to enable image_proxy ..."
586 tee_stderr 0.1 <<EOF | sudo -H -i 2>&1 | prefix_stdout "$_service_prefix"
588sed -i -e "s/image_proxy : False/image_proxy : True/g" "$SEARX_SETTINGS_PATH"
590 uWSGI_restart "$SEARX_UWSGI_APP"
593disable_image_proxy() {
594 info_msg "try to enable image_proxy ..."
595 tee_stderr 0.1 <<EOF | sudo -H -i 2>&1 | prefix_stdout "$_service_prefix"
597sed -i -e "s/image_proxy : True/image_proxy : False/g" "$SEARX_SETTINGS_PATH"
599 uWSGI_restart "$SEARX_UWSGI_APP"
603 warn_msg "Do not enable debug in production enviroments!!"
604 info_msg "try to enable debug mode ..."
605 tee_stderr 0.1 <<EOF | sudo -H -i 2>&1 | prefix_stdout "$_service_prefix"
607sed -i -e "s/debug : False/debug : True/g" "$SEARX_SETTINGS_PATH"
609 uWSGI_restart "$SEARX_UWSGI_APP"
613 info_msg "try to disable debug mode ..."
614 tee_stderr 0.1 <<EOF | sudo -H -i 2>&1 | prefix_stdout "$_service_prefix"
616sed -i -e "s/debug : True/debug : False/g" "$SEARX_SETTINGS_PATH"
618 uWSGI_restart "$SEARX_UWSGI_APP"
623 # usage: set_result_proxy <URL> [<key>]
625 info_msg "try to set result proxy: '$1' ($2)"
626 cp "${SEARX_SETTINGS_PATH}" "${SEARX_SETTINGS_PATH}.bak"
627 _set_result_proxy "$1" "$2" > "${SEARX_SETTINGS_PATH}"
634 local key=" key: !!binary \"$2\""
639 while IFS= read -r line
641 if [[ $stage = 0 ]] || [[ $stage = 2 ]] ; then
642 if [[ $line =~ ^[[:space:]]*#*[[:space:]]*result_proxy[[:space:]]*:[[:space:]]*$ ]]; then
643 if [[ $stage = 0 ]]; then
647 elif [[ $stage = 2 ]]; then
652 if [[ $stage = 1 ]] || [[ $stage = 2 ]] ; then
653 if [[ $line =~ ^[[:space:]]*#*[[:space:]]*url[[:space:]]*:[[:space:]] ]]; then
654 [[ $stage = 1 ]] && echo "$url"
656 elif [[ $line =~ ^[[:space:]]*#*[[:space:]]*key[[:space:]]*:[[:space:]] ]]; then
657 [[ $stage = 1 ]] && [[ -n $key ]] && echo "$key"
659 elif [[ $line =~ ^[[:space:]]*$ ]]; then
664 done < "${SEARX_SETTINGS_PATH}.bak"
667function has_substring() {
668 [[ "$1" != "${2/$1/}" ]]
671 rst_title "service status & log"
674sourced ${DOT_CONFIG#"$REPO_ROOT/"} :
676 PUBLIC_URL : ${PUBLIC_URL}
677 SEARX_URL_PATH : ${SEARX_URL_PATH}
678 SEARX_INSTANCE_NAME : ${SEARX_INSTANCE_NAME}
679 SEARX_INTERNAL_HTTP : ${SEARX_INTERNAL_HTTP}
683 if service_account_is_available "$SERVICE_USER"; then
684 info_msg "Service account $SERVICE_USER exists."
686 err_msg "Service account $SERVICE_USER does not exists!"
689 if pyenv_is_available; then
690 info_msg "~$SERVICE_USER: python environment is available."
692 err_msg "~$SERVICE_USER: python environment is not available!"
695 if clone_is_available; then
696 info_msg "~$SERVICE_USER: Searx software is installed."
698 err_msg "~$SERVICE_USER: Missing searx software!"
701 if uWSGI_app_enabled "$SEARX_UWSGI_APP"; then
702 info_msg "uWSGI app $SEARX_UWSGI_APP is enabled."
704 err_msg "uWSGI app $SEARX_UWSGI_APP not enabled!"
707 uWSGI_app_available "$SEARX_UWSGI_APP" \
708 || err_msg "uWSGI app $SEARX_UWSGI_APP not available!"
710 if in_container; then
713 info_msg "public URL --> ${PUBLIC_URL}"
714 info_msg "internal URL --> http://${SEARX_INTERNAL_HTTP}"
717 if ! service_is_available "http://${SEARX_INTERNAL_HTTP}"; then
718 err_msg "uWSGI app (service) at http://${SEARX_INTERNAL_HTTP} is not available!"
719 MSG="${_Green}[${_BCyan}CTRL-C${_Green}] to stop or [${_BCyan}KEY${_Green}] to continue"\
723 if ! service_is_available "${PUBLIC_URL}"; then
724 warn_msg "Public service at ${PUBLIC_URL} is not available!"
725 if ! in_container; then
726 warn_msg "Check if public name is correct and routed or use the public IP from above."
731 if ask_yn "Enable searx debug mode?"; then
737 case $DIST_ID-$DIST_VERS in
739 systemctl --no-pager -l status "${SERVICE_NAME}"
742 systemctl --no-pager -l status "uwsgi@${SERVICE_NAME%.*}"
745 systemctl --no-pager -l status uwsgi
749 # shellcheck disable=SC2059
750 printf "// use ${_BCyan}CTRL-C${_creset} to stop monitoring the log"
756 case $DIST_ID-$DIST_VERS in
757 ubuntu-*|debian-*) tail -f /var/log/uwsgi/app/searx.log ;;
758 arch-*) journalctl -f -u "uwsgi@${SERVICE_NAME%.*}" ;;
759 fedora-*|centos-7) journalctl -f -u uwsgi ;;
763 if [[ $_debug_on == 1 ]]; then
769install_apache_site() {
770 rst_title "Install Apache site $APACHE_SEARX_SITE"
773This installs the searx uwsgi app as apache site. If your server is public to
774the internet, you should instead use a reverse proxy (filtron) to block
775excessively bot queries."
777 ! apache_is_installed && err_msg "Apache is not installed."
779 if ! ask_yn "Do you really want to continue?" Yn; then
785 apache_install_site --variant=uwsgi "${APACHE_SEARX_SITE}"
787 rst_title "Install searx's uWSGI app (searx.ini)" section
789 uWSGI_install_app --variant=socket "$SEARX_UWSGI_APP"
791 if ! service_is_available "${PUBLIC_URL}"; then
792 err_msg "Public service at ${PUBLIC_URL} is not available!"
796remove_apache_site() {
798 rst_title "Remove Apache site ${APACHE_SEARX_SITE}"
801This removes apache site ${APACHE_SEARX_SITE}."
803 ! apache_is_installed && err_msg "Apache is not installed."
805 if ! ask_yn "Do you really want to continue?" Yn; then
809 apache_remove_site "${APACHE_SEARX_SITE}"
811 rst_title "Remove searx's uWSGI app (searx.ini)" section
813 uWSGI_remove_app "$SEARX_UWSGI_APP"
817 local debian="${SEARX_PACKAGES_debian}"
818 local arch="${SEARX_PACKAGES_arch}"
819 local fedora="${SEARX_PACKAGES_fedora}"
820 local centos="${SEARX_PACKAGES_centos}"
821 local debian_build="${BUILD_PACKAGES_debian}"
822 local arch_build="${BUILD_PACKAGES_arch}"
823 local fedora_build="${BUILD_PACKAGES_fedora}"
824 local centos_build="${SEARX_PACKAGES_centos}"
825 debian="$(echo "${debian}" | sed 's/.*/ & \\/' | sed '$ s/.$//')"
826 arch="$(echo "${arch}" | sed 's/.*/ & \\/' | sed '$ s/.$//')"
827 fedora="$(echo "${fedora}" | sed 's/.*/ & \\/' | sed '$ s/.$//')"
828 centos="$(echo "${centos}" | sed 's/.*/ & \\/' | sed '$ s/.$//')"
829 debian_build="$(echo "${debian_build}" | sed 's/.*/ & \\/' | sed '$ s/.$//')"
830 arch_build="$(echo "${arch_build}" | sed 's/.*/ & \\/' | sed '$ s/.$//')"
831 fedora_build="$(echo "${fedora_build}" | sed 's/.*/ & \\/' | sed '$ s/.$//')"
832 centos_build="$(echo "${centos_build}" | sed 's/.*/ & \\/' | sed '$ s/.$//')"
834 eval "echo \"$(< "${REPO_ROOT}/docs/build-templates/searx.rst")\""
836 # I use ubuntu-20.04 here to demonstrate that versions are also suported,
837 # normaly debian-* and ubuntu-* are most the same.
839 for DIST_NAME in ubuntu-20.04 arch fedora; do
841 DIST_ID=${DIST_NAME%-*}
842 DIST_VERS=${DIST_NAME#*-}
843 [[ $DIST_VERS =~ $DIST_ID ]] && DIST_VERS=
846 echo -e "\n.. START searx uwsgi-description $DIST_NAME"
848 case $DIST_ID-$DIST_VERS in
849 ubuntu-*|debian-*) cat <<EOF
853 # init.d --> /usr/share/doc/uwsgi/README.Debian.gz
854 # For uWSGI debian uses the LSB init process, this might be changed
855 # one day, see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=833067
857 create ${uWSGI_APPS_AVAILABLE}/${SEARX_UWSGI_APP}
858 enable: sudo -H ln -s ${uWSGI_APPS_AVAILABLE}/${SEARX_UWSGI_APP} ${uWSGI_APPS_ENABLED}/
859 start: sudo -H service uwsgi start ${SEARX_UWSGI_APP%.*}
860 restart: sudo -H service uwsgi restart ${SEARX_UWSGI_APP%.*}
861 stop: sudo -H service uwsgi stop ${SEARX_UWSGI_APP%.*}
862 disable: sudo -H rm ${uWSGI_APPS_ENABLED}/${SEARX_UWSGI_APP}
870 # systemd --> /usr/lib/systemd/system/uwsgi@.service
871 # For uWSGI archlinux uses systemd template units, see
872 # - http://0pointer.de/blog/projects/instances.html
873 # - https://uwsgi-docs.readthedocs.io/en/latest/Systemd.html#one-service-per-app-in-systemd
875 create: ${uWSGI_APPS_ENABLED}/${SEARX_UWSGI_APP}
876 enable: sudo -H systemctl enable uwsgi@${SEARX_UWSGI_APP%.*}
877 start: sudo -H systemctl start uwsgi@${SEARX_UWSGI_APP%.*}
878 restart: sudo -H systemctl restart uwsgi@${SEARX_UWSGI_APP%.*}
879 stop: sudo -H systemctl stop uwsgi@${SEARX_UWSGI_APP%.*}
880 disable: sudo -H systemctl disable uwsgi@${SEARX_UWSGI_APP%.*}
884 fedora-*|centos-7) cat <<EOF
888 # systemd --> /usr/lib/systemd/system/uwsgi.service
889 # The unit file starts uWSGI in emperor mode (/etc/uwsgi.ini), see
890 # - https://uwsgi-docs.readthedocs.io/en/latest/Emperor.html
892 create: ${uWSGI_APPS_ENABLED}/${SEARX_UWSGI_APP}
893 restart: sudo -H touch ${uWSGI_APPS_ENABLED}/${SEARX_UWSGI_APP}
894 disable: sudo -H rm ${uWSGI_APPS_ENABLED}/${SEARX_UWSGI_APP}
899 echo -e ".. END searx uwsgi-description $DIST_NAME"
901 echo -e "\n.. START searx uwsgi-appini $DIST_NAME"
902 echo ".. code:: bash"
904 eval "echo \"$(< "${TEMPLATES}/${uWSGI_APPS_AVAILABLE}/${SEARX_UWSGI_APP}")\"" | prefix_stdout " "
905 echo -e "\n.. END searx uwsgi-appini $DIST_NAME"
912# ----------------------------------------------------------------------------
914# ----------------------------------------------------------------------------
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list