-
Notifications
You must be signed in to change notification settings - Fork 213
/
getssl.py
32 lines (25 loc) · 1.03 KB
/
getssl.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import os
start_v2ray_cmd = "service v2ray start >/dev/null 2>&1"
stop_v2ray_cmd = "service v2ray stop >/dev/null 2>&1"
start_nginx_cmd = "service nginx start >/dev/null 2>&1"
stop_nginx_cmd = "service nginx stop >/dev/null 2>&1"
start_httpd_cmd = "service httpd start >/dev/null 2>&1"
stop_httpd_cmd = "service httpd stop >/dev/null 2>&1"
def getssl(domain):
crt_file = "/root/.acme.sh/"+domain+"/fullchain.cer"
key_file = "/root/.acme.sh/"+domain+"/ca.cer"
get_ssl_cmd = "bash /root/.acme.sh/acme.sh --issue -d " +domain +" --standalone"
#判断是否存在证书
if os.path.isfile(crt_file) and os.path.isfile(key_file):
print("证书文件已存在,跳过获取证书阶段。")
else:
os.system(stop_v2ray_cmd)
os.system(stop_nginx_cmd)
os.system(start_httpd_cmd)
os.system(get_ssl_cmd)
os.system(start_v2ray_cmd)
os.system(start_nginx_cmd)
os.system(start_httpd_cmd)
print("证书获取成功!")