Пример #1
0
	def makedomain(self, host, ip, typedns='bind'):
		data = [ip, host, ip, ip, host, ip, ip]
		if typedns == 'bind' or typedns == 'bind9':
			template = """$TTL 10800
@		IN SOA	{0}. root.{1}. (
			  2015080401   ; Serial number
			  10800        ; Refresh
			  3600         ; Retry
			  777600       ; Expire
			  3600       ) ; Minimum TTL
		A	{2}
		NS	{3}.
		MX	10 mail.{4}.
ftp		A	{5}
mail		A	{6}
www		CNAME	@
""".format(*data)
		elif typedns == 'sdnsp' or typedns == 'sdnsplus' or typedns == 'simple' or typedns == 'simple dns plus' or typedns == 'simplednsplus':
			template = """
		$TTL 10800
@		IN SOA	( {0}. ; Primary DNS server
			  root.{1}. ; Responsible person
			  2015080401   ; Serial number
			  10800        ; Refresh
			  3600         ; Retry
			  777600       ; Expire
			  3600       ) ; Minimum TTL
		A	{2}
		NS	{3}.
		MX	10 mail.{4}.
ftp		A	{5}
mail		A	{6}
www		CNAME	@
""".format(*data)

		print "template =", template
		print '-'*94
		print "DB-PATH =", os.path.join(os.path.join(configset.read_config4('DB', 'PATH', configname))[0], str(host) + '.' + EXT)
		print '-'*94
		fi = open(os.path.join(configset.read_config4('DB', 'PATH', configname)[0], str(host) + '.' + EXT), 'w')
		fi.write("\n")
		fi.write(template)
		fi.close()
Пример #2
0
	def insertdomain(self, host, typehost='master', dbpath=None, configpath=None):
		if dbpath == None:
			dbpath = os.path.join(configset.read_config4('DB', 'PATH', configname)[0], str(host) + "." + EXT)
		else:
			dbpath = os.path.join(dbpath, str(host) + "." + EXT)
		print "HOST   2 =", host
		print "TYPE   2 =", typehost
		print "DBPATH 2 =", dbpath
		# data1 = [host, typehost, dbpath]
		template = """zone "%s" {
        type %s;
        file "%s";
};"""%(host, typehost, dbpath)
		print "template =", template
		if configpath == None:
			fi = open(configset.read_config4('DB', 'CONFIG_PATH', configname)[0], 'a')
		else:
			fi = open(configpath, 'a')
		fi.write("\n")
		fi.write(template)
		fi.close()
Пример #3
0
#!/usr/bin/python
import argparse
import os
import sys
import configset 
THIS_PATH = os.path.dirname(__file__)
configname = os.path.join(THIS_PATH, 'bindg.ini')
EXT = configset.read_config4('DB', 'EXT', configname)[0]
if EXT == None:
	EXT = "dns"

class bind(object):
	def __init__(self):
		super(bind, self)

	def makedomain(self, host, ip, typedns='bind'):
		data = [ip, host, ip, ip, host, ip, ip]
		if typedns == 'bind' or typedns == 'bind9':
			template = """$TTL 10800
@		IN SOA	{0}. root.{1}. (
			  2015080401   ; Serial number
			  10800        ; Refresh
			  3600         ; Retry
			  777600       ; Expire
			  3600       ) ; Minimum TTL
		A	{2}
		NS	{3}.
		MX	10 mail.{4}.
ftp		A	{5}
mail		A	{6}
www		CNAME	@