mirror of
https://github.com/YunoHost/dynette.git
synced 2024-09-03 20:06:17 +02:00
[enh] Add some comments.
This commit is contained in:
parent
c83fecdb08
commit
87acdfaf80
1 changed files with 14 additions and 1 deletions
|
@ -30,7 +30,10 @@ from urllib import urlopen
|
||||||
master_key_path = os.path.join(os.path.dirname(__file__), 'master.key')
|
master_key_path = os.path.join(os.path.dirname(__file__), 'master.key')
|
||||||
master_key = open(master_key_path).read().rstrip()
|
master_key = open(master_key_path).read().rstrip()
|
||||||
|
|
||||||
|
# Bind configuration
|
||||||
lines = ['// Generated by Dynette CRON']
|
lines = ['// Generated by Dynette CRON']
|
||||||
|
|
||||||
|
# Loop through Dynette servers
|
||||||
for url in subs_urls:
|
for url in subs_urls:
|
||||||
|
|
||||||
lines.extend([
|
lines.extend([
|
||||||
|
@ -40,9 +43,11 @@ for url in subs_urls:
|
||||||
'};',
|
'};',
|
||||||
])
|
])
|
||||||
|
|
||||||
|
# Get available DynDNS domains
|
||||||
domains = json.loads(str(urlopen(url +'/domains').read()))
|
domains = json.loads(str(urlopen(url +'/domains').read()))
|
||||||
for domain in domains:
|
for domain in domains:
|
||||||
result = json.loads(str(urlopen(url +'/all/'+ domain).read()))
|
|
||||||
|
# Create zone database if not present
|
||||||
if not os.path.exists(zone_dir + domain +'.db'):
|
if not os.path.exists(zone_dir + domain +'.db'):
|
||||||
db_lines = [
|
db_lines = [
|
||||||
'$ORIGIN .',
|
'$ORIGIN .',
|
||||||
|
@ -63,6 +68,7 @@ for url in subs_urls:
|
||||||
with open(zone_dir + domain +'.db', 'w') as zone:
|
with open(zone_dir + domain +'.db', 'w') as zone:
|
||||||
for line in db_lines:
|
for line in db_lines:
|
||||||
zone.write(line + '\n')
|
zone.write(line + '\n')
|
||||||
|
|
||||||
lines.extend([
|
lines.extend([
|
||||||
'zone "'+ domain +'" {',
|
'zone "'+ domain +'" {',
|
||||||
' type master;',
|
' type master;',
|
||||||
|
@ -71,6 +77,8 @@ for url in subs_urls:
|
||||||
' grant dynette. wildcard *.'+ domain +'. ANY;',
|
' grant dynette. wildcard *.'+ domain +'. ANY;',
|
||||||
])
|
])
|
||||||
|
|
||||||
|
# Get registered sub-domains
|
||||||
|
result = json.loads(str(urlopen(url +'/all/'+ domain).read()))
|
||||||
for entry in result:
|
for entry in result:
|
||||||
for subd, type in allowed_operations.items():
|
for subd, type in allowed_operations.items():
|
||||||
if subd == '.': subd = ''
|
if subd == '.': subd = ''
|
||||||
|
@ -90,13 +98,18 @@ for url in subs_urls:
|
||||||
'};',
|
'};',
|
||||||
])
|
])
|
||||||
|
|
||||||
|
# Backup old Bind configuration file.
|
||||||
os.system('cp '+ conf_file +' '+ conf_file +'.back')
|
os.system('cp '+ conf_file +' '+ conf_file +'.back')
|
||||||
|
|
||||||
|
# Write Bind configuration file.
|
||||||
with open(conf_file, 'w') as zone:
|
with open(conf_file, 'w') as zone:
|
||||||
for line in lines:
|
for line in lines:
|
||||||
zone.write(line + '\n')
|
zone.write(line + '\n')
|
||||||
|
|
||||||
|
# Restore ownership
|
||||||
os.system('chown -R bind:bind '+ zone_dir +' '+ conf_file)
|
os.system('chown -R bind:bind '+ zone_dir +' '+ conf_file)
|
||||||
|
|
||||||
|
# Reload Bind
|
||||||
if os.system('/usr/sbin/rndc reload') == 0:
|
if os.system('/usr/sbin/rndc reload') == 0:
|
||||||
exit(0)
|
exit(0)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue