searx.sh 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #!/usr/bin/env bash
  2. # SPDX-License-Identifier: AGPL-3.0-or-later
  3. # shellcheck disable=SC2001
  4. # shellcheck source=utils/lib.sh
  5. source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
  6. # shellcheck source=utils/brand.env
  7. source "${REPO_ROOT}/utils/brand.env"
  8. # ----------------------------------------------------------------------------
  9. # config
  10. # ----------------------------------------------------------------------------
  11. PUBLIC_URL="${PUBLIC_URL:-${SEARXNG_URL}}"
  12. SERVICE_NAME="searx"
  13. SERVICE_USER="${SERVICE_USER:-${SERVICE_NAME}}"
  14. SEARXNG_SETTINGS_PATH="/etc/searx/settings.yml"
  15. SEARXNG_UWSGI_APP="searx.ini"
  16. # ----------------------------------------------------------------------------
  17. usage() {
  18. # ----------------------------------------------------------------------------
  19. # shellcheck disable=SC1117
  20. cat <<EOF
  21. usage::
  22. $(basename "$0") remove all
  23. remove all: complete uninstall of SearXNG service
  24. environment:
  25. PUBLIC_URL : ${PUBLIC_URL}
  26. EOF
  27. [[ -n ${1} ]] && err_msg "$1"
  28. }
  29. main() {
  30. local _usage="unknown or missing $1 command $2"
  31. case $1 in
  32. remove)
  33. rst_title "SearXNG (remove)" part
  34. sudo_or_exit
  35. case $2 in
  36. all) remove_all;;
  37. *) usage "$_usage"; exit 42;;
  38. esac ;;
  39. *) usage "unknown or missing command $1"; exit 42;;
  40. esac
  41. }
  42. remove_all() {
  43. rst_title "De-Install SearXNG (service)"
  44. rst_para "\
  45. It goes without saying that this script can only be used to remove
  46. installations that were installed with this script."
  47. if ! ask_yn "Do you really want to deinstall SearXNG?"; then
  48. return
  49. fi
  50. remove_searx_uwsgi
  51. drop_service_account "${SERVICE_USER}"
  52. remove_settings
  53. wait_key
  54. if service_is_available "${PUBLIC_URL}"; then
  55. MSG="** Don't forgett to remove your public site! (${PUBLIC_URL}) **" wait_key 10
  56. fi
  57. }
  58. remove_settings() {
  59. rst_title "remove SearXNG settings" section
  60. echo
  61. info_msg "delete ${SEARXNG_SETTINGS_PATH}"
  62. rm -f "${SEARXNG_SETTINGS_PATH}"
  63. }
  64. remove_searx_uwsgi() {
  65. rst_title "Remove SearXNG's uWSGI app (searxng.ini)" section
  66. echo
  67. uWSGI_remove_app "$SEARXNG_UWSGI_APP"
  68. }
  69. # ----------------------------------------------------------------------------
  70. main "$@"
  71. # ----------------------------------------------------------------------------