21 lines
881 B
Python
21 lines
881 B
Python
#!/usr/bin/env python3
|
|
import uuid, hashlib, subprocess, sys
|
|
|
|
key = str(uuid.uuid4())
|
|
h = hashlib.sha256(key.encode()).hexdigest()
|
|
print(f"Key: {key}")
|
|
print(f"Hash: {h}")
|
|
|
|
# Delete old key
|
|
subprocess.run(["docker", "exec", "-i", "netbird-server", "sqlite3", "/var/lib/netbird/store.db",
|
|
"DELETE FROM setup_keys WHERE name = 'proxmox-lxc'"], check=True)
|
|
|
|
# Insert new key
|
|
sql = ("INSERT INTO setup_keys (id, account_id, key, key_secret, name, type, created_at, expires_at, "
|
|
"updated_at, revoked, used_times, usage_limit, ephemeral) "
|
|
f"VALUES ('{key}', 'd898edfkclh0009hc94g', '{key}', '{h}', 'proxmox-lxc', 'oneoff', "
|
|
"datetime('now'), datetime('now', '+10 years'), datetime('now'), 0, 0, 1, 0);")
|
|
subprocess.run(["docker", "exec", "-i", "netbird-server", "sqlite3", "/var/lib/netbird/store.db", sql], check=True)
|
|
print("DONE")
|
|
print(f"USE KEY: {key}")
|