[dnssec_generate] add verbose mode
This commit is contained in:
parent
9f9e950d5c
commit
5bdcde4a02
1 changed files with 16 additions and 1 deletions
|
@ -4,6 +4,7 @@ import json
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
|
||||||
path = os.path.dirname(os.path.abspath(__file__))
|
path = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
@ -13,10 +14,21 @@ try:
|
||||||
except:
|
except:
|
||||||
zones = []
|
zones = []
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
parser = argparse.ArgumentParser(description="Gestion de DNSSEC")
|
||||||
|
parser.add_argument('-v', '--verbose', help="Mode verbeux", action="store_true")
|
||||||
|
args = parser.parse_args()
|
||||||
|
verbose = args.verbose
|
||||||
ds_records = {}
|
ds_records = {}
|
||||||
for zone in zones:
|
for zone in zones:
|
||||||
cdss = subprocess.check_output(['/usr/sbin/knotc', 'zone-read', zone, '@', 'CDS'])[:-1].decode('utf-8').split('\n')
|
if verbose:
|
||||||
|
print("Getting CDS of %s:" % (zone,))
|
||||||
|
print("/usr/sbin/knotcs zone-read %s @ CDS" % (zone,))
|
||||||
|
cdss = subprocess.check_output(['/usr/sbin/knotc', 'zone-read', zone, '@', 'CDS'])[:-1].decode('utf-8').split('\n')
|
||||||
|
if verbose:
|
||||||
|
print("CDS of %s = %s" % (zone, cdss))
|
||||||
for cds in cdss:
|
for cds in cdss:
|
||||||
ds = {}
|
ds = {}
|
||||||
try:
|
try:
|
||||||
|
@ -33,5 +45,8 @@ if __name__ == '__main__':
|
||||||
if not zone in ds_records:
|
if not zone in ds_records:
|
||||||
ds_records[zone] = []
|
ds_records[zone] = []
|
||||||
ds_records[zone].append(ds)
|
ds_records[zone].append(ds)
|
||||||
|
if verbose:
|
||||||
|
print("DS record of %s : %s" % (zone, ds))
|
||||||
|
print("\n\n")
|
||||||
with open('dnssec.json', 'w') as dnssec:
|
with open('dnssec.json', 'w') as dnssec:
|
||||||
json.dump(ds_records, dnssec)
|
json.dump(ds_records, dnssec)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue