diff options
| author | crupest <crupest@outlook.com> | 2022-11-27 13:17:25 +0800 | 
|---|---|---|
| committer | crupest <crupest@outlook.com> | 2022-11-27 13:17:25 +0800 | 
| commit | c8b8633f0cc4c327ead96efb8a4e72a18aa50619 (patch) | |
| tree | 55b9a3f4653d7ba685b8e0165bdc3504bdf1b401 /tool/aio.py | |
| parent | 39b8d121b4867c667194369f17946be8ebb06e8b (diff) | |
| download | crupest-c8b8633f0cc4c327ead96efb8a4e72a18aa50619.tar.gz crupest-c8b8633f0cc4c327ead96efb8a4e72a18aa50619.tar.bz2 crupest-c8b8633f0cc4c327ead96efb8a4e72a18aa50619.zip | |
Add certbot check.
Diffstat (limited to 'tool/aio.py')
| -rwxr-xr-x | tool/aio.py | 20 | 
1 files changed, 18 insertions, 2 deletions
| diff --git a/tool/aio.py b/tool/aio.py index 9d14e5f..ec22537 100755 --- a/tool/aio.py +++ b/tool/aio.py @@ -517,8 +517,24 @@ if os.path.isdir(data_dir):          to_check = Confirm.ask(              "I want to check your ssl certs, but I need to sudo. Do you want me check", console=console, default=False)          if to_check: -            get_cert_path(check_domain_is_defined()) -            # TODO: Do the check! +            domain = check_domain_is_defined() +            cert_path = get_cert_path(domain) +            tmp_cert_path = os.path.join(tmp_dir, "fullchain.pem") +            console.print("Temporarily copy cert to tmp...", style="yellow") +            ensure_tmp_dir() +            subprocess.run( +                ["sudo", "cp", cert_path, tmp_cert_path], check=True) +            subprocess.run(["sudo", "chown", os.geteuid(), +                           tmp_cert_path], check=True) +            cert_domains = set(get_cert_domains(tmp_cert_path, domain)) +            domains = set(list_domains()) +            if not cert_domains == domains: +                console.print( +                    "Cert domains are not equal to host domains. Run following command to recreate it.", style="red") +                console.print(certbot_command_gen( +                    domain, "create", standalone=True), soft_wrap=False, highlight=False) +            console.print("Remove tmp cert...", style="yellow") +            os.remove(tmp_cert_path)      if not os.path.exists(os.path.join(data_dir, "code-server")):          os.mkdir(os.path.join(data_dir, "code-server")) | 
