pull/624/head
Mr Chen 8 months ago
parent 5038d8b07f
commit ff2146a49d
  1. 74
      plugins/acme_pandominassl_apply/index.py
  2. 8
      plugins/acme_pandominassl_apply/install.sh
  3. 6
      plugins/acme_pandominassl_apply/js/common.js

@ -72,6 +72,24 @@ def checkArgs(data, ck=[]):
return (False, mw.returnJson(False, '参数:(' + ck[i] + ')没有!')) return (False, mw.returnJson(False, '参数:(' + ck[i] + ')没有!'))
return (True, mw.returnJson(True, 'ok')) return (True, mw.returnJson(True, 'ok'))
def getHomeDir():
if mw.isAppleSystem():
user = mw.execShell(
"who | sed -n '2, 1p' |awk '{print $1}'")[0].strip()
return '/Users/' + user
else:
return '/root'
def getRunUser():
if mw.isAppleSystem():
user = mw.execShell(
"who | sed -n '2, 1p' |awk '{print $1}'")[0].strip()
return user
else:
return 'root'
def configTpl(): def configTpl():
path = getPluginDir() + '/hooks' path = getPluginDir() + '/hooks'
pathFile = os.listdir(path) pathFile = os.listdir(path)
@ -474,7 +492,63 @@ def domainList():
return mw.getJson(data) return mw.getJson(data)
def getDnsapiData(dnsapi_id):
if dnsapi_id == '0':
return {}
conn_dnsapi = pSqliteDb('dnsapi')
tdata = conn_dnsapi.field('id,name,type,val').where('id=?',(dnsapi_id,)).select()
if len(tdata)>0:
return tdata[0]
return {}
def getCmdExportVar(val):
cmd_list = val.split('~')
def_var = ''
for x in range(len(cmd_list)):
v = cmd_list[x]
vlist = v.split('|')
def_var += 'export '+vlist[0]+'="'+vlist[1]+'"\n'
return def_var
def runHookDst():
pass
def runHook(): def runHook():
conn = pSqliteDb('domain')
conn_dnsapi = pSqliteDb('dnsapi')
field = 'id,domain,dnsapi_id,email,remark'
clist = conn.field(field).limit('1000').order('id desc').select()
for idx in range(len(clist)):
cmd = "#!/bin/bash\n"
if mw.isAppleSystem():
user = getRunUser()
cmd += "source /Users/"+user+"/.zshrc\n"
cmd_data = getDnsapiData(clist[idx]['dnsapi_id'])
print(cmd_data)
export_val = getCmdExportVar(cmd_data['val'])
cmd += export_val
# acme.sh --register-account -m my@example.com
cmd_register = 'acme.sh --register-account -m '+str(clist[idx]['email'])
cmd += cmd_register
# acme.sh --issue -d "example.com" -d "*.example.com" --dns dns_cf
cmd_apply = 'acme.sh --issue --dns '+str(cmd_data['type'])+' -d '+clist[idx]['domain']+' -d "*.'+clist[idx]['domain']+'"'
cmd += cmd_apply
run_log = runLog()
cmd += ' >> '+ run_log
print(cmd)
os.system(cmd)
# r = mw.execShell(cmd)
# print(r)
time.sleep(1)
return 'run hook' return 'run hook'
def runLog(): def runLog():

@ -10,6 +10,14 @@ serverPath=$(dirname "$rootPath")
install_tmp=${rootPath}/tmp/mw_install.pl install_tmp=${rootPath}/tmp/mw_install.pl
VERSION=$2 VERSION=$2
# curl https://get.acme.sh | sh
# acme.sh --uninstall
# source /Users/xxx/.zshrc
# https://github.com/acmesh-official/acme.sh/wiki/dnsapi
# cd /www/server/mdserver-web && python3 plugins/acme_pandominassl_apply/index.py run_hook # cd /www/server/mdserver-web && python3 plugins/acme_pandominassl_apply/index.py run_hook
Install_App() Install_App()

@ -211,9 +211,9 @@ function dnsapiDel(id, name){
} }
var dnsapi_option = [ var dnsapi_option = [
{"name":"cf", "title":'cloudflare', 'key':'CF_Key:CF_Email'}, {"name":"dns_cf", "title":'cloudflare', 'key':'CF_Key:CF_Email'},
{"name":"dp", "title":'dnspod/国内', 'key':'DP_Id:DP_Key'}, {"name":"dns_dp", "title":'dnspod/国内', 'key':'DP_Id:DP_Key'},
{"name":"dpi", "title":'dnspod/国际', 'key':'DPI_Id:DPI_Key'}, {"name":"dns_dpi", "title":'dnspod/国际', 'key':'DPI_Id:DPI_Key'},
{"name":"dns_gd", "title":'GoDaddy', 'key':'GD_Key:GD_Secret'}, {"name":"dns_gd", "title":'GoDaddy', 'key':'GD_Key:GD_Secret'},
{"name":"dns_pdns", "title":'PowerDNS', 'key':'PDNS_Url:PDNS_ServerId:PDNS_Token:PDNS_Ttl'}, {"name":"dns_pdns", "title":'PowerDNS', 'key':'PDNS_Url:PDNS_ServerId:PDNS_Token:PDNS_Ttl'},
{"name":"dns_lua", "title":'LuaDNS', 'key':'LUA_Key:LUA_Email'}, {"name":"dns_lua", "title":'LuaDNS', 'key':'LUA_Key:LUA_Email'},

Loading…
Cancel
Save