on master help sign in
LXC: install searx-suite installs searx, filtron & morty on all containers
af6acd3Markus Heiser
utils/filtron.sh+1−2
@@ -204,7 +204,7 @@ install_all() {
204 install_apache_site
204 install_apache_site
205 fi
205 fi
206 fi
206 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
208 inspect_service
208 inspect_service
209 fi
209 fi
210
210
@@ -253,7 +253,6 @@ grep -qFs -- 'source $GO_ENV' ~/.profile || echo 'source $GO_ENV' >> ~/.profile
253EOF
253EOF
254}
254}
255
255
256−
257filtron_is_installed() {
256filtron_is_installed() {
258 [[ -f $SERVICE_HOME/go-apps/bin/filtron ]]
257 [[ -f $SERVICE_HOME/go-apps/bin/filtron ]]
259}
258}
utils/lib.sh+9
@@ -290,6 +290,15 @@ cache_download() {
290 fi
290 fi
291}
291}
292
292
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+
293choose_one() {
302choose_one() {
294
303
295 # usage:
304 # usage:
utils/lxc.sh+48−7
@@ -19,6 +19,7 @@ HOST_PREFIX="${HOST_PREFIX:-searx}"
19
19
20# where all folders from HOST are mounted
20# where all folders from HOST are mounted
21LXC_SHARE_FOLDER="/share"
21LXC_SHARE_FOLDER="/share"
22+LXC_REPO_ROOT="${LXC_SHARE_FOLDER}/$(basename "${REPO_ROOT}")"
22
23
23TEST_IMAGES=(
24TEST_IMAGES=(
24 "$LINUXCONTAINERS_ORG_NAME:ubuntu/18.04" "ubu1804"
25 "$LINUXCONTAINERS_ORG_NAME:ubuntu/18.04" "ubu1804"
@@ -71,6 +72,7 @@ usage() {
71usage::
72usage::
72
73
73 $(basename "$0") build [containers]
74 $(basename "$0") build [containers]
75+ $(basename "$0") install [searx-suite]
74 $(basename "$0") remove [containers|subordinate]
76 $(basename "$0") remove [containers|subordinate]
75 $(basename "$0") [start|stop] [containers]
77 $(basename "$0") [start|stop] [containers]
76 $(basename "$0") inspect [info|config]
78 $(basename "$0") inspect [info|config]
@@ -87,6 +89,8 @@ inspect
87 :config: show config of all containers
89 :config: show config of all containers
88cmd ...
90cmd ...
89 run commandline ... in all containers
91 run commandline ... in all containers
92+install
93+ :searx-suite: install searx suite, includes morty & filtron
90
94
91all LXC containers:
95all LXC containers:
92 ${LOCAL_IMAGES[@]}
96 ${LOCAL_IMAGES[@]}
@@ -110,14 +114,24 @@ EOF
110main() {
114main() {
111
115
112 local exit_val
116 local exit_val
113−
114− if ! required_commands lxc; then
115− lxd_info
116− exit 42
117− fi
118−
119 local _usage="unknown or missing $1 command $2"
117 local _usage="unknown or missing $1 command $2"
120
118
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+
121 case $1 in
135 case $1 in
122 --source-only) ;;
136 --source-only) ;;
123 -h|--help) usage; exit 0;;
137 -h|--help) usage; exit 0;;
@@ -161,6 +175,7 @@ main() {
161 sudo_or_exit
175 sudo_or_exit
162 shift
176 shift
163 for i in "${LOCAL_IMAGES[@]}"; do
177 for i in "${LOCAL_IMAGES[@]}"; do
178+ exit_val=
164 info_msg "[${_BBlue}${i}${_creset}] ${_BGreen}${*}${_creset}"
179 info_msg "[${_BBlue}${i}${_creset}] ${_BGreen}${*}${_creset}"
165 lxc exec "${i}" -- "$@"
180 lxc exec "${i}" -- "$@"
166 exit_val=$?
181 exit_val=$?
@@ -171,11 +186,37 @@ main() {
171 fi
186 fi
172 done
187 done
173 ;;
188 ;;
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 ;;
174 *)
200 *)
175 usage "unknown or missing command $1"; exit 42;;
201 usage "unknown or missing command $1"; exit 42;;
176 esac
202 esac
177}
203}
178
204
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+
179build_instances() {
220build_instances() {
180 rst_title "Build LXC instances"
221 rst_title "Build LXC instances"
181
222
@@ -271,7 +312,7 @@ lxc_config_containers() {
271 # https://lxd.readthedocs.io/en/latest/instances/#type-disk
312 # https://lxd.readthedocs.io/en/latest/instances/#type-disk
272 lxc config device add "$i" repo_share disk \
313 lxc config device add "$i" repo_share disk \
273 source="${REPO_ROOT}" \
314 source="${REPO_ROOT}" \
274− path="${LXC_SHARE_FOLDER}/$(basename "${REPO_ROOT}")" &>/dev/null
315+ path="${LXC_REPO_ROOT}" &>/dev/null
275 # lxc config show "$i" && wait_key
316 # lxc config show "$i" && wait_key
276 done
317 done
277}
318}
utils/morty.sh+2−1
@@ -207,7 +207,7 @@ install_all() {
207 install_apache_site
207 install_apache_site
208 fi
208 fi
209 fi
209 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
211 inspect_service
211 inspect_service
212 fi
212 fi
213
213
@@ -408,6 +408,7 @@ This removes apache site ${APACHE_MORTY_SITE}."
408
408
409 apache_remove_site "$APACHE_MORTY_SITE"
409 apache_remove_site "$APACHE_MORTY_SITE"
410}
410}
411+
411# ----------------------------------------------------------------------------
412# ----------------------------------------------------------------------------
412main "$@"
413main "$@"
413# ----------------------------------------------------------------------------
414# ----------------------------------------------------------------------------
utils/searx.sh+13−9
@@ -43,9 +43,6 @@ case $DIST_ID in
43 git build-essential libxslt-dev zlib1g-dev libffi-dev libssl-dev "
43 git build-essential libxslt-dev zlib1g-dev libffi-dev libssl-dev "
44 ;;
44 ;;
45 arch) # pacman packages
45 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 !!!
49 SEARX_PACKAGES="\
46 SEARX_PACKAGES="\
50 python python-pip python-lxml python-babel \
47 python python-pip python-lxml python-babel \
51 uwsgi uwsgi-plugin-python \
48 uwsgi uwsgi-plugin-python \
@@ -233,7 +230,7 @@ install_all() {
233 if ! service_is_available "http://$SEARX_INTERNAL_URL"; then
230 if ! service_is_available "http://$SEARX_INTERNAL_URL"; then
234 err_msg "URL http://$SEARX_INTERNAL_URL not available, check searx & uwsgi setup!"
231 err_msg "URL http://$SEARX_INTERNAL_URL not available, check searx & uwsgi setup!"
235 fi
232 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
237 inspect_service
234 inspect_service
238 fi
235 fi
239}
236}
@@ -331,19 +328,26 @@ install_settings() {
331 return
328 return
332 fi
329 fi
333
330
334− rst_para "Diff between origin's setting file (-) and current (+):"
331+ rst_para "Diff between origin's setting file (+) and current (-):"
335 echo
332 echo
336− $DIFF_CMD "${SEARX_SRC}/searx/settings.yml" "${SEARX_SETTINGS_PATH}"
333+ $DIFF_CMD "${SEARX_SETTINGS_PATH}" "${SEARX_SRC}/searx/settings.yml"
337
334
338 local action
335 local action
339 choose_one action "What should happen to the settings file? " \
336 choose_one action "What should happen to the settings file? " \
340− "keep new configuration" \
337+ "keep configuration unchanged" \
338+ "use origin settings" \
341 "start interactiv shell"
339 "start interactiv shell"
342 case $action in
340 case $action in
343− "keep new configuration")
341+ "keep configuration unchanged")
344− info_msg "continue using new settings file"
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}"
345 ;;
348 ;;
346 "start interactiv shell")
349 "start interactiv shell")
350+ backup_file "${SEARX_SETTINGS_PATH}"
347 echo -e "// exit with [${_BCyan}CTRL-D${_creset}]"
351 echo -e "// exit with [${_BCyan}CTRL-D${_creset}]"
348 sudo -H -i
352 sudo -H -i
349 rst_para 'Diff between new setting file (-) and current (+):'
353 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
32lazy-apps = true
32lazy-apps = true
33
33
34# load uWSGI plugins
34# load uWSGI plugins
35−plugin = python,http,systemd_logger
35+plugin = python
36
36
37# By default the Python plugin does not initialize the GIL. This means your
37# By default the Python plugin does not initialize the GIL. This means your
38# app-generated threads will not run. If you need threads, remember to enable
38# app-generated threads will not run. If you need threads, remember to enable