searx.sh 2.2 KB

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