2026-07-07 23:43:16 +03:00

25 lines
739 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
"""setup_keyring.py — одноразово кладёт secret и static в keyring из env."""
import os
import sys
import keyring
SERVICE = "openvpn-totp"
def main():
secret = os.environ.get("OVPN_TOTP_SECRET")
static = os.environ.get("OVPN_STATIC_PASS")
missing = [name for name, val in
(("OVPN_TOTP_SECRET", secret), ("OVPN_STATIC_PASS", static))
if not val]
if missing:
sys.exit(f"Не заданы переменные окружения: {', '.join(missing)}")
keyring.set_password(SERVICE, "secret", secret)
keyring.set_password(SERVICE, "static", static)
print("Сохранено в keyring.")
if __name__ == "__main__":
main()