diff options
Diffstat (limited to 'misc/searxng.py')
-rw-r--r-- | misc/searxng.py | 28 |
1 files changed, 28 insertions, 0 deletions
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"])) |