searx.sh 18 KB

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