2020-01-14 19:26:54 +01:00
|
|
|
#!/usr/bin/env bash
|
2020-01-27 19:08:40 +01:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
2020-01-29 20:00:50 +01:00
|
|
|
# shellcheck disable=SC2001
|
2020-01-14 19:26:54 +01:00
|
|
|
|
|
|
|
# shellcheck source=utils/lib.sh
|
|
|
|
source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
|
2021-06-29 19:01:07 +02:00
|
|
|
|
2020-01-14 19:26:54 +01:00
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
# config
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
2022-07-30 16:13:47 +02:00
|
|
|
PUBLIC_URL="${PUBLIC_URL:-${SEARXNG_URL}}"
|
|
|
|
|
2020-02-02 18:14:10 +01:00
|
|
|
SERVICE_NAME="searx"
|
|
|
|
SERVICE_USER="${SERVICE_USER:-${SERVICE_NAME}}"
|
2022-06-16 16:30:18 +02:00
|
|
|
SEARXNG_SETTINGS_PATH="/etc/searx/settings.yml"
|
|
|
|
SEARXNG_UWSGI_APP="searx.ini"
|
2020-01-14 19:26:54 +01:00
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
2020-01-20 16:55:05 +01:00
|
|
|
usage() {
|
2020-01-14 19:26:54 +01:00
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
# shellcheck disable=SC1117
|
|
|
|
cat <<EOF
|
2020-02-02 18:14:10 +01:00
|
|
|
usage::
|
2022-06-16 16:30:18 +02:00
|
|
|
$(basename "$0") remove all
|
2020-01-14 19:26:54 +01:00
|
|
|
|
2022-06-16 16:30:18 +02:00
|
|
|
remove all: complete uninstall of SearXNG service
|
2022-07-30 16:13:47 +02:00
|
|
|
|
|
|
|
environment:
|
|
|
|
PUBLIC_URL : ${PUBLIC_URL}
|
2020-01-14 19:26:54 +01:00
|
|
|
EOF
|
2021-06-29 19:01:07 +02:00
|
|
|
|
2020-02-16 20:07:37 +01:00
|
|
|
[[ -n ${1} ]] && err_msg "$1"
|
2020-01-14 19:26:54 +01:00
|
|
|
}
|
|
|
|
|
2020-01-20 16:55:05 +01:00
|
|
|
main() {
|
2020-01-29 20:00:50 +01:00
|
|
|
|
2020-02-04 17:59:58 +01:00
|
|
|
local _usage="unknown or missing $1 command $2"
|
2020-01-14 19:26:54 +01:00
|
|
|
|
|
|
|
case $1 in
|
|
|
|
remove)
|
2021-06-29 19:01:07 +02:00
|
|
|
rst_title "SearXNG (remove)" part
|
2020-01-14 19:26:54 +01:00
|
|
|
sudo_or_exit
|
|
|
|
case $2 in
|
|
|
|
all) remove_all;;
|
|
|
|
*) usage "$_usage"; exit 42;;
|
|
|
|
esac ;;
|
2020-02-04 17:59:58 +01:00
|
|
|
*) usage "unknown or missing command $1"; exit 42;;
|
2020-01-14 19:26:54 +01:00
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
remove_all() {
|
2021-06-29 19:01:07 +02:00
|
|
|
rst_title "De-Install SearXNG (service)"
|
2020-01-21 18:38:57 +01:00
|
|
|
|
|
|
|
rst_para "\
|
|
|
|
It goes without saying that this script can only be used to remove
|
|
|
|
installations that were installed with this script."
|
|
|
|
|
2021-06-29 19:01:07 +02:00
|
|
|
if ! ask_yn "Do you really want to deinstall SearXNG?"; then
|
2020-01-16 14:01:38 +01:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
remove_searx_uwsgi
|
2020-02-01 16:59:27 +01:00
|
|
|
drop_service_account "${SERVICE_USER}"
|
2020-02-17 18:58:59 +01:00
|
|
|
remove_settings
|
|
|
|
wait_key
|
2020-01-30 19:55:51 +01:00
|
|
|
if service_is_available "${PUBLIC_URL}"; then
|
2023-08-11 16:01:54 +02:00
|
|
|
MSG="** Don't forget to remove your public site! (${PUBLIC_URL}) **" wait_key 10
|
2020-01-30 19:55:51 +01:00
|
|
|
fi
|
2020-01-14 19:26:54 +01:00
|
|
|
}
|
|
|
|
|
2020-02-17 18:58:59 +01:00
|
|
|
remove_settings() {
|
2021-07-12 15:31:42 +02:00
|
|
|
rst_title "remove SearXNG settings" section
|
2020-02-17 18:58:59 +01:00
|
|
|
echo
|
2021-10-02 17:18:05 +02:00
|
|
|
info_msg "delete ${SEARXNG_SETTINGS_PATH}"
|
|
|
|
rm -f "${SEARXNG_SETTINGS_PATH}"
|
2020-02-17 18:58:59 +01:00
|
|
|
}
|
|
|
|
|
2020-01-14 19:26:54 +01:00
|
|
|
remove_searx_uwsgi() {
|
2021-10-11 21:20:22 +02:00
|
|
|
rst_title "Remove SearXNG's uWSGI app (searxng.ini)" section
|
2020-01-14 19:26:54 +01:00
|
|
|
echo
|
2021-10-11 21:20:22 +02:00
|
|
|
uWSGI_remove_app "$SEARXNG_UWSGI_APP"
|
2020-01-14 19:26:54 +01:00
|
|
|
}
|
|
|
|
|
2020-03-02 19:00:19 +01:00
|
|
|
|
2020-01-14 19:26:54 +01:00
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
main "$@"
|
|
|
|
# ----------------------------------------------------------------------------
|