From 8829796f76bc74c584db1d2a83553ac0611372a0 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Tue, 28 Apr 2020 16:54:42 +0200 Subject: [PATCH] utils/morty.sh option new-key: set new morty key A command to set new morty key in morty & searx service (settings.yml) and to restart both services with new key:: utils/morty.sh option new-key Signed-off-by: Markus Heiser --- utils/morty.sh | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/utils/morty.sh b/utils/morty.sh index 6b90db581..75bfeeedf 100755 --- a/utils/morty.sh +++ b/utils/morty.sh @@ -59,7 +59,7 @@ usage:: $(basename "$0") activate [service] $(basename "$0") deactivate [service] $(basename "$0") inspect [service] - $(basename "$0") option [debug-on|debug-off] + $(basename "$0") option [debug-on|debug-off|new-key] $(basename "$0") apache [install|remove] $(basename "$0") nginx [install|remove] $(basename "$0") info [searx] @@ -79,6 +79,7 @@ inspect service show service status and log option set one of the available options + :new-key: set new morty key apache : ${PUBLIC_URL_MORTY} :install: apache site with a reverse proxy (ProxyPass) :remove: apache site ${APACHE_MORTY_SITE} @@ -198,6 +199,7 @@ main() { option) sudo_or_exit case $2 in + new-key) set_new_key ;; debug-on) enable_debug ;; debug-off) disable_debug ;; *) usage "$_usage"; exit 42;; @@ -410,6 +412,23 @@ disable_debug() { set_service_env_debug false } + +set_new_key() { + rst_title "Set morty key" + echo + + MORTY_KEY="$(head -c 32 /dev/urandom | base64)" + info_msg "morty key: '${MORTY_KEY}'" + + warn_msg "this will need to reinstall services .." + MSG="${_Green}press any [${_BCyan}KEY${_Green}] to continue // stop with [${_BCyan}CTRL-C${_creset}]" wait_key + + systemd_install_service "${SERVICE_NAME}" "${SERVICE_SYSTEMD_UNIT}" + "${REPO_ROOT}/utils/searx.sh" option result-proxy "${PUBLIC_URL_MORTY}" "${MORTY_KEY}" + "${REPO_ROOT}/utils/searx.sh" option image-proxy-on +} + + install_apache_site() { rst_title "Install Apache site $APACHE_MORTY_SITE"