on master help sign in
utils/searx.sh & filtron.sh: misc changes from first tests (WIP)

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>

commit924bf6551794e5962688c1e2962dc0c94869e2f1 authorMarkus Heiser <markus.heiser@darmarit.de> dateWed 29 Jan 2020, 20:00 (7 years ago) parent971a826
6 files changed+285−101
.gitignore+1 utils/dot_config+8 utils/filtron.sh+114−41 utils/lib.sh+87−16 utils/searx.sh+72−44 utils/templates/etc/apache2/sites-available/searx.conf:filtron+3
.gitignore+1
@@ -25,3 +25,4 @@ dist/
2525local/
2626gh-pages/
2727searx.egg-info/
28+.config
utils/dot_confignew file+8
@@ -0,0 +1,8 @@
1+# -*- coding: utf-8; mode: sh -*-
2+# SPDX-License-Identifier: AGPL-3.0-or-later
3+#
4+# Set environment used by ./utils scripts like filtron.sh or searx.sh
5+#
6+
7+# Public URL of the searx instance
8+PUBLIC_URL="${PUBLIC_URL:-https://$(uname -n)/searx}"
utils/filtron.sh+114−41
@@ -5,6 +5,7 @@
55
66# shellcheck source=utils/lib.sh
77source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
8+source_dot_config
89
910# ----------------------------------------------------------------------------
1011# config
@@ -30,7 +31,9 @@ GO_ENV="${SERVICE_HOME}/.go_env"
3031GO_PKG_URL="https://dl.google.com/go/go1.13.5.linux-amd64.tar.gz"
3132GO_TAR=$(basename "$GO_PKG_URL")
3233
33−APACHE_SITE="searx.conf"
34+# Apache Settings
35+
36+APACHE_FILTRON_SITE="searx.conf"
3437
3538# shellcheck disable=SC2034
3639CONFIG_FILES=(
@@ -53,22 +56,32 @@ usage:
5356 $(basename "$0") remove [all]
5457 $(basename "$0") activate [service]
5558 $(basename "$0") deactivate [service]
56− $(basename "$0") show [service]
59+ $(basename "$0") inspect [service]
60+ $(basename "$0") apache [install|remove]
61+
5762
5863shell
5964 start interactive shell from user ${SERVICE_USER}
60−install / remove all
61− complete setup of filtron service
65+install / remove
66+ all: complete setup of filtron service
67+ user: add/remove service user '$SERVICE_USER' at $SERVICE_HOME
6268update filtron
6369 Update filtron installation of user ${SERVICE_USER}
64−activate
70+activate service
6571 activate and start service daemon (systemd unit)
6672deactivate service
6773 stop and deactivate service daemon (systemd unit)
68−install user
69− add service user '$SERVICE_USER' at $SERVICE_HOME
70−show service
74+inspect service
7175 show service status and log
76+apache
77+ install: apache site with a reverse proxy (ProxyPass)
78+ remove: apache site ${APACHE_FILTRON_SITE}
79+
80+If needed change the environment variable PUBLIC_URL of your WEB service in the
81+${DOT_CONFIG#"$REPO_ROOT/"} file:
82+
83+ PUBLIC_URL : ${PUBLIC_URL}
84+
7285EOF
7386 [ ! -z ${1+x} ] && echo -e "$1"
7487}
@@ -76,6 +89,10 @@ EOF
7689main() {
7790 rst_title "$SERVICE_NAME" part
7891
92+ required_commands \
93+ dpkg apt-get install git wget curl \
94+ || exit
95+
7996 local _usage="ERROR: unknown or missing $1 command $2"
8097
8198 case $1 in
@@ -86,11 +103,11 @@ main() {
86103 sudo_or_exit
87104 interactive_shell
88105 ;;
89− show)
106+ inspect)
90107 case $2 in
91108 service)
92109 sudo_or_exit
93− show_service
110+ inspect_service
94111 ;;
95112 *) usage "$_usage"; exit 42;;
96113 esac ;;
@@ -126,6 +143,14 @@ main() {
126143 service) deactivate_service ;;
127144 *) usage "$_usage"; exit 42;;
128145 esac ;;
146+ apache)
147+ sudo_or_exit
148+ case $2 in
149+ install) install_apache_site ;;
150+ remove) remove_apache_site ;;
151+ *) usage "$_usage"; exit 42;;
152+ esac ;;
153+
129154 *) usage "ERROR: unknown or missing command $1"; exit 42;;
130155 esac
131156}
@@ -140,14 +165,29 @@ install_all() {
140165 wait_key
141166 install_service
142167 wait_key
168+ echo
169+ if ! service_is_available "http://${FILTRON_LISTEN}" ; then
170+ err_msg "Filtron does not listening on: http://${FILTRON_LISTEN}"
171+ fi
143172 if apache_is_installed; then
144− install_apache_site
145− wait_key
173+ info_msg "Apache is installed on this host."
174+ if ask_yn "Do you want to install a reverse proxy (ProxyPass)" Yn; then
175+ install_apache_site
176+ fi
177+ fi
178+ if ask_yn "Do you want to inspect the installation?" Yn; then
179+ inspect_service
146180 fi
181+
147182}
148183
149184remove_all() {
150185 rst_title "De-Install $SERVICE_NAME (service)"
186+
187+ rst_para "\
188+It goes without saying that this script can only be used to remove
189+installations that were installed with this script."
190+
151191 remove_service
152192 wait_key
153193 remove_user
@@ -155,18 +195,6 @@ remove_all() {
155195 wait_key
156196}
157197
158−filtron_is_available() {
159− curl --insecure "http://${FILTRON_LISTEN}" &>/dev/null
160−}
161−
162−api_is_available() {
163− curl --insecure "http://${FILTRON_API}" &>/dev/null
164−}
165−
166−target_is_available() {
167− curl --insecure "http://${FILTRON_TARGET}" &>/dev/null
168−}
169−
170198install_service() {
171199 rst_title "Install System-D Unit ${SERVICE_NAME}.service" section
172200 echo
@@ -191,7 +219,7 @@ systemctl enable $SERVICE_NAME.service
191219systemctl restart $SERVICE_NAME.service
192220EOF
193221 tee_stderr <<EOF | bash 2>&1
194−systemctl status $SERVICE_NAME.service
222+systemctl status --no-pager $SERVICE_NAME.service
195223EOF
196224}
197225
@@ -265,9 +293,8 @@ mkdir -p \$HOME/local
265293rm -rf \$HOME/local/go
266294tar -C \$HOME/local -xzf ${CACHE}/${GO_TAR}
267295EOF
268− echo
269296 sudo -i -u "$SERVICE_USER" <<EOF | prefix_stdout
270−! which go >/dev/null && echo "Go Installation not found in PATH!?!"
297+! which go >/dev/null && echo "ERROR - Go Installation not found in PATH!?!"
271298which go >/dev/null && go version && echo "congratulations -- Go installation OK :)"
272299EOF
273300}
@@ -293,9 +320,20 @@ go get -v -u github.com/asciimoo/filtron
293320EOF
294321}
295322
296−show_service() {
323+inspect_service() {
324+
297325 rst_title "service status & log"
298− echo
326+
327+ cat <<EOF
328+
329+sourced ${DOT_CONFIG#"$REPO_ROOT/"} :
330+
331+ PUBLIC_URL : ${PUBLIC_URL}
332+ FILTRON_API : ${FILTRON_API}
333+ FILTRON_LISTEN : ${FILTRON_LISTEN}
334+ FILTRON_TARGET : ${FILTRON_TARGET}
335+
336+EOF
299337
300338 apache_is_installed && info_msg "Apache is installed."
301339
@@ -314,20 +352,21 @@ show_service() {
314352 else
315353 err_msg "~$SERVICE_USER: filtron app is not installed!"
316354 fi
317− if api_is_available; then
318− info_msg "API available at: http://${FILTRON_API}"
319− else
355+
356+ if ! service_is_available "http://${FILTRON_API}"; then
320357 err_msg "API not available at: http://${FILTRON_API}"
321358 fi
322− if filtron_is_available; then
323− info_msg "Filtron listening on: http://${FILTRON_LISTEN}"
324− else
359+
360+ if ! service_is_available "http://${FILTRON_LISTEN}" ; then
325361 err_msg "Filtron does not listening on: http://${FILTRON_LISTEN}"
326362 fi
327− if target_is_available; then
363+
364+ if ! service_is_available ""http://${FILTRON_TARGET}"" ; then
328365 info_msg "Filtron's target is available at: http://${FILTRON_TARGET}"
329− else
330− err_msg "Filtron's target is not available at: http://${FILTRON_TARGET}"
366+ fi
367+
368+ if ! service_is_available "${PUBLIC_URL}"; then
369+ err_msg "Public service at ${PUBLIC_URL} is not available!"
331370 fi
332371
333372 wait_key
@@ -344,10 +383,44 @@ show_service() {
344383}
345384
346385install_apache_site() {
347− rst_title "Install Apache site $APACHE_SITE" section
386+
387+ rst_title "Install Apache site $APACHE_FILTRON_SITE"
388+
389+ rst_para "\
390+This installs a reverse proxy (ProxyPass) into apache site (${APACHE_FILTRON_SITE})"
391+
392+ ! apache_is_installed && err_msg "Apache is not installed."
393+
394+ if ! ask_yn "Do you really want to continue?"; then
395+ return
396+ fi
397+
398+ a2enmod proxy
399+ a2enmod proxy_http
400+
348401 echo
349− err_msg "not yet implemented (${APACHE_SITE})"; return 42
350− # apache_install_site "${APACHE_SITE}"
402+ apache_install_site --variant=filtron "${APACHE_FILTRON_SITE}"
403+
404+ info_msg "testing public url .."
405+ if ! service_is_available "${PUBLIC_URL}"; then
406+ err_msg "Public service at ${PUBLIC_URL} is not available!"
407+ fi
408+}
409+
410+remove_apache_site() {
411+
412+ rst_title "Remove Apache site $APACHE_FILTRON_SITE"
413+
414+ rst_para "\
415+This removes apache site ${APACHE_FILTRON_SITE}."
416+
417+ ! apache_is_installed && err_msg "Apache is not installed."
418+
419+ if ! ask_yn "Do you really want to continue?"; then
420+ return
421+ fi
422+
423+ apache_remove_site "$APACHE_FILTRON_SITE"
351424}
352425
353426# ----------------------------------------------------------------------------
utils/lib.sh+87−16
@@ -1,6 +1,7 @@
11#!/usr/bin/env bash
22# -*- coding: utf-8; mode: sh indent-tabs-mode: nil -*-
3−# shellcheck disable=SC2059,SC1117,SC2162,SC2004
3+# SPDX-License-Identifier: AGPL-3.0-or-later
4+# shellcheck disable=SC2059,SC1117
45
56ADMIN_NAME="${ADMIN_NAME:-$(git config user.name)}"
67ADMIN_NAME="${ADMIN_NAME:-$USER}"
@@ -35,6 +36,20 @@ if [[ -z ${DIFF_CMD} ]]; then
3536 fi
3637fi
3738
39+DOT_CONFIG="${DOT_CONFIG:-${REPO_ROOT}/.config}"
40+
41+source_dot_config() {
42+ if [[ ! -e "$DOT_CONFIG" ]]; then
43+ info_msg "installing $DOT_CONFIG"
44+ cp "$(dirname "${BASH_SOURCE[0]}")/dot_config" "$DOT_CONFIG"
45+ if [[ ! -z ${SUDO_USER} ]]; then
46+ chown "${SUDO_USER}:${SUDO_USER}" "$DOT_CONFIG"
47+ fi
48+ fi
49+ # shellcheck disable=SC1090
50+ source "${REPO_ROOT}/.config"
51+}
52+
3853sudo_or_exit() {
3954 # usage: sudo_or_exit
4055
@@ -44,6 +59,22 @@ sudo_or_exit() {
4459 fi
4560}
4661
62+required_commands() {
63+
64+ # usage: requires_commands [cmd1 ...]
65+
66+ local exit_val=0
67+ while [ ! -z "$1" ]; do
68+
69+ if ! command -v "$1" &>/dev/null; then
70+ err_msg "missing command $1"
71+ exit_val=42
72+ fi
73+ shift
74+ done
75+ return $exit_val
76+}
77+
4778rst_title() {
4879 # usage: rst_title <header-text> [part|chapter|section]
4980
@@ -81,7 +112,7 @@ info_msg() { echo -e "INFO: $*"; }
81112
82113clean_stdin() {
83114 if [[ $(uname -s) != 'Darwin' ]]; then
84− while read -n1 -t 0.1; do : ; done
115+ while read -r -n1 -t 0.1; do : ; done
85116 fi
86117}
87118
@@ -93,7 +124,7 @@ wait_key(){
93124 [[ ! -z $FORCE_TIMEOUT ]] && _t=$FORCE_TIMEOUT
94125 [[ ! -z $_t ]] && _t="-t $_t"
95126 # shellcheck disable=SC2086
96− read -s -n1 $_t -p "** press any [KEY] to continue **"
127+ read -r -s -n1 $_t -p "** press any [KEY] to continue **"
97128 echo
98129 clean_stdin
99130}
@@ -124,7 +155,7 @@ ask_yn() {
124155 clean_stdin
125156 printf "$1 ${choice} "
126157 # shellcheck disable=SC2086
127− read -n1 $_t
158+ read -r -n1 $_t
128159 if [[ -z $REPLY ]]; then
129160 printf "$default\n"; break
130161 elif [[ $REPLY =~ ^[Yy]$ ]]; then
@@ -156,7 +187,7 @@ tee_stderr () {
156187 local _t="0";
157188 if [[ ! -z $1 ]] ; then _t="$1"; fi
158189
159− (while read line; do
190+ (while read -r line; do
160191 # shellcheck disable=SC2086
161192 sleep $_t
162193 echo -e "$line" >&2
@@ -171,6 +202,7 @@ prefix_stdout () {
171202
172203 if [[ ! -z $1 ]] ; then prefix="$1"; fi
173204
205+ # shellcheck disable=SC2162
174206 (while IFS= read line; do
175207 echo -e "${prefix}$line"
176208 done)
@@ -214,7 +246,7 @@ cache_download() {
214246 else
215247 wget --progress=bar -O "${CACHE}/$2" "$1" ; exit_value=$?
216248 fi
217− if $exit_value; then
249+ if [[ $exit_value = 0 ]]; then
218250 err_msg "failed to download: $1"
219251 fi
220252 fi
@@ -238,7 +270,7 @@ choose_one() {
238270
239271 list=("$@")
240272 echo -e "Menu::"
241− for ((i=1; i<= $(($max -1)); i++)); do
273+ for ((i=1; i<= $((max -1)); i++)); do
242274 if [[ "$i" == "$default" ]]; then
243275 echo -e " $i.) ${list[$i]} [default]"
244276 else
@@ -249,15 +281,15 @@ choose_one() {
249281 clean_stdin
250282 printf "$1 [$default] "
251283
252− if (( 10 > $max )); then
284+ if (( 10 > max )); then
253285 # shellcheck disable=SC2086
254− read -n1 $_t
286+ read -r -n1 $_t
255287 else
256288 # shellcheck disable=SC2086,SC2229
257− read $_t
289+ read -r $_t
258290 fi
259291 # selection fits
260− [[ $REPLY =~ ^-?[0-9]+$ ]] && (( $REPLY > 0 )) && (( $REPLY < $max )) && break
292+ [[ $REPLY =~ ^-?[0-9]+$ ]] && (( REPLY > 0 )) && (( REPLY < max )) && break
261293
262294 # take default
263295 [[ -z $REPLY ]] && REPLY=$default && break
@@ -386,6 +418,28 @@ install_template() {
386418 done
387419}
388420
421+
422+service_is_available() {
423+
424+ # usage: service_is_available <URL>
425+
426+ local URL="$1"
427+ if [[ -z $URL ]]; then
428+ err_msg "service_is_available: missing arguments"
429+ return 42
430+ fi
431+
432+ http_code=$(curl -H 'Cache-Control: no-cache' \
433+ --silent -o /dev/null --head --write-out '%{http_code}' --insecure \
434+ "${URL}")
435+ exit_val=$?
436+ if [[ $exit_val = 0 ]]; then
437+ info_msg "got $http_code from ${URL}"
438+ fi
439+ return $exit_val
440+}
441+
442+
389443# Apache
390444# ------
391445
@@ -430,18 +484,32 @@ apache_install_site() {
430484 root root 644
431485
432486 apache_enable_site "${pos_args[1]}"
433− apache_reload
434487 info_msg "installed apache site: ${pos_args[1]}"
435488}
436489
490+apache_remove_site() {
491+
492+ # usage: apache_remove_site <mysite.conf>
493+
494+ info_msg "remove apache site: $1"
495+ apache_dissable_site "$1"
496+ rm -f "${APACHE_SITES_AVAILABE}/$1"
497+}
498+
437499apache_enable_site() {
438− info_msg "enable apache site $1 .."
500+
501+ # usage: apache_enable_site <mysite.conf>
502+
503+ info_msg "enable apache site: $1"
439504 sudo -H a2ensite -q "$1"
440505 apache_reload
441506}
442507
443508apache_dissable_site() {
444− info_msg "disable apache site $1 .."
509+
510+ # usage: apache_disable_site <mysite.conf>
511+
512+ info_msg "disable apache site: $1"
445513 sudo -H a2dissite -q "$1"
446514 apache_reload
447515}
@@ -456,7 +524,7 @@ uWSGI_restart() {
456524 # usage: uWSGI_restart()
457525
458526 info_msg "restart uWSGI service"
459− sudo -H systemctl restart uwsgi
527+ systemctl restart uwsgi
460528}
461529
462530uWSGI_app_available() {
@@ -498,10 +566,10 @@ uWSGI_remove_app() {
498566 # usage: uWSGI_remove_app <myapp.ini>
499567
500568 local CONF="$1"
569+ info_msg "remove uWSGI app: ${CONF}"
501570 uWSGI_disable_app "${CONF}"
502571 uWSGI_restart
503572 rm -f "${uWSGI_SETUP}/apps-available/${CONF}"
504− info_msg "removed uWSGI app: ${CONF}"
505573}
506574
507575uWSGI_app_enabled() {
@@ -542,6 +610,9 @@ uWSGI_disable_app() {
542610 return 42
543611 fi
544612 rm -f "${uWSGI_SETUP}/apps-enabled/${CONF}"
613+ # FIXME: restart uwsgi service won't stop wsgi forked processes of user searx.
614+ # I had to kill them manually here ...
615+ pkill -f "${uWSGI_SETUP}/apps-enabled/${CONF}" -9
545616 info_msg "disabled uWSGI app: ${CONF} (restart uWSGI required)"
546617}
547618
utils/searx.sh+72−44
@@ -1,19 +1,20 @@
11#!/usr/bin/env bash
22# -*- coding: utf-8; mode: sh indent-tabs-mode: nil -*-
33# SPDX-License-Identifier: AGPL-3.0-or-later
4−# shellcheck disable=SC2119
4+# shellcheck disable=SC2001
55
66# shellcheck source=utils/lib.sh
77source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
8+source_dot_config
89
910# ----------------------------------------------------------------------------
1011# config
1112# ----------------------------------------------------------------------------
1213
13−SEARX_PUBLIC_URL="${SEARX_PUBLIC_URL:-https://$(uname -n)/searx}"
14−SEARX_URL_PATH="${SEARX_URL_PATH:-$(echo "$SEARX_PUBLIC_URL" \
15−| sed -e 's,^.*://[^/]*\(/.*\),\1,g') }"
16−SEARX_INSTANCE_NAME="${SEARX_INSTANCE_NAME:-searx@$(echo "$SEARX_PUBLIC_URL" \
14+SEARX_URL_PATH="${SEARX_URL_PATH:-$(echo "${PUBLIC_URL}" \
15+| sed -e 's,^.*://[^/]*\(/.*\),\1,g')}"
16+[[ "${SEARX_URL_PATH}" == "${PUBLIC_URL}" ]] && SEARX_URL_PATH=/
17+SEARX_INSTANCE_NAME="${SEARX_INSTANCE_NAME:-searx@$(echo "$PUBLIC_URL" \
1718| sed -e 's,^.*://\([^\:/]*\).*,\1,g') }"
1819
1920SERVICE_USER="searx"
@@ -42,10 +43,10 @@ SEARX_APT_PACKAGES="\
4243# Apache Settings
4344
4445APACHE_APT_PACKAGES="\
45− apache2 libapache2-mod-uwsgi \
46+ libapache2-mod-uwsgi \
4647"
4748
48−SEARX_APACHE_SITE="searx.conf"
49+APACHE_SEARX_SITE="searx.conf"
4950
5051# shellcheck disable=SC2034
5152CONFIG_FILES=(
@@ -74,6 +75,7 @@ usage:
7475 $(basename "$0") deactivate [service]
7576 $(basename "$0") inspect [service]
7677 $(basename "$0") option [debug-on|debug-off]
78+ $(basename "$0") apache [install|remove]
7779
7880shell
7981 start interactive shell from user ${SERVICE_USER}
@@ -82,23 +84,25 @@ install / remove
8284 user: add/remove service user '$SERVICE_USER' at $SERVICE_HOME
8385 searx-src: clone $SEARX_GIT_URL
8486 pyenv: create/remove virtualenv (python) in $SEARX_PYENV
85− apache: install apache site for searx-uwsgi app
8687update searx
8788 Update searx installation of user ${SERVICE_USER}
88−activate
89+activate service
8990 activate and start service daemon (systemd unit)
9091deactivate service
9192 stop and deactivate service daemon (systemd unit)
9293inspect service
9394 run some small tests and inspect service's status and log
9495option
95− set one of te available options
96+ set one of the available options
97+apache
98+ install: apache site with the searx uwsgi app
99+ remove: apache site ${APACHE_FILTRON_SITE}
96100
97−Use environment SEARX_PUBLIC_URL to set public URL of your WEB-Server:
101+If needed change the environment variable PUBLIC_URL of your WEB service in the
102+${DOT_CONFIG#"$REPO_ROOT/"} file:
98103
99− SEARX_PUBLIC_URL : ${SEARX_PUBLIC_URL}
100− SEARX_URL_PATH : ${SEARX_URL_PATH}
101− SEARX_INSTANCE_NAME : ${SEARX_INSTANCE_NAME}
104+ PUBLIC_URL : ${PUBLIC_URL}
105+ SEARX_INSTANCE_NAME : ${SEARX_INSTANCE_NAME}
102106
103107EOF
104108 [ ! -z ${1+x} ] && echo -e "$1"
@@ -107,6 +111,10 @@ EOF
107111main() {
108112 rst_title "$SEARX_INSTANCE_NAME" part
109113
114+ required_commands \
115+ dpkg systemctl apt-get install git wget curl \
116+ || exit
117+
110118 local _usage="ERROR: unknown or missing $1 command $2"
111119
112120 case $1 in
@@ -132,7 +140,6 @@ main() {
132140 user) assert_user ;;
133141 pyenv) create_pyenv ;;
134142 searx-src) clone_searx ;;
135− apache) install_apache_site ;;
136143 *) usage "$_usage"; exit 42;;
137144 esac ;;
138145 update)
@@ -154,13 +161,13 @@ main() {
154161 sudo_or_exit
155162 case $2 in
156163 service)
157− activate_service; uWSGI_restart ;;
164+ activate_service ;;
158165 *) usage "$_usage"; exit 42;;
159166 esac ;;
160167 deactivate)
161168 sudo_or_exit
162169 case $2 in
163− service) deactivate_service; uWSGI_restart ;;
170+ service) deactivate_service ;;
164171 *) usage "$_usage"; exit 42;;
165172 esac ;;
166173 option)
@@ -170,6 +177,14 @@ main() {
170177 debug-off) echo; disable_debug ;;
171178 *) usage "$_usage"; exit 42;;
172179 esac ;;
180+ apache)
181+ sudo_or_exit
182+ case $2 in
183+ install) install_apache_site ;;
184+ remove) remove_apache_site ;;
185+ *) usage "$_usage"; exit 42;;
186+ esac ;;
187+
173188 *) usage "ERROR: unknown or missing command $1"; exit 42;;
174189 esac
175190}
@@ -191,9 +206,7 @@ install_all() {
191206 test_local_searx
192207 wait_key
193208 install_searx_uwsgi
194− if service_is_available "http://$SEARX_INTERNAL_URL" &>/dev/null; then
195− info_msg "URL http://$SEARX_INTERNAL_URL is available."
196− else
209+ if ! service_is_available "http://$SEARX_INTERNAL_URL"; then
197210 err_msg "URL http://$SEARX_INTERNAL_URL not available, check searx & uwsgi setup!"
198211 fi
199212 if ask_yn "Do you want to inspect the installation?" Yn; then
@@ -418,12 +431,14 @@ activate_service() {
418431 rst_title "Activate $SEARX_INSTANCE_NAME (service)" section
419432 echo
420433 uWSGI_enable_app "$SEARX_UWSGI_APP"
434+ uWSGI_restart
421435}
422436
423437deactivate_service() {
424438 rst_title "De-Activate $SEARX_INSTANCE_NAME (service)" section
425439 echo
426440 uWSGI_disable_app "$SEARX_UWSGI_APP"
441+ uWSGI_restart
427442}
428443
429444interactive_shell() {
@@ -438,12 +453,6 @@ git --no-pager diff
438453EOF
439454}
440455
441−service_is_available() {
442− curl -H 'Cache-Control: no-cache' -o /dev/null \
443− --silent --head --write-out '%{http_code}' --insecure \
444− "${1?missing URL argument}"
445−}
446−
447456enable_debug() {
448457 info_msg "try to enable debug mode ..."
449458 tee_stderr 0.1 <<EOF | sudo -H -u "${SERVICE_USER}" -i 2>&1 | prefix_stdout "$_service_prefix"
@@ -464,7 +473,16 @@ EOF
464473
465474inspect_service() {
466475 rst_title "service status & log"
467− echo
476+ cat <<EOF
477+
478+sourced ${DOT_CONFIG#"$REPO_ROOT/"} :
479+
480+ PUBLIC_URL : ${PUBLIC_URL}
481+ SEARX_URL_PATH : ${SEARX_URL_PATH}
482+ SEARX_INSTANCE_NAME : ${SEARX_INSTANCE_NAME}
483+ SEARX_INTERNAL_URL : ${SEARX_INTERNAL_URL}
484+
485+EOF
468486
469487 apache_is_installed && info_msg "Apache is installed."
470488
@@ -475,15 +493,15 @@ inspect_service() {
475493 fi
476494
477495 if pyenv_is_available; then
478− info_msg "${SEARX_PYENV}/bin/activate is available."
496+ info_msg "~$SERVICE_USER: python environment is available."
479497 else
480− err_msg "${SEARX_PYENV}/bin/activate not available!"
498+ err_msg "~$SERVICE_USER: python environment is not available!"
481499 fi
482500
483501 if clone_is_available; then
484− info_msg "Searx software is installed."
502+ info_msg "~$SERVICE_USER: Searx software is installed."
485503 else
486− err_msg "Missing searx software!"
504+ err_msg "~$SERVICE_USER: Missing searx software!"
487505 fi
488506
489507 if uWSGI_app_enabled "$SEARX_UWSGI_APP"; then
@@ -495,16 +513,12 @@ inspect_service() {
495513 uWSGI_app_available "$SEARX_UWSGI_APP" \
496514 || err_msg "uWSGI app $SEARX_UWSGI_APP not available!"
497515
498− if service_is_available "http://$SEARX_INTERNAL_URL" &>/dev/null; then
499− info_msg "uWSGI app (service) at http://$SEARX_INTERNAL_URL is available"
500− else
516+ if ! service_is_available "http://$SEARX_INTERNAL_URL"; then
501517 err_msg "uWSGI app (service) at http://$SEARX_INTERNAL_URL is not available!"
502518 fi
503519
504− if service_is_available "${SEARX_PUBLIC_URL}" &>/dev/null; then
505− info_msg "Public service at ${SEARX_PUBLIC_URL} is available"
506− else
507− err_msg "Public service at ${SEARX_PUBLIC_URL} is not available!"
520+ if ! service_is_available "${PUBLIC_URL}"; then
521+ err_msg "Public service at ${PUBLIC_URL} is not available!"
508522 fi
509523
510524 local _debug_on
@@ -530,7 +544,7 @@ inspect_service() {
530544}
531545
532546install_apache_site() {
533− rst_title "Install Apache site $SEARX_APACHE_SITE"
547+ rst_title "Install Apache site $APACHE_SEARX_SITE"
534548
535549 rst_para "\
536550This installs the searx uwsgi app as apache site. If your server ist public to
@@ -547,13 +561,27 @@ excessively bot queries."
547561 a2enmod uwsgi
548562
549563 echo
550− apache_install_site --variant=uwsgi "${SEARX_APACHE_SITE}"
564+ apache_install_site --variant=uwsgi "${APACHE_SEARX_SITE}"
551565
552− if service_is_available "${SEARX_PUBLIC_URL}" &>/dev/null; then
553− info_msg "Public service at ${SEARX_PUBLIC_URL} is available"
554− else
555− err_msg "Public service at ${SEARX_PUBLIC_URL} is not available!"
566+ if ! service_is_available "${PUBLIC_URL}"; then
567+ err_msg "Public service at ${PUBLIC_URL} is not available!"
568+ fi
569+}
570+
571+remove_apache_site() {
572+
573+ rst_title "Remove Apache site ${APACHE_SEARX_SITE}"
574+
575+ rst_para "\
576+This removes apache site ${APACHE_SEARX_SITE}."
577+
578+ ! apache_is_installed && err_msg "Apache is not installed."
579+
580+ if ! ask_yn "Do you really want to continue?"; then
581+ return
556582 fi
583+
584+ apache_remove_site "${APACHE_SEARX_SITE}"
557585}
558586
559587# ----------------------------------------------------------------------------
utils/templates/etc/apache2/sites-available/searx.conf:filtronnew file+3
@@ -0,0 +1,3 @@
1+# -*- coding: utf-8; mode: apache -*-
2+
3+ProxyPass "/searx" "http://127.0.0.1:4004/"