searx.sh 2.2 KB

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