searx.sh 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  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=" |$SERVICE_USER| "
  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?" Yn; 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_SRC}/searx/settings.yml" "${SEARX_SETTINGS_PATH}"
  293. local action
  294. choose_one action "What should happen to the settings file? " \
  295. "keep new configuration" \
  296. "start interactiv shell"
  297. case $action in
  298. "keep new configuration")
  299. info_msg "continue using new settings file"
  300. ;;
  301. "start interactiv shell")
  302. echo -e "// exit with [${_BCyan}CTRL-D${_creset}]"
  303. sudo -H -i
  304. rst_para 'Diff between new setting file (-) and current (+):'
  305. echo
  306. $DIFF_CMD "${SEARX_SRC}/searx/settings.yml" "${SEARX_SETTINGS_PATH}"
  307. wait_key
  308. ;;
  309. esac
  310. }
  311. remove_settings() {
  312. rst_title "remove searx settings" section
  313. echo
  314. info_msg "delete ${SEARX_SETTINGS_PATH}"
  315. rm -f "${SEARX_SETTINGS_PATH}"
  316. }
  317. remove_searx() {
  318. rst_title "Drop searx sources" section
  319. if ask_yn "Do you really want to drop searx sources ($SEARX_SRC)?"; then
  320. rm -rf "$SEARX_SRC"
  321. else
  322. rst_para "Leave searx sources unchanged."
  323. fi
  324. }
  325. pyenv_is_available() {
  326. [[ -f "${SEARX_PYENV}/bin/activate" ]]
  327. }
  328. create_pyenv() {
  329. rst_title "Create virtualenv (python)" section
  330. echo
  331. if [[ ! -f "${SEARX_SRC}/manage.sh" ]]; then
  332. err_msg "to create pyenv for searx, searx has to be cloned first"
  333. return 42
  334. fi
  335. info_msg "create pyenv in ${SEARX_PYENV}"
  336. tee_stderr 0.1 <<EOF | sudo -H -u "${SERVICE_USER}" -i 2>&1 | prefix_stdout "$_service_prefix"
  337. rm -rf "${SEARX_PYENV}"
  338. python3 -m venv "${SEARX_PYENV}"
  339. grep -qFs -- 'source ${SEARX_PYENV}/bin/activate' ~/.profile \
  340. || echo 'source ${SEARX_PYENV}/bin/activate' >> ~/.profile
  341. EOF
  342. info_msg "inspect python's virtual environment"
  343. tee_stderr 0.1 <<EOF | sudo -H -u "${SERVICE_USER}" -i 2>&1 | prefix_stdout "$_service_prefix"
  344. command -v python && python --version
  345. EOF
  346. wait_key
  347. info_msg "install needed python packages"
  348. tee_stderr 0.1 <<EOF | sudo -H -u "${SERVICE_USER}" -i 2>&1 | prefix_stdout "$_service_prefix"
  349. ${SEARX_SRC}/manage.sh update_packages
  350. EOF
  351. }
  352. remove_pyenv() {
  353. rst_title "Remove virtualenv (python)" section
  354. if ! ask_yn "Do you really want to drop ${SEARX_PYENV} ?"; then
  355. return
  356. fi
  357. info_msg "remove pyenv activation from ~/.profile"
  358. tee_stderr 0.1 <<EOF | sudo -H -u "${SERVICE_USER}" -i 2>&1 | prefix_stdout "$_service_prefix"
  359. grep -v 'source ${SEARX_PYENV}/bin/activate' ~/.profile > ~/.profile.##
  360. mv ~/.profile.## ~/.profile
  361. EOF
  362. rm -rf "${SEARX_PYENV}"
  363. }
  364. configure_searx() {
  365. rst_title "Configure searx" section
  366. rst_para "Setup searx config located at $SEARX_SETTINGS_PATH"
  367. echo
  368. tee_stderr 0.1 <<EOF | sudo -H -i 2>&1 | prefix_stdout "$_service_prefix"
  369. cd ${SEARX_SRC}
  370. sed -i -e "s/ultrasecretkey/$(openssl rand -hex 16)/g" "$SEARX_SETTINGS_PATH"
  371. sed -i -e "s/{instance_name}/${SEARX_INSTANCE_NAME}/g" "$SEARX_SETTINGS_PATH"
  372. EOF
  373. }
  374. test_local_searx() {
  375. rst_title "Testing searx instance localy" section
  376. echo
  377. if service_is_available "http://$SEARX_INTERNAL_URL" &>/dev/null; then
  378. err_msg "URL/port http://$SEARX_INTERNAL_URL is already in use, you"
  379. err_msg "should stop that service before starting local tests!"
  380. if ! ask_yn "Continue with local tests?"; then
  381. return
  382. fi
  383. fi
  384. sed -i -e "s/debug : False/debug : True/g" "$SEARX_SETTINGS_PATH"
  385. tee_stderr 0.1 <<EOF | sudo -H -u "${SERVICE_USER}" -i 2>&1 | prefix_stdout "$_service_prefix"
  386. export SEARX_SETTINGS_PATH="${SEARX_SETTINGS_PATH}"
  387. cd ${SEARX_SRC}
  388. timeout 10 python3 searx/webapp.py &
  389. sleep 3
  390. curl --location --verbose --head --insecure $SEARX_INTERNAL_URL
  391. EOF
  392. sed -i -e "s/debug : True/debug : False/g" "$SEARX_SETTINGS_PATH"
  393. }
  394. install_searx_uwsgi() {
  395. rst_title "Install searx's uWSGI app (searx.ini)" section
  396. echo
  397. uWSGI_install_app "$SEARX_UWSGI_APP"
  398. }
  399. remove_searx_uwsgi() {
  400. rst_title "Remove searx's uWSGI app (searx.ini)" section
  401. echo
  402. uWSGI_remove_app "$SEARX_UWSGI_APP"
  403. }
  404. activate_service() {
  405. rst_title "Activate $SEARX_INSTANCE_NAME (service)" section
  406. echo
  407. uWSGI_enable_app "$SEARX_UWSGI_APP"
  408. uWSGI_restart "$SEARX_UWSGI_APP"
  409. }
  410. deactivate_service() {
  411. rst_title "De-Activate $SEARX_INSTANCE_NAME (service)" section
  412. echo
  413. uWSGI_disable_app "$SEARX_UWSGI_APP"
  414. uWSGI_restart "$SEARX_UWSGI_APP"
  415. }
  416. enable_debug() {
  417. warn_msg "Do not enable debug in production enviroments!!"
  418. info_msg "try to enable debug mode ..."
  419. tee_stderr 0.1 <<EOF | sudo -H -i 2>&1 | prefix_stdout "$_service_prefix"
  420. cd ${SEARX_SRC}
  421. sed -i -e "s/debug : False/debug : True/g" "$SEARX_SETTINGS_PATH"
  422. EOF
  423. uWSGI_restart "$SEARX_UWSGI_APP"
  424. }
  425. disable_debug() {
  426. info_msg "try to disable debug mode ..."
  427. tee_stderr 0.1 <<EOF | sudo -H -i 2>&1 | prefix_stdout "$_service_prefix"
  428. cd ${SEARX_SRC}
  429. sed -i -e "s/debug : True/debug : False/g" "$SEARX_SETTINGS_PATH"
  430. EOF
  431. uWSGI_restart "$SEARX_UWSGI_APP"
  432. }
  433. inspect_service() {
  434. rst_title "service status & log"
  435. cat <<EOF
  436. sourced ${DOT_CONFIG#"$REPO_ROOT/"} :
  437. PUBLIC_URL : ${PUBLIC_URL}
  438. PUBLIC_HOST : ${PUBLIC_HOST}
  439. SEARX_URL_PATH : ${SEARX_URL_PATH}
  440. SEARX_INSTANCE_NAME : ${SEARX_INSTANCE_NAME}
  441. SEARX_INTERNAL_URL : ${SEARX_INTERNAL_URL}
  442. EOF
  443. apache_is_installed && info_msg "Apache is installed."
  444. if service_account_is_available "$SERVICE_USER"; then
  445. info_msg "Service account $SERVICE_USER exists."
  446. else
  447. err_msg "Service account $SERVICE_USER does not exists!"
  448. fi
  449. if pyenv_is_available; then
  450. info_msg "~$SERVICE_USER: python environment is available."
  451. else
  452. err_msg "~$SERVICE_USER: python environment is not available!"
  453. fi
  454. if clone_is_available; then
  455. info_msg "~$SERVICE_USER: Searx software is installed."
  456. else
  457. err_msg "~$SERVICE_USER: Missing searx software!"
  458. fi
  459. if uWSGI_app_enabled "$SEARX_UWSGI_APP"; then
  460. info_msg "uWSGI app $SEARX_UWSGI_APP is enabled."
  461. else
  462. err_msg "uWSGI app $SEARX_UWSGI_APP not enabled!"
  463. fi
  464. uWSGI_app_available "$SEARX_UWSGI_APP" \
  465. || err_msg "uWSGI app $SEARX_UWSGI_APP not available!"
  466. if ! service_is_available "http://${SEARX_INTERNAL_URL}"; then
  467. err_msg "uWSGI app (service) at http://${SEARX_INTERNAL_URL} is not available!"
  468. echo -e "${_Green}stop with [${_BCyan}CTRL-C${_Green}] or .."
  469. wait_key
  470. fi
  471. if ! service_is_available "${PUBLIC_URL}"; then
  472. warn_msg "Public service at ${PUBLIC_URL} is not available!"
  473. fi
  474. local _debug_on
  475. if ask_yn "Enable searx debug mode?"; then
  476. enable_debug
  477. _debug_on=1
  478. fi
  479. echo
  480. systemctl --no-pager -l status "${SERVICE_NAME}"
  481. echo
  482. info_msg "public URL --> ${PUBLIC_URL}"
  483. info_msg "internal URL --> http://${SEARX_INTERNAL_URL}"
  484. # shellcheck disable=SC2059
  485. printf "// use ${_BCyan}CTRL-C${_creset} to stop monitoring the log"
  486. read -r -s -n1 -t 2
  487. echo
  488. while true; do
  489. trap break 2
  490. #journalctl -f -u "${SERVICE_NAME}"
  491. tail -f /var/log/uwsgi/app/searx.log
  492. done
  493. if [[ $_debug_on == 1 ]]; then
  494. disable_debug
  495. fi
  496. return 0
  497. }
  498. install_apache_site() {
  499. rst_title "Install Apache site $APACHE_SEARX_SITE"
  500. rst_para "\
  501. This installs the searx uwsgi app as apache site. If your server ist public to
  502. the internet you should instead use a reverse proxy (filtron) to block
  503. excessively bot queries."
  504. ! apache_is_installed && err_msg "Apache is not installed."
  505. if ! ask_yn "Do you really want to install apache site for searx-uwsgi?"; then
  506. return
  507. fi
  508. pkg_install "$APACHE_APT_PACKAGES"
  509. a2enmod uwsgi
  510. echo
  511. apache_install_site --variant=uwsgi "${APACHE_SEARX_SITE}"
  512. if ! service_is_available "${PUBLIC_URL}"; then
  513. err_msg "Public service at ${PUBLIC_URL} is not available!"
  514. fi
  515. }
  516. remove_apache_site() {
  517. rst_title "Remove Apache site ${APACHE_SEARX_SITE}"
  518. rst_para "\
  519. This removes apache site ${APACHE_SEARX_SITE}."
  520. ! apache_is_installed && err_msg "Apache is not installed."
  521. if ! ask_yn "Do you really want to continue?"; then
  522. return
  523. fi
  524. apache_remove_site "${APACHE_SEARX_SITE}"
  525. }
  526. # ----------------------------------------------------------------------------
  527. main "$@"
  528. # ----------------------------------------------------------------------------