diff --git a/update-record.py b/update-record.py index 399a89c..f4a7c91 100755 --- a/update-record.py +++ b/update-record.py @@ -71,17 +71,19 @@ ret = None # end if else: - if (subId < 0): + if (not args.update or subId < 0): ret = inwx_conn.nameserver.createRecord({'domain': domain, 'name': sub, 'type': args.record_type, 'content': str(args.content), 'ttl': args.ttl}) + if (verbose): + print('create: ' + str(ret)) + # end if else: ret = inwx_conn.nameserver.updateRecord({'id': subId, 'type': args.record_type, 'content': str(args.content), 'ttl': args.ttl}) + if (verbose): + print('update: ' + str(ret)) + # end if # end if # end if - if (verbose): - print('update/create: ' + str(ret)) - # end if - # end main @@ -92,6 +94,7 @@ parser.add_argument('content', metavar='content', nargs='?', default=None, help='ip or string to fill into sub domain entry') parser.add_argument('-r', '--record-type', metavar='type', required=True, choices=['A', 'AAAA', 'TXT', 'CNAME', 'TLSA'], help='record type (A, AAAA, TXT, CNAME, TLSA)') parser.add_argument('--delete', action='store_true', required=False, help='delete existing record') + parser.add_argument('-u', '--update', action='store_true', required=False, help='update existing record if it exists') parser.add_argument('-c', '--config_file', metavar='path', default='./conf.cfg', help='path to configuration file') parser.add_argument('-t', '--ttl', default=3600, type=int, help='TTL (time to live) of the nameserver record in seconds (default 3600)')