Compare commits
2 commits
16f8f65a82
...
2892c30f69
Author | SHA1 | Date | |
---|---|---|---|
2892c30f69 | |||
9c1538de29 |
1 changed files with 20 additions and 4 deletions
|
@ -76,7 +76,14 @@ class Cloudflare:
|
||||||
dns_list = self.list_dns(zone_id, type_)
|
dns_list = self.list_dns(zone_id, type_)
|
||||||
return dns_list['result'][0]['content']
|
return dns_list['result'][0]['content']
|
||||||
|
|
||||||
def issue_cert(self, ssl_home: str, acme_directory: str, domains: List[str]) -> None:
|
def issue_cert(
|
||||||
|
self,
|
||||||
|
ssl_home: str,
|
||||||
|
acme_directory: str,
|
||||||
|
domains: List[str],
|
||||||
|
server: str = 'zerossl',
|
||||||
|
force: bool = False,
|
||||||
|
) -> None:
|
||||||
env = {
|
env = {
|
||||||
'HOME': ssl_home,
|
'HOME': ssl_home,
|
||||||
'CF_Key': self.key,
|
'CF_Key': self.key,
|
||||||
|
@ -84,7 +91,10 @@ class Cloudflare:
|
||||||
}
|
}
|
||||||
|
|
||||||
acme = os.path.join(script_dir, acme_directory, 'acme.sh')
|
acme = os.path.join(script_dir, acme_directory, 'acme.sh')
|
||||||
kwargs = [acme, '--issue', '--dns', 'dns_cf', '-d', self.host]
|
kwargs = [acme, '--server', server, '--issue', '--dns', 'dns_cf', '-d', self.host]
|
||||||
|
|
||||||
|
if force:
|
||||||
|
kwargs.append('--force')
|
||||||
|
|
||||||
for domain in domains:
|
for domain in domains:
|
||||||
kwargs.extend(['-d', f"{domain}.{self.host}"])
|
kwargs.extend(['-d', f"{domain}.{self.host}"])
|
||||||
|
@ -169,8 +179,14 @@ class CloudflareAction(argparse.Action):
|
||||||
if option_string == '--issue-cert':
|
if option_string == '--issue-cert':
|
||||||
ssl_home = config.get('ssl', 'ssl_home')
|
ssl_home = config.get('ssl', 'ssl_home')
|
||||||
acme_directory = config.get('ssl', 'acme_directory')
|
acme_directory = config.get('ssl', 'acme_directory')
|
||||||
|
server = config.get('ssl', 'server', fallback='zerossl')
|
||||||
subdomains = config.get('General', 'subdomains').replace(' ', '').split(',')
|
subdomains = config.get('General', 'subdomains').replace(' ', '').split(',')
|
||||||
self.cloudflare.issue_cert(ssl_home, acme_directory, subdomains)
|
force = False
|
||||||
|
|
||||||
|
if values == "force":
|
||||||
|
force = True
|
||||||
|
|
||||||
|
self.cloudflare.issue_cert(ssl_home, acme_directory, subdomains, server, force)
|
||||||
|
|
||||||
if option_string == '--maintenance':
|
if option_string == '--maintenance':
|
||||||
self.cloudflare.update_dns(
|
self.cloudflare.update_dns(
|
||||||
|
@ -207,6 +223,6 @@ if __name__ == '__main__':
|
||||||
command_parser = argparse.ArgumentParser()
|
command_parser = argparse.ArgumentParser()
|
||||||
command_parser.add_argument('--list-dns', action=CloudflareAction, nargs=1)
|
command_parser.add_argument('--list-dns', action=CloudflareAction, nargs=1)
|
||||||
command_parser.add_argument('--update-dns', action=CloudflareAction, nargs=0)
|
command_parser.add_argument('--update-dns', action=CloudflareAction, nargs=0)
|
||||||
command_parser.add_argument('--issue-cert', action=CloudflareAction, nargs=0)
|
command_parser.add_argument('--issue-cert', action=CloudflareAction, nargs='?')
|
||||||
command_parser.add_argument('--maintenance', action=CloudflareAction, nargs=0)
|
command_parser.add_argument('--maintenance', action=CloudflareAction, nargs=0)
|
||||||
command_parser.parse_args()
|
command_parser.parse_args()
|
||||||
|
|
Loading…
Add table
Reference in a new issue