on master help sign in
LXC: install searx-suite installs searx, filtron & morty on all containers

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

commitaf6acd3417bf53c151b9ba6068186c1e472a2776 authorMarkus Heiser <markus.heiser@darmarit.de> dateWed 26 Feb 2020, 19:07 (7 years ago) parentd5917cc
6 files changed+74−20
utils/filtron.sh+1−2 utils/lib.sh+9 utils/lxc.sh+48−7 utils/morty.sh+2−1 utils/searx.sh+13−9 utils/templates/etc/uwsgi/apps-archlinux/searx.ini+1−1
utils/filtron.sh+1−2
@@ -204,7 +204,7 @@ install_all() {
204204 install_apache_site
205205 fi
206206 fi
207− if ask_yn "Do you want to inspect the installation?" Yn; then
207+ if ask_yn "Do you want to inspect the installation?" Ny; then
208208 inspect_service
209209 fi
210210
@@ -253,7 +253,6 @@ grep -qFs -- 'source $GO_ENV' ~/.profile || echo 'source $GO_ENV' >> ~/.profile
253253EOF
254254}
255255
256−
257256filtron_is_installed() {
258257 [[ -f $SERVICE_HOME/go-apps/bin/filtron ]]
259258}
utils/lib.sh+9
@@ -290,6 +290,15 @@ cache_download() {
290290 fi
291291}
292292
293+backup_file() {
294+
295+ # usage: backup_file /path/to/file.foo
296+
297+ local stamp=$(date +"_%Y%m%d_%H%M%S")
298+ info_msg "create backup: ${1}${stamp}"
299+ cp -a "${1}" "${1}${stamp}"
300+}
301+
293302choose_one() {
294303
295304 # usage:
utils/lxc.sh+48−7
@@ -19,6 +19,7 @@ HOST_PREFIX="${HOST_PREFIX:-searx}"
1919
2020# where all folders from HOST are mounted
2121LXC_SHARE_FOLDER="/share"
22+LXC_REPO_ROOT="${LXC_SHARE_FOLDER}/$(basename "${REPO_ROOT}")"
2223
2324TEST_IMAGES=(
2425 "$LINUXCONTAINERS_ORG_NAME:ubuntu/18.04" "ubu1804"
@@ -71,6 +72,7 @@ usage() {
7172usage::
7273
7374 $(basename "$0") build [containers]
75+ $(basename "$0") install [searx-suite]
7476 $(basename "$0") remove [containers|subordinate]
7577 $(basename "$0") [start|stop] [containers]
7678 $(basename "$0") inspect [info|config]
@@ -87,6 +89,8 @@ inspect
8789 :config: show config of all containers
8890cmd ...
8991 run commandline ... in all containers
92+install
93+ :searx-suite: install searx suite, includes morty & filtron
9094
9195all LXC containers:
9296 ${LOCAL_IMAGES[@]}
@@ -110,14 +114,24 @@ EOF
110114main() {
111115
112116 local exit_val
113−
114− if ! required_commands lxc; then
115− lxd_info
116− exit 42
117− fi
118−
119117 local _usage="unknown or missing $1 command $2"
120118
119+ case $1 in
120+ __install)
121+ sudo_or_exit
122+ case $2 in
123+ searx-suite) install_searx_suite ;;
124+ esac
125+ exit
126+ ;;
127+ *)
128+ if ! required_commands lxc; then
129+ lxd_info
130+ exit 42
131+ fi
132+ ;;
133+ esac
134+
121135 case $1 in
122136 --source-only) ;;
123137 -h|--help) usage; exit 0;;
@@ -161,6 +175,7 @@ main() {
161175 sudo_or_exit
162176 shift
163177 for i in "${LOCAL_IMAGES[@]}"; do
178+ exit_val=
164179 info_msg "[${_BBlue}${i}${_creset}] ${_BGreen}${*}${_creset}"
165180 lxc exec "${i}" -- "$@"
166181 exit_val=$?
@@ -171,11 +186,37 @@ main() {
171186 fi
172187 done
173188 ;;
189+ install)
190+ sudo_or_exit
191+ case $2 in
192+ searx-suite)
193+ for i in "${LOCAL_IMAGES[@]}"; do
194+ info_msg "[${_BBlue}${i}${_creset}] ${_BGreen}${LXC_REPO_ROOT}/utils/lxc.sh install $2${_creset}"
195+ lxc exec "${i}" -- "${LXC_REPO_ROOT}/utils/lxc.sh" __install "$2"
196+ done
197+ ;;
198+ *) usage "$_usage"; exit 42;;
199+ esac ;;
174200 *)
175201 usage "unknown or missing command $1"; exit 42;;
176202 esac
177203}
178204
205+install_searx_suite() {
206+ export FILTRON_API="0.0.0.0:4005"
207+ export FILTRON_LISTEN="0.0.0.0:4004"
208+ export MORTY_LISTEN="0.0.0.0:3000"
209+ FORCE_TIMEOUT=0 "${LXC_REPO_ROOT}/utils/searx.sh" install all
210+ FORCE_TIMEOUT=0 "${LXC_REPO_ROOT}/utils/morty.sh" install all
211+ FORCE_TIMEOUT=0 "${LXC_REPO_ROOT}/utils/filtron.sh" install all
212+ rst_title "[$(hostname)] searx-suite installation finished" part
213+ rst_para "IPs of the container ..."
214+ echo
215+ ip addr show | grep "inet\s*[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*"
216+ echo
217+}
218+
219+
179220build_instances() {
180221 rst_title "Build LXC instances"
181222
@@ -271,7 +312,7 @@ lxc_config_containers() {
271312 # https://lxd.readthedocs.io/en/latest/instances/#type-disk
272313 lxc config device add "$i" repo_share disk \
273314 source="${REPO_ROOT}" \
274− path="${LXC_SHARE_FOLDER}/$(basename "${REPO_ROOT}")" &>/dev/null
315+ path="${LXC_REPO_ROOT}" &>/dev/null
275316 # lxc config show "$i" && wait_key
276317 done
277318}
utils/morty.sh+2−1
@@ -207,7 +207,7 @@ install_all() {
207207 install_apache_site
208208 fi
209209 fi
210− if ask_yn "Do you want to inspect the installation?" Yn; then
210+ if ask_yn "Do you want to inspect the installation?" Ny; then
211211 inspect_service
212212 fi
213213
@@ -408,6 +408,7 @@ This removes apache site ${APACHE_MORTY_SITE}."
408408
409409 apache_remove_site "$APACHE_MORTY_SITE"
410410}
411+
411412# ----------------------------------------------------------------------------
412413main "$@"
413414# ----------------------------------------------------------------------------
utils/searx.sh+13−9
@@ -43,9 +43,6 @@ case $DIST_ID in
4343 git build-essential libxslt-dev zlib1g-dev libffi-dev libssl-dev "
4444 ;;
4545 arch) # pacman packages
46− # FIXME:
47− # - /usr/lib/uwsgi/http_plugin.so: cannot open shared object file: No such file or directory !!!
48− # - /usr/lib/uwsgi/systemd_logger_plugin.so: cannot open shared object file: No such file or directory !!!
4946 SEARX_PACKAGES="\
5047 python python-pip python-lxml python-babel \
5148 uwsgi uwsgi-plugin-python \
@@ -233,7 +230,7 @@ install_all() {
233230 if ! service_is_available "http://$SEARX_INTERNAL_URL"; then
234231 err_msg "URL http://$SEARX_INTERNAL_URL not available, check searx & uwsgi setup!"
235232 fi
236− if ask_yn "Do you want to inspect the installation?" Yn; then
233+ if ask_yn "Do you want to inspect the installation?" Ny; then
237234 inspect_service
238235 fi
239236}
@@ -331,19 +328,26 @@ install_settings() {
331328 return
332329 fi
333330
334− rst_para "Diff between origin's setting file (-) and current (+):"
331+ rst_para "Diff between origin's setting file (+) and current (-):"
335332 echo
336− $DIFF_CMD "${SEARX_SRC}/searx/settings.yml" "${SEARX_SETTINGS_PATH}"
333+ $DIFF_CMD "${SEARX_SETTINGS_PATH}" "${SEARX_SRC}/searx/settings.yml"
337334
338335 local action
339336 choose_one action "What should happen to the settings file? " \
340− "keep new configuration" \
337+ "keep configuration unchanged" \
338+ "use origin settings" \
341339 "start interactiv shell"
342340 case $action in
343− "keep new configuration")
344− info_msg "continue using new settings file"
341+ "keep configuration unchanged")
342+ info_msg "leave settings file unchanged"
343+ ;;
344+ "use origin settings")
345+ backup_file "${SEARX_SETTINGS_PATH}"
346+ info_msg "install origin settings"
347+ cp "${SEARX_SRC}/searx/settings.yml" "${SEARX_SETTINGS_PATH}"
345348 ;;
346349 "start interactiv shell")
350+ backup_file "${SEARX_SETTINGS_PATH}"
347351 echo -e "// exit with [${_BCyan}CTRL-D${_creset}]"
348352 sudo -H -i
349353 rst_para 'Diff between new setting file (-) and current (+):'
utils/templates/etc/uwsgi/apps-archlinux/searx.ini+1−1
@@ -32,7 +32,7 @@ master = true
3232lazy-apps = true
3333
3434# load uWSGI plugins
35−plugin = python,http,systemd_logger
35+plugin = python
3636
3737# By default the Python plugin does not initialize the GIL. This means your
3838# app-generated threads will not run. If you need threads, remember to enable