my cgi script:
#!/usr/bin/env python
import os
import time
from string import Template
# Configuration – python dictionary
ddns = {
'ns1' : "ns1.example.com",
'ns2' : "ns2.example.com",
'email' : "admin@example.com",
# the ddns records
'ebal' : "ebal.dyn.example.com"
}
# Zone Template
zone = Template('$zone.\tIN\tSOA\t$ns1\t$email\t$serial\t14400\t14400\t1209600\t86400\n\t\t\tIN\tNS\t$ns1\n\t\t\tIN\tNS\t$ns2\n$zone.\t300\tIN\tA\t$dynip\n')
# Zone File – must have write access
fddns="/tmp/" + ddns[os.environ['REMOTE_USER']]
# Write zone
with open(fddns, 'w') as f:
f.write( zone.substitute(zone=ddns[os.environ['REMOTE_USER']], serial=str(int(time.time())), dynip=os.environ['REMOTE_ADDR'] , ns1= ddns['ns1'], ns2= ddns['ns2'], email= ddns['email'] ) )
print