diff options
author | mia <mia@mia.jetzt> | 2024-06-08 22:56:05 -0700 |
---|---|---|
committer | mia <mia@mia.jetzt> | 2024-06-08 22:56:05 -0700 |
commit | 8cf813ff033bbc98a7dd40db6ac11e2e35c7e997 (patch) | |
tree | a451059194cbd4ba90993ebdaced4749448ec4df /misc/searxng.py | |
download | asylum-8cf813ff033bbc98a7dd40db6ac11e2e35c7e997.tar.gz asylum-8cf813ff033bbc98a7dd40db6ac11e2e35c7e997.zip |
initial commit
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"])) |