add cmd in server

This commit is contained in:
Josue Gomez 2019-01-31 18:57:55 -06:00
parent fb9d079200
commit 4c6892ea42

47
iprenew Executable file
View File

@ -0,0 +1,47 @@
#!/usr/bin/python
import re
import os
import sys
from datetime import datetime
FILE = "/etc/bind/example.com.db"
nip = sys.argv[1]
content = ';\n'\
'; BIND data file for local loopback interface\n'\
';\n'\
'$TTL 1800\n'\
'example.com. IN SOA ns1.example.com. hostmaster.example.com. (\n'\
' {0:%Y%m%d%H} ; Serial Remember change serial each time u edit the file\n'\
' 604800 ; Refresh\n'\
' 86400 ; Retry\n'\
' 2419200 ; Expire\n'\
' 604800 ) ; Negative Cache TTL\n'\
';\n'\
'example.com. 1800 IN NS ns1.example.com.\n'\
';\n'\
'ns1.example.com. IN A 0.0.0.0\n'\
'mailgw.example.com. IN A {1}}\n'\
';\n'\
';example.com. 60 IN A {0}}\n'\
'example.com. 60 IN A {1}\n'\
';\n'\
'example.com. 60 IN MX 0 example.com.\n'\
';\n'\
'ada 60 IN CNAME example.com.\n'\
'mydata 60 IN CNAME example.com.\n'\
'mail 60 IN CNAME example.com.\n'\
'www 43200 IN CNAME example.com.\n'\
'hditsv 43200 IN CNAME example.com.\n'\
'nextcloud 60 IN CNAME example.com.\n'\
'example.com. 60 IN TXT "v=spf1 mx -all"\n'.format(datetime.now(), nip)
if re.match(r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$", nip):
os.remove(FILE)
with open(FILE, 'w')as f:
f.write(content)
os.system('rndc reload example.com')