Skip to content

Commit

Permalink
Fix: add missing VNC_PASS generation in draksetup init (#970)
Browse files Browse the repository at this point in the history
  • Loading branch information
psrok1 authored Sep 19, 2024
1 parent 4233e9a commit f69281a
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion drakrun/drakrun/draksetup/init.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import configparser
import logging
import secrets
import string
import sysconfig
from pathlib import Path
from typing import List, Optional
Expand Down Expand Up @@ -38,6 +40,14 @@ def create_configuration_file(config_file_name, target_dir=None):
return target_path


def set_template_vnc_password(template_path):
template_data = template_path.read_text()
passwd_characters = string.ascii_letters + string.digits
vnc_passwd = "".join(secrets.choice(passwd_characters) for _ in range(20))
template_data = template_data.replace("{{ VNC_PASS }}", vnc_passwd)
template_path.write_text(template_data)


def apply_local_minio_service_config(config: DrakrunConfig):
parser = configparser.ConfigParser(strict=False, allow_no_value=True)
minio_env = "[DEFAULT]\n" + MINIO_ENV_CONFIG_FILE.read_text()
Expand Down Expand Up @@ -226,7 +236,10 @@ def is_component_to_init(component_name):
create_configuration_file("hooks.txt")
create_configuration_file("[email protected]", target_dir=SYSTEMD_SERVICE_PATH)
fix_exec_start("[email protected]")
create_configuration_file("cfg.template", target_dir=ETC_SCRIPTS_DIR)
template_path = create_configuration_file(
"cfg.template", target_dir=ETC_SCRIPTS_DIR
)
set_template_vnc_password(template_path)

if is_component_to_init("system"):
create_configuration_file(
Expand Down

0 comments on commit f69281a

Please sign in to comment.