Пример #1
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()
Пример #2
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)
Пример #3
0
def rebuilduservhost(cpuser):
    firewall = vhost.get_firewall()
    settings = vhost.get_default_settings()
    if os.path.exists("/var/cpanel/users/" + cpuser):
        print "Rebuilding all domains nginx vhost configuration files for  user ..." + shellcolor.pink + cpuser + shellcolor.end
        userdata = vhost.get_user_domains(cpuser)
        #ssldomain=vhost.get_ssl_domains()
        ssldata = cpanel.get_all_ssl_certificates()
        dedicate_ip = vhost.get_dedicated_ip_domains()
        for domain in userdata:
            #print userdata[domain]
            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 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
    else:
        print "No such cpanel user .. " + shellcolor.fail + "NOT FOUND" + shellcolor.end
    reload_nginx()
Пример #4
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()