copied from internal repo

This commit is contained in:
Dragroth
2026-01-22 12:37:26 +01:00
parent a475364582
commit 7451b63f62
118 changed files with 17182 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
import os
import random
import string
from conpeek_setup import util
def generate_password(length=64, lowercase=True, uppercase=True, digits=True):
basic_characters = ""
if lowercase:
basic_characters += string.ascii_lowercase
if uppercase:
basic_characters += string.ascii_uppercase
if digits:
basic_characters += string.digits
if not lowercase and not uppercase and not digits:
util.print_red("Password must contain at least lowercase, uppercase or digits.")
password = ''.join(random.choices(basic_characters, k=length))
return password
def run(config):
output_directory = os.path.join(util.get_output_path(), "tokens")
os.makedirs(output_directory, exist_ok=True)
passwords = {
"system_token_secretkey": 64,
".erlang.cookie": 56,
}
for key in passwords.keys():
token_path = os.path.join(output_directory, key)
if not os.path.exists(token_path):
with open(token_path, "w") as file:
file.write(generate_password(length=passwords[key]))