diff options
| author | crupest <crupest@outlook.com> | 2022-11-20 16:14:32 +0800 | 
|---|---|---|
| committer | crupest <crupest@outlook.com> | 2022-11-20 16:14:32 +0800 | 
| commit | 79bb2c981e427d84b93d880fae5a42216f2f38d1 (patch) | |
| tree | b83f2ba1b36c899dcea552f65c98e61c8319d8e1 /tool | |
| parent | d9b7d82487f9da2f91592a1a437cff20d7f01445 (diff) | |
| download | crupest-79bb2c981e427d84b93d880fae5a42216f2f38d1.tar.gz crupest-79bb2c981e427d84b93d880fae5a42216f2f38d1.tar.bz2 crupest-79bb2c981e427d84b93d880fae5a42216f2f38d1.zip  | |
Add expand ssl certs command.
Diffstat (limited to 'tool')
| -rwxr-xr-x | tool/aio.py | 6 | ||||
| -rwxr-xr-x | tool/modules/nginx.py | 5 | 
2 files changed, 10 insertions, 1 deletions
diff --git a/tool/aio.py b/tool/aio.py index b690b3e..3f3ab69 100755 --- a/tool/aio.py +++ b/tool/aio.py @@ -52,6 +52,8 @@ certbot_command_group = certbot_parser.add_mutually_exclusive_group()  certbot_command_group.add_argument(      "-C", "--create", action="store_true", default=False, help="Only print the command for 'create' action.")  certbot_command_group.add_argument( +    "-E", "--expand", action="store_true", default=False, help="Only print the command for 'expand' action.") +certbot_command_group.add_argument(      "-R", "--renew", action="store_true", default=False, help="Only print the command for 'renew' action.")  certbot_parser.add_argument( @@ -156,6 +158,10 @@ if args.action == 'certbot':          console.print(certbot_command_gen(domain, "create",                                            test=is_test), soft_wrap=True, highlight=False)          exit(0) +    elif args.expand: +        console.print(certbot_command_gen(domain, "expand", +                                          test=is_test), soft_wrap=True, highlight=False) +        exit(0)      elif args.renew:          console.print(certbot_command_gen(domain, "renew",                                            test=is_test), soft_wrap=True, highlight=False) diff --git a/tool/modules/nginx.py b/tool/modules/nginx.py index def7f11..7336c3e 100755 --- a/tool/modules/nginx.py +++ b/tool/modules/nginx.py @@ -77,9 +77,12 @@ def certbot_command_gen(domain: str, action, test=False) -> str:      if action == 'create':          # create with standalone mode          return f'docker run -it --rm --name certbot -v "{project_abs_path}/data/certbot/certs:/etc/letsencrypt" -v "{project_abs_path}/data/certbot/data:/var/lib/letsencrypt" -p "0.0.0.0:80:80" certbot/certbot certonly --standalone -d {" -d ".join(domains)}{ " --test-cert --dry-run" if test else "" }' +    elif action == 'expand': +        # expand with webroot mode +        return f'docker run -it --rm --name certbot -v "{project_abs_path}/data/certbot/certs:/etc/letsencrypt" -v "{project_abs_path}/data/certbot/data:/var/lib/letsencrypt" -v "{project_abs_path}/data/certbot/webroot:/var/www/certbot" certbot/certbot certonly --webroot -w /var/www/certbot -d {" -d ".join(domains)}{ " --test-cert --dry-run" if test else "" }'      elif action == 'renew':          # renew with webroot mode -        return f'docker run -it --rm --name certbot -v "{project_abs_path}/data/certbot/certs:/etc/letsencrypt" -v "{project_abs_path}/data/certbot/data:/var/lib/letsencrypt" -v "{project_abs_path}/data/certbot/webroot:/var/www/certbot" certbot/certbot renew --webroot -w /var/www/certbot -d {" -d ".join(domains)}{ " --test-cert --dry-run" if test else "" }' +        return f'docker run -it --rm --name certbot -v "{project_abs_path}/data/certbot/certs:/etc/letsencrypt" -v "{project_abs_path}/data/certbot/data:/var/lib/letsencrypt" -v "{project_abs_path}/data/certbot/webroot:/var/www/certbot" certbot/certbot renew --webroot -w /var/www/certbot{ " --test-cert --dry-run" if test else "" }'      raise ValueError('Invalid action')  | 
