mirror of
https://git.nolog.cz/NoLog.cz/nginx-configurator.git
synced 2025-01-31 11:53:35 +01:00
add certs-only flag
This commit is contained in:
parent
c8a31d1d74
commit
e5e11af36d
2 changed files with 23 additions and 15 deletions
14
ncc/main.py
14
ncc/main.py
|
@ -91,13 +91,13 @@ def cli():
|
|||
|
||||
@cli.command()
|
||||
@click.option(
|
||||
"--dehydrated-only",
|
||||
"--certs-only",
|
||||
type=bool,
|
||||
is_flag=True,
|
||||
help="Only fetches and deploys new certificates",
|
||||
)
|
||||
@click.option("--skip-master-check", type=bool, is_flag=True)
|
||||
def up(dehydrated_only: bool, skip_master_check: bool):
|
||||
def up(certs_only: bool, skip_master_check: bool):
|
||||
"""Deploy the configuration to the cluster
|
||||
|
||||
Does the following:
|
||||
|
@ -117,7 +117,7 @@ def up(dehydrated_only: bool, skip_master_check: bool):
|
|||
|
||||
with Step("Preparing configuration..."):
|
||||
dehydrated_dir = Path(CONFIG["dehydrated_dir"])
|
||||
if not dehydrated_only:
|
||||
if not certs_only:
|
||||
certs.generate_ssl(
|
||||
Path(CONFIG["main_config"]),
|
||||
Path(CONFIG["dehydrated_dir"]) / "domains.txt",
|
||||
|
@ -133,6 +133,7 @@ def up(dehydrated_only: bool, skip_master_check: bool):
|
|||
f"dehydrated returned {ec} (log: {click.format_filename(log)})"
|
||||
)
|
||||
|
||||
if not certs_only:
|
||||
ec, stdout = sysaction.run_shell(
|
||||
("nginx", "-t", "-p", ".", "-c", CONFIG["main_config"]), window_height=5
|
||||
)
|
||||
|
@ -144,6 +145,13 @@ def up(dehydrated_only: bool, skip_master_check: bool):
|
|||
step.echo('deploying to "' + target + '"', nl=False)
|
||||
|
||||
try:
|
||||
if certs_only:
|
||||
sysrsync.run(
|
||||
source=os.getcwd() + "/" + str(dehydrated_dir / "certs"),
|
||||
destination=target + "/" + str(dehydrated_dir / "certs"),
|
||||
options=["-a", "--delete"],
|
||||
)
|
||||
else:
|
||||
sysrsync.run(
|
||||
source=os.getcwd(),
|
||||
destination=target,
|
||||
|
|
|
@ -21,7 +21,7 @@ def run_shell(cmd, window_height=0):
|
|||
buf = deque()
|
||||
for line in out.stdout:
|
||||
term_size = os.get_terminal_size()
|
||||
prefixed = (" => " + line).rstrip()[: term_size[0] - 1] + "\n"
|
||||
prefixed = (" => " + line).replace("\t", " ").rstrip()[: term_size[0] - 1] + "\n"
|
||||
stdout.append(line)
|
||||
buf.append(prefixed)
|
||||
|
||||
|
|
Loading…
Reference in a new issue