searx.sh 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  1. #!/usr/bin/env bash
  2. # -*- coding: utf-8; mode: sh indent-tabs-mode: nil -*-
  3. # SPDX-License-Identifier: AGPL-3.0-or-later
  4. # shellcheck disable=SC2001
  5. # shellcheck source=utils/lib.sh
  6. source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
  7. source_dot_config
  8. # ----------------------------------------------------------------------------
  9. # config
  10. # ----------------------------------------------------------------------------
  11. SEARX_INTERNAL_URL="${SEARX_INTERNAL_URL:-127.0.0.1:8888}"
  12. SEARX_URL_PATH="${SEARX_URL_PATH:-$(echo "${PUBLIC_URL}" \
  13. | sed -e 's,^.*://[^/]*\(/.*\),\1,g')}"
  14. [[ "${SEARX_URL_PATH}" == "${PUBLIC_URL}" ]] && SEARX_URL_PATH=/
  15. SEARX_INSTANCE_NAME="${SEARX_INSTANCE_NAME:-searx@$(echo "$PUBLIC_URL" \
  16. | sed -e 's,^.*://\([^\:/]*\).*,\1,g') }"
  17. SERVICE_NAME="searx"
  18. SERVICE_USER="${SERVICE_USER:-${SERVICE_NAME}}"
  19. SERVICE_HOME_BASE="${SERVICE_HOME_BASE:-/usr/local}"
  20. SERVICE_HOME="${SERVICE_HOME_BASE}/${SERVICE_USER}"
  21. # shellcheck disable=SC2034
  22. SERVICE_GROUP="${SERVICE_USER}"
  23. SEARX_GIT_URL="${SEARX_GIT_URL:-https://github.com/asciimoo/searx.git}"
  24. SEARX_GIT_BRANCH="${SEARX_GIT_BRANCH:-master}"
  25. SEARX_PYENV="${SERVICE_HOME}/searx-pyenv"
  26. SEARX_SRC="${SERVICE_HOME}/searx-src"
  27. SEARX_SETTINGS_PATH="/etc/searx/settings.yml"
  28. SEARX_UWSGI_APP="searx.ini"
  29. # shellcheck disable=SC2034
  30. SEARX_UWSGI_SOCKET="/run/uwsgi/app/searx/socket"
  31. case $DIST_ID in
  32. ubuntu|debian) # apt packages
  33. SEARX_PACKAGES="\
  34. python3-dev python3-babel python3-venv \
  35. uwsgi uwsgi-plugin-python3 \
  36. git build-essential libxslt-dev zlib1g-dev libffi-dev libssl-dev "
  37. ;;
  38. arch) # pacman packages
  39. SEARX_PACKAGES="\
  40. python python-pip python-lxml python-babel \
  41. uwsgi uwsgi-plugin-python \
  42. git base-devel libxml2 "
  43. ;;
  44. fedora) # dnf packages
  45. SEARX_PACKAGES="\
  46. python python-pip python-lxml python-babel \
  47. uwsgi uwsgi-plugin-python3 \
  48. git @development-tools libxml2 "
  49. ;;
  50. esac
  51. # Apache Settings
  52. APACHE_APT_PACKAGES="\
  53. libapache2-mod-uwsgi \
  54. "
  55. APACHE_SEARX_SITE="searx.conf"
  56. # shellcheck disable=SC2034
  57. CONFIG_FILES=(
  58. "${uWSGI_APPS_AVAILABLE}/${SEARX_UWSGI_APP}"
  59. )
  60. # shellcheck disable=SC2034
  61. CONFIG_BACKUP_ENCRYPTED=(
  62. "${SEARX_SETTINGS_PATH}"
  63. )
  64. # ----------------------------------------------------------------------------
  65. usage() {
  66. # ----------------------------------------------------------------------------
  67. # shellcheck disable=SC1117
  68. cat <<EOF
  69. usage::
  70. $(basename "$0") shell
  71. $(basename "$0") install [all|user|searx-src|pyenv|apache]
  72. $(basename "$0") update [searx]
  73. $(basename "$0") remove [all|user|pyenv|searx-src]
  74. $(basename "$0") activate [service]
  75. $(basename "$0") deactivate [service]
  76. $(basename "$0") inspect [service]
  77. $(basename "$0") option [debug-on|debug-off]
  78. $(basename "$0") apache [install|remove]
  79. shell
  80. start interactive shell from user ${SERVICE_USER}
  81. install / remove
  82. :all: complete (de-) installation of searx service
  83. :user: add/remove service user '$SERVICE_USER' ($SERVICE_HOME)
  84. :searx-src: clone $SEARX_GIT_URL
  85. :pyenv: create/remove virtualenv (python) in $SEARX_PYENV
  86. :settings: reinstall settings from ${REPO_ROOT}/searx/settings.yml
  87. update searx
  88. Update searx installation ($SERVICE_HOME)
  89. activate service
  90. activate and start service daemon (systemd unit)
  91. deactivate service
  92. stop and deactivate service daemon (systemd unit)
  93. inspect service
  94. run some small tests and inspect service's status and log
  95. option
  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}
  100. searx settings: ${SEARX_SETTINGS_PATH}
  101. If needed, set PUBLIC_URL of your WEB service in the '${DOT_CONFIG#"$REPO_ROOT/"}' file::
  102. PUBLIC_URL : ${PUBLIC_URL}
  103. PUBLIC_HOST : ${PUBLIC_HOST}
  104. SEARX_INSTANCE_NAME : ${SEARX_INSTANCE_NAME}
  105. SERVICE_USER : ${SERVICE_USER}
  106. EOF
  107. [[ -n ${1} ]] && err_msg "$1"
  108. }
  109. main() {
  110. rst_title "$SEARX_INSTANCE_NAME" part
  111. required_commands \
  112. sudo systemctl install git wget curl \
  113. || exit
  114. local _usage="unknown or missing $1 command $2"
  115. case $1 in
  116. --source-only) ;;
  117. -h|--help) usage; exit 0;;
  118. shell)
  119. sudo_or_exit
  120. interactive_shell "${SERVICE_USER}"
  121. ;;
  122. inspect)
  123. case $2 in
  124. service)
  125. sudo_or_exit
  126. inspect_service
  127. ;;
  128. *) usage "$_usage"; exit 42;;
  129. esac ;;
  130. install)
  131. sudo_or_exit
  132. case $2 in
  133. all) install_all ;;
  134. user) assert_user ;;
  135. pyenv) create_pyenv ;;
  136. searx-src) clone_searx ;;
  137. settings) install_settings ;;
  138. *) usage "$_usage"; exit 42;;
  139. esac ;;
  140. update)
  141. sudo_or_exit
  142. case $2 in
  143. searx) update_searx;;
  144. *) usage "$_usage"; exit 42;;
  145. esac ;;
  146. remove)
  147. sudo_or_exit
  148. case $2 in
  149. all) remove_all;;
  150. user) drop_service_account "${SERVICE_USER}";;
  151. pyenv) remove_pyenv ;;
  152. searx-src) remove_searx ;;
  153. *) usage "$_usage"; exit 42;;
  154. esac ;;
  155. activate)
  156. sudo_or_exit
  157. case $2 in
  158. service)
  159. activate_service ;;
  160. *) usage "$_usage"; exit 42;;
  161. esac ;;
  162. deactivate)
  163. sudo_or_exit
  164. case $2 in
  165. service) deactivate_service ;;
  166. *) usage "$_usage"; exit 42;;
  167. esac ;;
  168. option)
  169. sudo_or_exit
  170. case $2 in
  171. debug-on) echo; enable_debug ;;
  172. debug-off) echo; disable_debug ;;
  173. *) usage "$_usage"; exit 42;;
  174. esac ;;
  175. apache)
  176. sudo_or_exit
  177. case $2 in
  178. install) install_apache_site ;;
  179. remove) remove_apache_site ;;
  180. *) usage "$_usage"; exit 42;;
  181. esac ;;
  182. *) usage "unknown or missing command $1"; exit 42;;
  183. esac
  184. }
  185. _service_prefix=" ${_Yellow}|$SERVICE_USER|${_creset} "
  186. install_all() {
  187. rst_title "Install $SEARX_INSTANCE_NAME (service)"
  188. pkg_install "$SEARX_PACKAGES"
  189. wait_key
  190. assert_user
  191. wait_key
  192. clone_searx
  193. wait_key
  194. create_pyenv
  195. wait_key
  196. install_settings
  197. wait_key
  198. test_local_searx
  199. wait_key
  200. install_searx_uwsgi
  201. if ! service_is_available "http://$SEARX_INTERNAL_URL"; then
  202. err_msg "URL http://$SEARX_INTERNAL_URL not available, check searx & uwsgi setup!"
  203. fi
  204. if ask_yn "Do you want to inspect the installation?" Ny; then
  205. inspect_service
  206. fi
  207. }
  208. update_searx() {
  209. rst_title "Update searx instance"
  210. echo
  211. tee_stderr 0.3 <<EOF | sudo -H -u "${SERVICE_USER}" -i 2>&1 | prefix_stdout "$_service_prefix"
  212. cd ${SEARX_SRC}
  213. git checkout -B "$SEARX_GIT_BRANCH"
  214. git pull
  215. ${SEARX_SRC}/manage.sh update_packages
  216. EOF
  217. install_settings
  218. uWSGI_restart "$SEARX_UWSGI_APP"
  219. }
  220. remove_all() {
  221. rst_title "De-Install $SEARX_INSTANCE_NAME (service)"
  222. rst_para "\
  223. It goes without saying that this script can only be used to remove
  224. installations that were installed with this script."
  225. if ! ask_yn "Do you really want to deinstall $SEARX_INSTANCE_NAME?"; then
  226. return
  227. fi
  228. remove_searx_uwsgi
  229. drop_service_account "${SERVICE_USER}"
  230. remove_settings
  231. wait_key
  232. if service_is_available "${PUBLIC_URL}"; then
  233. MSG="** Don't forgett to remove your public site! (${PUBLIC_URL}) **" wait_key 10
  234. fi
  235. }
  236. assert_user() {
  237. rst_title "user $SERVICE_USER" section
  238. echo
  239. tee_stderr 1 <<EOF | bash | prefix_stdout
  240. useradd --shell /bin/bash --system \
  241. --home-dir "$SERVICE_HOME" \
  242. --comment 'Privacy-respecting metasearch engine' $SERVICE_USER
  243. mkdir "$SERVICE_HOME"
  244. chown -R "$SERVICE_GROUP:$SERVICE_GROUP" "$SERVICE_HOME"
  245. groups $SERVICE_USER
  246. EOF
  247. #SERVICE_HOME="$(sudo -i -u "$SERVICE_USER" echo \$HOME)"
  248. #export SERVICE_HOME
  249. #echo "export SERVICE_HOME=$SERVICE_HOME"
  250. }
  251. clone_is_available() {
  252. [[ -f "$SEARX_SRC/.git/config" ]]
  253. }
  254. # shellcheck disable=SC2164
  255. clone_searx() {
  256. rst_title "Clone searx sources" section
  257. echo
  258. SERVICE_HOME="$(sudo -i -u "$SERVICE_USER" echo \$HOME 2>/dev/null)"
  259. if [[ ! "${SERVICE_HOME}" ]]; then
  260. err_msg "to clone searx sources, user $SERVICE_USER hast to be created first"
  261. return 42
  262. fi
  263. export SERVICE_HOME
  264. git_clone "$REPO_ROOT" "$SEARX_SRC" \
  265. "$SEARX_GIT_BRANCH" "$SERVICE_USER"
  266. pushd "${SEARX_SRC}" > /dev/null
  267. tee_stderr 0.1 <<EOF | sudo -H -u "${SERVICE_USER}" -i 2>&1 | prefix_stdout "$_service_prefix"
  268. cd "${SEARX_SRC}"
  269. git remote set-url origin ${SEARX_GIT_URL}
  270. git config user.email "$ADMIN_EMAIL"
  271. git config user.name "$ADMIN_NAME"
  272. git config --list
  273. EOF
  274. popd > /dev/null
  275. }
  276. install_settings() {
  277. rst_title "${SEARX_SETTINGS_PATH}" section
  278. if ! clone_is_available; then
  279. err_msg "you have to install searx first"
  280. exit 42
  281. fi
  282. mkdir -p "$(dirname ${SEARX_SETTINGS_PATH})"
  283. if [[ ! -f ${SEARX_SETTINGS_PATH} ]]; then
  284. info_msg "install settings ${REPO_ROOT}/searx/settings.yml"
  285. info_msg " --> ${SEARX_SETTINGS_PATH}"
  286. cp "${REPO_ROOT}/searx/settings.yml" "${SEARX_SETTINGS_PATH}"
  287. configure_searx
  288. return
  289. fi
  290. rst_para "Diff between origin's setting file (+) and current (-):"
  291. echo
  292. $DIFF_CMD "${SEARX_SETTINGS_PATH}" "${SEARX_SRC}/searx/settings.yml"
  293. local action
  294. choose_one action "What should happen to the settings file? " \
  295. "keep configuration unchanged" \
  296. "use origin settings" \
  297. "start interactiv shell"
  298. case $action in
  299. "keep configuration unchanged")
  300. info_msg "leave settings file unchanged"
  301. ;;
  302. "use origin settings")
  303. backup_file "${SEARX_SETTINGS_PATH}"
  304. info_msg "install origin settings"
  305. cp "${SEARX_SRC}/searx/settings.yml" "${SEARX_SETTINGS_PATH}"
  306. ;;
  307. "start interactiv shell")
  308. backup_file "${SEARX_SETTINGS_PATH}"
  309. echo -e "// exit with [${_BCyan}CTRL-D${_creset}]"
  310. sudo -H -i
  311. rst_para 'Diff between new setting file (-) and current (+):'
  312. echo
  313. $DIFF_CMD "${SEARX_SRC}/searx/settings.yml" "${SEARX_SETTINGS_PATH}"
  314. wait_key
  315. ;;
  316. esac
  317. }
  318. remove_settings() {
  319. rst_title "remove searx settings" section
  320. echo
  321. info_msg "delete ${SEARX_SETTINGS_PATH}"
  322. rm -f "${SEARX_SETTINGS_PATH}"
  323. }
  324. remove_searx() {
  325. rst_title "Drop searx sources" section
  326. if ask_yn "Do you really want to drop searx sources ($SEARX_SRC)?"; then
  327. rm -rf "$SEARX_SRC"
  328. else
  329. rst_para "Leave searx sources unchanged."
  330. fi
  331. }
  332. pyenv_is_available() {
  333. [[ -f "${SEARX_PYENV}/bin/activate" ]]
  334. }
  335. create_pyenv() {
  336. rst_title "Create virtualenv (python)" section
  337. echo
  338. if [[ ! -f "${SEARX_SRC}/manage.sh" ]]; then
  339. err_msg "to create pyenv for searx, searx has to be cloned first"
  340. return 42
  341. fi
  342. info_msg "create pyenv in ${SEARX_PYENV}"
  343. tee_stderr 0.1 <<EOF | sudo -H -u "${SERVICE_USER}" -i 2>&1 | prefix_stdout "$_service_prefix"
  344. rm -rf "${SEARX_PYENV}"
  345. python3 -m venv "${SEARX_PYENV}"
  346. grep -qFs -- 'source ${SEARX_PYENV}/bin/activate' ~/.profile \
  347. || echo 'source ${SEARX_PYENV}/bin/activate' >> ~/.profile
  348. EOF
  349. info_msg "inspect python's virtual environment"
  350. tee_stderr 0.1 <<EOF | sudo -H -u "${SERVICE_USER}" -i 2>&1 | prefix_stdout "$_service_prefix"
  351. command -v python && python --version
  352. EOF
  353. wait_key
  354. info_msg "install needed python packages"
  355. tee_stderr 0.1 <<EOF | sudo -H -u "${SERVICE_USER}" -i 2>&1 | prefix_stdout "$_service_prefix"
  356. ${SEARX_SRC}/manage.sh update_packages
  357. EOF
  358. }
  359. remove_pyenv() {
  360. rst_title "Remove virtualenv (python)" section
  361. if ! ask_yn "Do you really want to drop ${SEARX_PYENV} ?"; then
  362. return
  363. fi
  364. info_msg "remove pyenv activation from ~/.profile"
  365. tee_stderr 0.1 <<EOF | sudo -H -u "${SERVICE_USER}" -i 2>&1 | prefix_stdout "$_service_prefix"
  366. grep -v 'source ${SEARX_PYENV}/bin/activate' ~/.profile > ~/.profile.##
  367. mv ~/.profile.## ~/.profile
  368. EOF
  369. rm -rf "${SEARX_PYENV}"
  370. }
  371. configure_searx() {
  372. rst_title "Configure searx" section
  373. rst_para "Setup searx config located at $SEARX_SETTINGS_PATH"
  374. echo
  375. tee_stderr 0.1 <<EOF | sudo -H -i 2>&1 | prefix_stdout "$_service_prefix"
  376. cd ${SEARX_SRC}
  377. sed -i -e "s/ultrasecretkey/$(openssl rand -hex 16)/g" "$SEARX_SETTINGS_PATH"
  378. sed -i -e "s/{instance_name}/${SEARX_INSTANCE_NAME}/g" "$SEARX_SETTINGS_PATH"
  379. EOF
  380. }
  381. test_local_searx() {
  382. rst_title "Testing searx instance localy" section
  383. echo
  384. if service_is_available "http://$SEARX_INTERNAL_URL" &>/dev/null; then
  385. err_msg "URL/port http://$SEARX_INTERNAL_URL is already in use, you"
  386. err_msg "should stop that service before starting local tests!"
  387. if ! ask_yn "Continue with local tests?"; then
  388. return
  389. fi
  390. fi
  391. sed -i -e "s/debug : False/debug : True/g" "$SEARX_SETTINGS_PATH"
  392. tee_stderr 0.1 <<EOF | sudo -H -u "${SERVICE_USER}" -i 2>&1 | prefix_stdout "$_service_prefix"
  393. export SEARX_SETTINGS_PATH="${SEARX_SETTINGS_PATH}"
  394. cd ${SEARX_SRC}
  395. timeout 10 python3 searx/webapp.py &
  396. sleep 3
  397. curl --location --verbose --head --insecure $SEARX_INTERNAL_URL
  398. EOF
  399. sed -i -e "s/debug : True/debug : False/g" "$SEARX_SETTINGS_PATH"
  400. }
  401. install_searx_uwsgi() {
  402. rst_title "Install searx's uWSGI app (searx.ini)" section
  403. echo
  404. uWSGI_install_app "$SEARX_UWSGI_APP"
  405. }
  406. remove_searx_uwsgi() {
  407. rst_title "Remove searx's uWSGI app (searx.ini)" section
  408. echo
  409. uWSGI_remove_app "$SEARX_UWSGI_APP"
  410. }
  411. activate_service() {
  412. rst_title "Activate $SEARX_INSTANCE_NAME (service)" section
  413. echo
  414. uWSGI_enable_app "$SEARX_UWSGI_APP"
  415. uWSGI_restart "$SEARX_UWSGI_APP"
  416. }
  417. deactivate_service() {
  418. rst_title "De-Activate $SEARX_INSTANCE_NAME (service)" section
  419. echo
  420. uWSGI_disable_app "$SEARX_UWSGI_APP"
  421. uWSGI_restart "$SEARX_UWSGI_APP"
  422. }
  423. enable_debug() {
  424. warn_msg "Do not enable debug in production enviroments!!"
  425. info_msg "try to enable debug mode ..."
  426. tee_stderr 0.1 <<EOF | sudo -H -i 2>&1 | prefix_stdout "$_service_prefix"
  427. cd ${SEARX_SRC}
  428. sed -i -e "s/debug : False/debug : True/g" "$SEARX_SETTINGS_PATH"
  429. EOF
  430. uWSGI_restart "$SEARX_UWSGI_APP"
  431. }
  432. disable_debug() {
  433. info_msg "try to disable debug mode ..."
  434. tee_stderr 0.1 <<EOF | sudo -H -i 2>&1 | prefix_stdout "$_service_prefix"
  435. cd ${SEARX_SRC}
  436. sed -i -e "s/debug : True/debug : False/g" "$SEARX_SETTINGS_PATH"
  437. EOF
  438. uWSGI_restart "$SEARX_UWSGI_APP"
  439. }
  440. inspect_service() {
  441. rst_title "service status & log"
  442. cat <<EOF
  443. sourced ${DOT_CONFIG#"$REPO_ROOT/"} :
  444. PUBLIC_URL : ${PUBLIC_URL}
  445. PUBLIC_HOST : ${PUBLIC_HOST}
  446. SEARX_URL_PATH : ${SEARX_URL_PATH}
  447. SEARX_INSTANCE_NAME : ${SEARX_INSTANCE_NAME}
  448. SEARX_INTERNAL_URL : ${SEARX_INTERNAL_URL}
  449. EOF
  450. apache_is_installed && info_msg "Apache is installed."
  451. if service_account_is_available "$SERVICE_USER"; then
  452. info_msg "Service account $SERVICE_USER exists."
  453. else
  454. err_msg "Service account $SERVICE_USER does not exists!"
  455. fi
  456. if pyenv_is_available; then
  457. info_msg "~$SERVICE_USER: python environment is available."
  458. else
  459. err_msg "~$SERVICE_USER: python environment is not available!"
  460. fi
  461. if clone_is_available; then
  462. info_msg "~$SERVICE_USER: Searx software is installed."
  463. else
  464. err_msg "~$SERVICE_USER: Missing searx software!"
  465. fi
  466. if uWSGI_app_enabled "$SEARX_UWSGI_APP"; then
  467. info_msg "uWSGI app $SEARX_UWSGI_APP is enabled."
  468. else
  469. err_msg "uWSGI app $SEARX_UWSGI_APP not enabled!"
  470. fi
  471. uWSGI_app_available "$SEARX_UWSGI_APP" \
  472. || err_msg "uWSGI app $SEARX_UWSGI_APP not available!"
  473. if is_container; then
  474. warn_msg "runnning inside container ..."
  475. for ip in $(hostname -I); do
  476. if [[ $ip =~ .*:.* ]]; then
  477. info_msg " public HTTP service (IPv6) --> http://[$ip]"
  478. else
  479. info_msg " public HTTP service (IPv4) --> http://$ip"
  480. fi
  481. done
  482. warn_msg "SEARX_INTERNAL_URL not available from outside"
  483. fi
  484. if ! service_is_available "http://${SEARX_INTERNAL_URL}"; then
  485. err_msg "uWSGI app (service) at http://${SEARX_INTERNAL_URL} is not available!"
  486. echo -e "${_Green}stop with [${_BCyan}CTRL-C${_Green}] or .."
  487. wait_key
  488. fi
  489. if ! service_is_available "${PUBLIC_URL}"; then
  490. warn_msg "Public service at ${PUBLIC_URL} is not available!"
  491. if is_container; then
  492. warn_msg "Check if public name is correct and routed or use the public IP from above."
  493. fi
  494. fi
  495. local _debug_on
  496. if ask_yn "Enable searx debug mode?"; then
  497. enable_debug
  498. _debug_on=1
  499. fi
  500. echo
  501. systemctl --no-pager -l status "${SERVICE_NAME}"
  502. echo
  503. info_msg "public URL --> ${PUBLIC_URL}"
  504. info_msg "internal URL --> http://${SEARX_INTERNAL_URL}"
  505. # shellcheck disable=SC2059
  506. printf "// use ${_BCyan}CTRL-C${_creset} to stop monitoring the log"
  507. read -r -s -n1 -t 2
  508. echo
  509. while true; do
  510. trap break 2
  511. #journalctl -f -u "${SERVICE_NAME}"
  512. tail -f /var/log/uwsgi/app/searx.log
  513. done
  514. if [[ $_debug_on == 1 ]]; then
  515. disable_debug
  516. fi
  517. return 0
  518. }
  519. install_apache_site() {
  520. rst_title "Install Apache site $APACHE_SEARX_SITE"
  521. rst_para "\
  522. This installs the searx uwsgi app as apache site. If your server ist public to
  523. the internet you should instead use a reverse proxy (filtron) to block
  524. excessively bot queries."
  525. ! apache_is_installed && err_msg "Apache is not installed."
  526. if ! ask_yn "Do you really want to install apache site for searx-uwsgi?"; then
  527. return
  528. fi
  529. pkg_install "$APACHE_APT_PACKAGES"
  530. a2enmod uwsgi
  531. echo
  532. apache_install_site --variant=uwsgi "${APACHE_SEARX_SITE}"
  533. if ! service_is_available "${PUBLIC_URL}"; then
  534. err_msg "Public service at ${PUBLIC_URL} is not available!"
  535. fi
  536. }
  537. remove_apache_site() {
  538. rst_title "Remove Apache site ${APACHE_SEARX_SITE}"
  539. rst_para "\
  540. This removes apache site ${APACHE_SEARX_SITE}."
  541. ! apache_is_installed && err_msg "Apache is not installed."
  542. if ! ask_yn "Do you really want to continue?"; then
  543. return
  544. fi
  545. apache_remove_site "${APACHE_SEARX_SITE}"
  546. }
  547. # ----------------------------------------------------------------------------
  548. main "$@"
  549. # ----------------------------------------------------------------------------