From 8cf813ff033bbc98a7dd40db6ac11e2e35c7e997 Mon Sep 17 00:00:00 2001 From: mia Date: Sat, 8 Jun 2024 22:56:05 -0700 Subject: initial commit --- misc/searxng.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 misc/searxng.py (limited to 'misc/searxng.py') diff --git a/misc/searxng.py b/misc/searxng.py new file mode 100644 index 0000000..db56c21 --- /dev/null +++ b/misc/searxng.py @@ -0,0 +1,28 @@ +import random +import string + +from commia.bearer import get_key, has_key, keys, set_key +from commia.prelude import * +from commia.ssh import ssh_args, ssh_opt_args, ssh_prewarm +from commia.util import with_written + +ssh_prewarm("asylum", "secrets@bearer") + +if not has_key(keys.searxng.secret_key): + print("initializing secret key") + key = "" + for _ in range(64): + key += random.choice(string.ascii_letters + string.digits + "-_=+") + set_key(keys.searxng.secret_key, key) + +secret_key = get_key(keys.searxng.secret_key) +searxng_conf = Path("misc/searxng.yml").read_text().replace("%SECRET_KEY%", secret_key) + +with_written( + searxng_conf, + lambda path: run_sc( + ["scp", *ssh_opt_args(), path, "asylum:/etc/searxng/settings.yml"] + ), +) + +run_check(p([*ssh_args(), "systemctl", "restart", "searxng"])) -- cgit 1.4.1