on master help sign in
filtron.sh & morty.sh: improve usage message (if used in containers)

BTW: normalize soma variable names Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>

commitc81849cb5a22d937c0f1de1d02d1fb8e3a7849cd authorMarkus Heiser <markus.heiser@darmarit.de> dateSun 5 Apr 2020, 17:40 (7 years ago) parentc2caf95
5 files changed+72−49
utils/filtron.sh+12−3 utils/morty.sh+25−22 utils/searx.sh+33−22 utils/templates/etc/uwsgi/apps-archlinux/searx.ini+1−1 utils/templates/etc/uwsgi/apps-available/searx.ini+1−1
utils/filtron.sh+12−3
@@ -97,15 +97,24 @@ apache (${PUBLIC_URL})
9797filtron rules: ${FILTRON_RULES}
9898
9999If needed, set PUBLIC_URL of your WEB service in the '${DOT_CONFIG#"$REPO_ROOT/"}' file::
100−
101100 PUBLIC_URL : ${PUBLIC_URL}
102101 PUBLIC_HOST : ${PUBLIC_HOST}
103102 SERVICE_USER : ${SERVICE_USER}
103+ FILTRON_TARGET : ${FILTRON_TARGET}
104104 FILTRON_API : ${FILTRON_API}
105105 FILTRON_LISTEN : ${FILTRON_LISTEN}
106− FILTRON_TARGET : ${FILTRON_TARGET}
107−
108106EOF
107+ if in_container; then
108+ # in containers the service is listening on 0.0.0.0 (see lxc-searx.env)
109+ for ip in $(global_IPs) ; do
110+ if [[ $ip =~ .*:.* ]]; then
111+ echo " container URL (IPv6): http://[${ip#*|}]:4005/"
112+ else
113+ # IPv4:
114+ echo " container URL (IPv4): http://${ip#*|}:4005/"
115+ fi
116+ done
117+ fi
109118 [[ -n ${1} ]] && err_msg "$1"
110119}
111120
utils/morty.sh+25−22
@@ -83,39 +83,37 @@ apache : ${PUBLIC_URL_MORTY}
8383 :install: apache site with a reverse proxy (ProxyPass)
8484 :remove: apache site ${APACHE_MORTY_SITE}
8585
86−If needed, set the environment variable MORTY_LISTEN in the
87−${DOT_CONFIG#"$REPO_ROOT/"} file::
88−
89− MORTY_LISTEN : ${MORTY_LISTEN}
90− SERVICE_USER : ${SERVICE_USER}
91−
86+If needed, set the environment variables in the '${DOT_CONFIG#"$REPO_ROOT/"}' file::
87+ PUBLIC_URL_MORTY: ${PUBLIC_URL_MORTY}
88+ MORTY_LISTEN: ${MORTY_LISTEN}
89+ SERVICE_USER: ${SERVICE_USER}
9290EOF
9391 if in_container; then
94− lxc_suite_info
95− else
96− info_msg "public URL --> ${PUBLIC_URL}"
97− info_msg "internal URL --> http://${SEARX_INTERNAL_URL}"
92+ # in containers the service is listening on 0.0.0.0 (see lxc-searx.env)
93+ for ip in $(global_IPs) ; do
94+ if [[ $ip =~ .*:.* ]]; then
95+ echo " container URL (IPv6): http://[${ip#*|}]:3000/"
96+ else
97+ # IPv4:
98+ echo " container URL (IPv4): http://${ip#*|}:3000/"
99+ fi
100+ done
98101 fi
102+ echo
99103 info_searx
104+
100105 [[ -n ${1} ]] && err_msg "$1"
101106}
102107
103108info_searx() {
104109 # shellcheck disable=SC1117
105110 cat <<EOF
106−
107−To activate morty in searx, add result_proxy to your settings.yml::
108−
111+To activate result and image proxy in searx, edit settings.yml (read:
112+${DOCS_URL}/admin/morty.html)::
109113 result_proxy:
110− url : ${PUBLIC_URL_MORTY}/
111−
114+ url : ${PUBLIC_URL_MORTY}
112115 server:
113− ...
114− image_proxy : True # Proxying image results through searx
115− ...
116−
117−further read: ${DOCS_URL}/admin/morty.html
118−
116+ image_proxy : True
119117EOF
120118}
121119
@@ -210,7 +208,6 @@ install_all() {
210208 wait_key
211209 systemd_install_service "${SERVICE_NAME}" "${SERVICE_SYSTEMD_UNIT}"
212210 wait_key
213− info_searx
214211 if ! service_is_available "http://${MORTY_LISTEN}" ; then
215212 err_msg "Morty does not listening on: http://${MORTY_LISTEN}"
216213 fi
@@ -220,6 +217,12 @@ install_all() {
220217 install_apache_site
221218 fi
222219 fi
220+ info_searx
221+ if ask_yn "Add image and result proxy to searx settings.yml?" Yn; then
222+ "${REPO_ROOT}/utils/searx.sh" option result-proxy "${PUBLIC_URL_MORTY}"
223+ "${REPO_ROOT}/utils/searx.sh" option image-proxy-on
224+ fi
225+
223226 if ask_yn "Do you want to inspect the installation?" Ny; then
224227 inspect_service
225228 fi
utils/searx.sh+33−22
@@ -17,7 +17,7 @@ in_container && lxc_set_suite_env
1717
1818PUBLIC_URL="${PUBLIC_URL:-http://$(uname -n)/searx}"
1919
20−SEARX_INTERNAL_URL="${SEARX_INTERNAL_URL:-127.0.0.1:8888}"
20+SEARX_INTERNAL_HTTP="${SEARX_INTERNAL_HTTP:-127.0.0.1:8888}"
2121
2222SEARX_URL_PATH="${SEARX_URL_PATH:-$(echo "${PUBLIC_URL}" \
2323| sed -e 's,^.*://[^/]*\(/.*\),\1,g')}"
@@ -79,17 +79,17 @@ case $DIST_ID in
7979 ubuntu|debian)
8080 SEARX_PACKAGES="${SEARX_PACKAGES_debian}"
8181 BUILD_PACKAGES="${BUILD_PACKAGES_debian}"
82− APACHE_APT_PACKAGES="libapache2-mod-uwsgi"
82+ APACHE_PACKAGES="libapache2-mod-uwsgi"
8383 ;;
8484 arch)
8585 SEARX_PACKAGES="${SEARX_PACKAGES_arch}"
8686 BUILD_PACKAGES="${BUILD_PACKAGES_arch}"
87− APACHE_APT_PACKAGES="uwsgi"
87+ APACHE_PACKAGES="uwsgi"
8888 ;;
8989 fedora)
9090 SEARX_PACKAGES="${SEARX_PACKAGES_fedora}"
9191 BUILD_PACKAGES="${BUILD_PACKAGES_fedora}"
92− APACHE_APT_PACKAGES="uwsgi"
92+ APACHE_PACKAGES="uwsgi"
9393 ;;
9494esac
9595
@@ -116,13 +116,13 @@ usage() {
116116usage::
117117
118118 $(basename "$0") shell
119− $(basename "$0") install [all|user|searx-src|pyenv|uwsgi|apache|packages|buildhost]
119+ $(basename "$0") install [all|user|searx-src|pyenv|uwsgi|packages|buildhost]
120120 $(basename "$0") update [searx]
121121 $(basename "$0") remove [all|user|pyenv|searx-src]
122122 $(basename "$0") activate [service]
123123 $(basename "$0") deactivate [service]
124124 $(basename "$0") inspect [service]
125− $(basename "$0") option [debug-on|debug-off]
125+ $(basename "$0") option [debug-[on|off]|image-proxy-[on|off]|result-proxy <url> <key>]
126126 $(basename "$0") apache [install|remove]
127127
128128shell
@@ -153,12 +153,25 @@ apache
153153searx settings: ${SEARX_SETTINGS_PATH}
154154
155155If needed, set PUBLIC_URL of your WEB service in the '${DOT_CONFIG#"$REPO_ROOT/"}' file::
156−
157156 PUBLIC_URL : ${PUBLIC_URL}
158157 SEARX_INSTANCE_NAME : ${SEARX_INSTANCE_NAME}
159158 SERVICE_USER : ${SERVICE_USER}
160−
159+ SEARX_INTERNAL_HTTP : http://${SEARX_INTERNAL_HTTP}
161160EOF
161+ if in_container; then
162+ # searx is listening on 127.0.0.1 and not available from outside container
163+ # in containers the service is listening on 0.0.0.0 (see lxc-searx.env)
164+ echo -e "${_BBlack}HINT:${_creset} searx only listen on loopback device" \
165+ "${_BBlack}inside${_creset} the container."
166+ for ip in $(global_IPs) ; do
167+ if [[ $ip =~ .*:.* ]]; then
168+ echo " container (IPv6): [${ip#*|}]"
169+ else
170+ # IPv4:
171+ echo " container (IPv4): ${ip#*|}"
172+ fi
173+ done
174+ fi
162175 [[ -n ${1} ]] && err_msg "$1"
163176}
164177
@@ -277,8 +290,8 @@ install_all() {
277290 test_local_searx
278291 wait_key
279292 install_searx_uwsgi
280− if ! service_is_available "http://$SEARX_INTERNAL_URL"; then
281− err_msg "URL http://$SEARX_INTERNAL_URL not available, check searx & uwsgi setup!"
293+ if ! service_is_available "http://${SEARX_INTERNAL_HTTP}"; then
294+ err_msg "URL http://${SEARX_INTERNAL_HTTP} not available, check searx & uwsgi setup!"
282295 fi
283296 if ask_yn "Do you want to inspect the installation?" Ny; then
284297 inspect_service
@@ -481,8 +494,8 @@ test_local_searx() {
481494 rst_title "Testing searx instance localy" section
482495 echo
483496
484− if service_is_available "http://$SEARX_INTERNAL_URL" &>/dev/null; then
485− err_msg "URL/port http://$SEARX_INTERNAL_URL is already in use, you"
497+ if service_is_available "http://${SEARX_INTERNAL_HTTP}" &>/dev/null; then
498+ err_msg "URL/port http://${SEARX_INTERNAL_HTTP} is already in use, you"
486499 err_msg "should stop that service before starting local tests!"
487500 if ! ask_yn "Continue with local tests?"; then
488501 return
@@ -494,7 +507,7 @@ export SEARX_SETTINGS_PATH="${SEARX_SETTINGS_PATH}"
494507cd ${SEARX_SRC}
495508timeout 10 python searx/webapp.py &
496509sleep 3
497−curl --location --verbose --head --insecure $SEARX_INTERNAL_URL
510+curl --location --verbose --head --insecure $SEARX_INTERNAL_HTTP
498511EOF
499512 sed -i -e "s/debug : True/debug : False/g" "$SEARX_SETTINGS_PATH"
500513}
@@ -624,12 +637,10 @@ sourced ${DOT_CONFIG#"$REPO_ROOT/"} :
624637 PUBLIC_URL : ${PUBLIC_URL}
625638 SEARX_URL_PATH : ${SEARX_URL_PATH}
626639 SEARX_INSTANCE_NAME : ${SEARX_INSTANCE_NAME}
627− SEARX_INTERNAL_URL : ${SEARX_INTERNAL_URL}
640+ SEARX_INTERNAL_HTTP : ${SEARX_INTERNAL_HTTP}
628641
629642EOF
630643
631− apache_is_installed && info_msg "Apache is installed."
632−
633644 if service_account_is_available "$SERVICE_USER"; then
634645 info_msg "Service account $SERVICE_USER exists."
635646 else
@@ -661,11 +672,11 @@ EOF
661672 lxc_suite_info
662673 else
663674 info_msg "public URL --> ${PUBLIC_URL}"
664− info_msg "internal URL --> http://${SEARX_INTERNAL_URL}"
675+ info_msg "internal URL --> http://${SEARX_INTERNAL_HTTP}"
665676 fi
666677
667− if ! service_is_available "http://${SEARX_INTERNAL_URL}"; then
668− err_msg "uWSGI app (service) at http://${SEARX_INTERNAL_URL} is not available!"
678+ if ! service_is_available "http://${SEARX_INTERNAL_HTTP}"; then
679+ err_msg "uWSGI app (service) at http://${SEARX_INTERNAL_HTTP} is not available!"
669680 MSG="${_Green}[${_BCyan}CTRL-C${_Green}] to stop or [${_BCyan}KEY${_Green}] to continue"\
670681 wait_key
671682 fi
@@ -720,8 +731,8 @@ install_apache_site() {
720731 rst_title "Install Apache site $APACHE_SEARX_SITE"
721732
722733 rst_para "\
723−This installs the searx uwsgi app as apache site. If your server ist public to
724−the internet you should instead use a reverse proxy (filtron) to block
734+This installs the searx uwsgi app as apache site. If your server is public to
735+the internet, you should instead use a reverse proxy (filtron) to block
725736excessively bot queries."
726737
727738 ! apache_is_installed && err_msg "Apache is not installed."
@@ -730,7 +741,7 @@ excessively bot queries."
730741 return
731742 fi
732743
733− pkg_install "$APACHE_APT_PACKAGES"
744+ pkg_install "$APACHE_PACKAGES"
734745 a2enmod uwsgi
735746
736747 echo
utils/templates/etc/uwsgi/apps-archlinux/searx.ini+1−1
@@ -68,7 +68,7 @@ pythonpath = ${SEARX_SRC}
6868# https://uwsgi-docs.readthedocs.io/en/latest/Options.html#plugin-http
6969# Native HTTP support: https://uwsgi-docs.readthedocs.io/en/latest/HTTP.html
7070
71−http = ${SEARX_INTERNAL_URL}
71+http = ${SEARX_INTERNAL_HTTP}
7272
7373# using unix-sockets:
7474#
utils/templates/etc/uwsgi/apps-available/searx.ini+1−1
@@ -67,7 +67,7 @@ pythonpath = ${SEARX_SRC}
6767# https://uwsgi-docs.readthedocs.io/en/latest/Options.html#plugin-http
6868# Native HTTP support: https://uwsgi-docs.readthedocs.io/en/latest/HTTP.html
6969
70−http = ${SEARX_INTERNAL_URL}
70+http = ${SEARX_INTERNAL_HTTP}
7171
7272# using unix-sockets:
7373#