Fix firstboot tls bundle script and prep checks
This commit is contained in:
@@ -215,11 +215,11 @@ if isinstance(actions, list) and actions:
|
||||
log(f"TLS bundle skipped (missing cert/key): {dest}")
|
||||
continue
|
||||
dest.parent.mkdir(parents=True, exist_ok=True)
|
||||
content = src_cert.read_bytes() + b\"\\n\" + src_key.read_bytes() + b\"\\n\"
|
||||
content = src_cert.read_bytes() + b"\n" + src_key.read_bytes() + b"\n"
|
||||
dest.write_bytes(content)
|
||||
owner = action.get("owner")
|
||||
if owner:
|
||||
user, _, group = str(owner).partition(\":\")
|
||||
user, _, group = str(owner).partition(":")
|
||||
try:
|
||||
uid = pwd.getpwnam(user).pw_uid if user else -1
|
||||
except Exception:
|
||||
@@ -238,8 +238,8 @@ if isinstance(actions, list) and actions:
|
||||
pass
|
||||
restart = action.get("restart")
|
||||
if restart:
|
||||
subprocess.run([\"systemctl\", \"restart\", str(restart)], check=False)
|
||||
log(f\"TLS bundle written: {dest}\")
|
||||
subprocess.run(["systemctl", "restart", str(restart)], check=False)
|
||||
log(f"TLS bundle written: {dest}")
|
||||
continue
|
||||
|
||||
if action_type == "replace_text":
|
||||
@@ -247,17 +247,17 @@ if isinstance(actions, list) and actions:
|
||||
match = str(action.get("match", ""))
|
||||
replacement = str(action.get("replace", ""))
|
||||
if not file_path.exists():
|
||||
log(f\"Replace skipped (missing file): {file_path}\")
|
||||
log(f"Replace skipped (missing file): {file_path}")
|
||||
continue
|
||||
content = file_path.read_text()
|
||||
if match not in content:
|
||||
log(f\"Replace skipped (pattern not found): {file_path}\")
|
||||
log(f"Replace skipped (pattern not found): {file_path}")
|
||||
continue
|
||||
file_path.write_text(content.replace(match, replacement, 1))
|
||||
restart = action.get("restart")
|
||||
if restart:
|
||||
subprocess.run([\"systemctl\", \"restart\", str(restart)], check=False)
|
||||
log(f\"Replaced text in: {file_path}\")
|
||||
subprocess.run(["systemctl", "restart", str(restart)], check=False)
|
||||
log(f"Replaced text in: {file_path}")
|
||||
continue
|
||||
else:
|
||||
log("Profile actions step skipped (none).")
|
||||
|
||||
Reference in New Issue
Block a user