generate: generate: Handle empty control scripts
When a given control script is empty, because the current config is missing a value for said script or is malformed, a script with only the shebang was written. Change it, so that it now executes true. Signed-off-by: Enno Tensing <tenno@suij.in>
This commit is contained in:
parent
ef63c0de14
commit
ff663f7835
1 changed files with 9 additions and 5 deletions
|
@ -98,13 +98,17 @@ def main() -> None:
|
||||||
Path(base).mkdir()
|
Path(base).mkdir()
|
||||||
for script, method in scripts.items():
|
for script, method in scripts.items():
|
||||||
s = Path(f"{base}/{script}")
|
s = Path(f"{base}/{script}")
|
||||||
|
script_content = ""
|
||||||
|
if script == "create":
|
||||||
|
script_content += ct.create_volumes()
|
||||||
|
script_content += ct.create_secrets()
|
||||||
|
script_content += ct.create_environment()
|
||||||
|
script_content += method()
|
||||||
|
if script_content == "":
|
||||||
|
script_content = "true"
|
||||||
with s.open("w+", encoding="utf-8") as f:
|
with s.open("w+", encoding="utf-8") as f:
|
||||||
f.write("#!/bin/sh\n")
|
f.write("#!/bin/sh\n")
|
||||||
if script == "create":
|
f.write(script_content)
|
||||||
f.write(ct.create_volumes())
|
|
||||||
f.write(ct.create_secrets())
|
|
||||||
f.write(ct.create_environment())
|
|
||||||
f.write(method())
|
|
||||||
s.chmod(
|
s.chmod(
|
||||||
stat.S_IRWXU
|
stat.S_IRWXU
|
||||||
| stat.S_IRGRP
|
| stat.S_IRGRP
|
||||||
|
|
Loading…
Add table
Reference in a new issue