mirror of
https://git.nolog.cz/NoLog.cz/nginx-configurator.git
synced 2025-01-31 03:43:35 +01:00
add certs-only flag
This commit is contained in:
parent
28db18d384
commit
b496ada16c
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()
|
@cli.command()
|
||||||
@click.option(
|
@click.option(
|
||||||
"--dehydrated-only",
|
"--certs-only",
|
||||||
type=bool,
|
type=bool,
|
||||||
is_flag=True,
|
is_flag=True,
|
||||||
help="Only fetches and deploys new certificates",
|
help="Only fetches and deploys new certificates",
|
||||||
)
|
)
|
||||||
@click.option("--skip-master-check", type=bool, is_flag=True)
|
@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
|
"""Deploy the configuration to the cluster
|
||||||
|
|
||||||
Does the following:
|
Does the following:
|
||||||
|
@ -117,7 +117,7 @@ def up(dehydrated_only: bool, skip_master_check: bool):
|
||||||
|
|
||||||
with Step("Preparing configuration..."):
|
with Step("Preparing configuration..."):
|
||||||
dehydrated_dir = Path(CONFIG["dehydrated_dir"])
|
dehydrated_dir = Path(CONFIG["dehydrated_dir"])
|
||||||
if not dehydrated_only:
|
if not certs_only:
|
||||||
certs.generate_ssl(
|
certs.generate_ssl(
|
||||||
Path(CONFIG["main_config"]),
|
Path(CONFIG["main_config"]),
|
||||||
Path(CONFIG["dehydrated_dir"]) / "domains.txt",
|
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)})"
|
f"dehydrated returned {ec} (log: {click.format_filename(log)})"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if not certs_only:
|
||||||
ec, stdout = sysaction.run_shell(
|
ec, stdout = sysaction.run_shell(
|
||||||
("nginx", "-t", "-p", ".", "-c", CONFIG["main_config"]), window_height=5
|
("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)
|
step.echo('deploying to "' + target + '"', nl=False)
|
||||||
|
|
||||||
try:
|
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(
|
sysrsync.run(
|
||||||
source=os.getcwd(),
|
source=os.getcwd(),
|
||||||
destination=target,
|
destination=target,
|
||||||
|
|
|
@ -21,7 +21,7 @@ def run_shell(cmd, window_height=0):
|
||||||
buf = deque()
|
buf = deque()
|
||||||
for line in out.stdout:
|
for line in out.stdout:
|
||||||
term_size = os.get_terminal_size()
|
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)
|
stdout.append(line)
|
||||||
buf.append(prefixed)
|
buf.append(prefixed)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue