diff options
author | Yuqian Yang <crupest@crupest.life> | 2025-01-21 00:58:41 +0800 |
---|---|---|
committer | Yuqian Yang <crupest@crupest.life> | 2025-01-21 01:07:50 +0800 |
commit | ca61b00c103262137c9f2b827499a9fcf44731ed (patch) | |
tree | 331900b44200efb90c9b8474c3c044aa9b89a638 /tools/cru-py/cru/service | |
parent | b92ef60a14a7c7bbc6449cd2d89c47da9324368e (diff) | |
download | crupest-ca61b00c103262137c9f2b827499a9fcf44731ed.tar.gz crupest-ca61b00c103262137c9f2b827499a9fcf44731ed.tar.bz2 crupest-ca61b00c103262137c9f2b827499a9fcf44731ed.zip |
feat(manage): default to test in certbot. add update-blog command.
Diffstat (limited to 'tools/cru-py/cru/service')
-rw-r--r-- | tools/cru-py/cru/service/_external.py | 14 | ||||
-rw-r--r-- | tools/cru-py/cru/service/_nginx.py | 15 |
2 files changed, 22 insertions, 7 deletions
diff --git a/tools/cru-py/cru/service/_external.py b/tools/cru-py/cru/service/_external.py index 418316a..2347e95 100644 --- a/tools/cru-py/cru/service/_external.py +++ b/tools/cru-py/cru/service/_external.py @@ -21,7 +21,10 @@ class CliToolCommandProvider(AppCommandFeatureProvider): "-t", "--test", action="store_true", help="run certbot in test mode" ) _install_docker_parser = subparsers.add_parser( - "install-docker", help="print docker commands" + "install-docker", help="print docker installation commands" + ) + _update_blog_parser = subparsers.add_parser( + "update-blog", help="print blog update command" ) def _print_install_docker_commands(self) -> None: @@ -62,8 +65,17 @@ sudo usermod -aG docker $USER """.strip() print(output) + def _print_update_blog_command(self): + output = """ +### COMMAND: update blog +docker exec -it blog /scripts/update.bash +""".strip() + print(output) + def run_command(self, args): if args.gen_cli_command == "certbot": self.app.get_feature(NginxManager).print_all_certbot_commands(args.test) elif args.gen_cli_command == "install-docker": self._print_install_docker_commands() + elif args.gen_cli_command == "update-blog": + self._print_update_blog_command()
\ No newline at end of file diff --git a/tools/cru-py/cru/service/_nginx.py b/tools/cru-py/cru/service/_nginx.py index a9013e2..e0a9c60 100644 --- a/tools/cru-py/cru/service/_nginx.py +++ b/tools/cru-py/cru/service/_nginx.py @@ -91,10 +91,9 @@ class NginxManager(AppCommandFeatureProvider): def _certbot_command( self, action: CertbotAction | str, - /, - test=False, - no_docker=False, + test: bool, *, + docker=True, standalone=None, email=None, agree_tos=True, @@ -123,7 +122,7 @@ class NginxManager(AppCommandFeatureProvider): data_dir = self.app.data_dir.full_path.as_posix() - if no_docker: + if not docker: command_args.append("certbot") else: command_args.extend( @@ -142,6 +141,8 @@ class NginxManager(AppCommandFeatureProvider): command_args.append(command_action) + command_args.append(f"--cert-name {self.root_domain}") + if standalone: command_args.append("--standalone") else: @@ -208,14 +209,16 @@ class NginxManager(AppCommandFeatureProvider): _list_parser = subparsers.add_parser("list", help="list domains") certbot_parser = subparsers.add_parser("certbot", help="print certbot commands") certbot_parser.add_argument( - "-t", "--test", action="store_true", help="run certbot in test mode" + "--no-test", + action="store_true", + help="remove args making certbot run in test mode", ) def run_command(self, args: Namespace) -> None: if args.nginx_command == "list": self._print_domains() elif args.nginx_command == "certbot": - self.print_all_certbot_commands(args.test) + self.print_all_certbot_commands(not args.no_test) def _generate_dns_zone( self, |