Exemplo n.º 1
0
def get_user_domains(cpuser):
    alluserdata = dataparse.get_vhost_data()
    alluserdata.update(udatafile.get_vhost_data_from_file())
    cpuserdata = {}
    for domain in alluserdata:
        if alluserdata[domain][1] == cpuser:
            cpuserdata[domain] = alluserdata[domain]
    return cpuserdata
Exemplo n.º 2
0
def rebuild_all_vhost():
    userdata = dataparse.get_vhost_data()
    userdata.update(udatafile.get_vhost_data_from_file())
    ssldata = cpanel.get_all_ssl_certificates()
    #ssldomain=vhost.get_ssl_domains()
    dedicate_ip = vhost.get_dedicated_ip_domains()
    firewall = vhost.get_firewall()
    settings = vhost.get_default_settings()
    for domain in userdata:
        #print userdata
        confpath = '/usr/local/nginx/conf/vhost.d/' + domain + '.conf'
        havessl = "0"
        if domain in dedicate_ip:
            havedip = "1"
        else:
            havedip = "0"
        vhostdata = vhost.build_vhost(userdata[domain], havessl, havedip,
                                      firewall, settings, ssldata)
        fo = open(confpath, "wb")
        fo.write(vhostdata)
        fo.close()
        vhostdata = ""
        print "Generating  nginx " + shellcolor.pink + "HTTP" + shellcolor.end + "  configuration file for " + shellcolor.green + domain + shellcolor.end + " on ... " + shellcolor.yellow + confpath + shellcolor.end
        if userdata[domain][2] == "addon" or userdata[domain][2] == "parked":
            sdomain = userdata[domain][3]
            if sdomain in ssldata:
                keycrt = ssldata[sdomain]['key']
                cert = ssldata[sdomain]['certificate']
                ca = ssldata[sdomain]['cabundle']
                ssldata[domain] = {
                    'key': keycrt,
                    'certificate': cert,
                    'cabundle': ca
                }
        #if domain in ssldomain:
        #if vhost.have_valid_ssl(domain):
        if domain in ssldata:
            havessl = "1"
            confpath_ssl = '/usr/local/nginx/conf/vhost.ssl.d/' + domain + '.conf'
            vhostdata_ssl = vhost.build_vhost(userdata[domain], havessl,
                                              havedip, firewall, settings,
                                              ssldata)
            fo = open(confpath_ssl, "wb")
            fo.write(vhostdata_ssl)
            fo.close()
            vhostdata_ssl = ""
            print "Generating  nginx " + shellcolor.green + "HTTPS" + shellcolor.end + "  configuration file for " + shellcolor.green + domain + shellcolor.end + " on ... " + shellcolor.yellow + confpath_ssl + shellcolor.end
    vhost.build_defaul_vhost()
    reload_nginx()
Exemplo n.º 3
0
def build_all_ssl_certs():
    userdata = dataparse.get_vhost_data()
    userdata.update(udatafile.get_vhost_data_from_file())
    ssldata = cpanel.get_all_ssl_certificates()
    for dom in userdata:
        if userdata[dom][2] == "addon" or userdata[dom][2] == "parked":
            sdomain = userdata[dom][3]
            if sdomain in ssldata:
                keycrt = ssldata[sdomain]['key']
                cert = ssldata[sdomain]['certificate']
                ca = ssldata[sdomain]['cabundle']
                ssldata[dom] = {
                    'key': keycrt,
                    'certificate': cert,
                    'cabundle': ca
                }
    for domain in ssldata:
        build_ssl_cert(domain, ssldata)
Exemplo n.º 4
0
def get_ssl_domains():
    alluserdata = dataparse.get_vhost_data()
    alluserdata.update(udatafile.get_vhost_data_from_file())
    ssldom = {}
    for domain in alluserdata:
        if alluserdata[domain][2] == "sub":
            domconf = '/var/cpanel/userdata/' + alluserdata[domain][
                1] + '/' + alluserdata[domain][0] + '_SSL'
            if os.path.exists(domconf):
                ssldom[domain] = [
                    alluserdata[domain][0], alluserdata[domain][5]
                ]
        else:
            domconf = '/var/cpanel/userdata/' + alluserdata[domain][
                1] + '/' + alluserdata[domain][3] + '_SSL'
            if os.path.exists(domconf):
                ssldom[domain] = [
                    alluserdata[domain][3], alluserdata[domain][5]
                ]
    return ssldom
Exemplo n.º 5
0
def monitor():
    ssldata = cpanel.get_all_ssl_certificates()
    userdata = dataparse.get_vhost_data()
    userdata.update(udatafile.get_vhost_data_from_file())
    for dom in userdata:
        if userdata[dom][2] == "addon" or userdata[dom][2] == "parked":
            sdomain = userdata[dom][3]
            if sdomain in ssldata:
                keycrt = ssldata[sdomain]['key']
                cert = ssldata[sdomain]['certificate']
                ca = ssldata[sdomain]['cabundle']
                ssldata[dom] = {
                    'key': keycrt,
                    'certificate': cert,
                    'cabundle': ca
                }
    puser = None
    parallel = ThreadPool(puser)
    for domain in ssldata:
        if bool(domain.strip()):
            parallel.apply_async(monitor_ssl, (domain, ssldata))
    parallel.close()
    parallel.join()