logging and rndc

This commit is contained in:
Wolfgang Hottgenroth 2019-11-28 14:33:23 +01:00
parent 17fd417d52
commit 055afe70e3
Signed by: wn
GPG Key ID: 6C1E5E531E0D5D7F
5 changed files with 15 additions and 16 deletions

View File

@ -29,6 +29,7 @@ RUN \
apt install -y netcat && \ apt install -y netcat && \
echo "include \"/etc/bind/local.key\";" >> /etc/bind/named.conf && \ echo "include \"/etc/bind/local.key\";" >> /etc/bind/named.conf && \
echo "include \"/etc/bind/dynamic/dynamic-zones.conf\";" >> /etc/bind/named.conf && \ echo "include \"/etc/bind/dynamic/dynamic-zones.conf\";" >> /etc/bind/named.conf && \
echo "include \"/etc/bind/named.conf.rndc\";" >> /etc/bind/named.conf && \
echo "include \"/etc/bind/named.conf.logging\";" >> /etc/bind/named.conf echo "include \"/etc/bind/named.conf.logging\";" >> /etc/bind/named.conf
COPY ./server/ $APP_DIR COPY ./server/ $APP_DIR

View File

@ -1,5 +1,6 @@
logging { logging {
category default { default_logfile; }; category default { default_logfile; };
category queries { default_logfile; };
channel default_logfile { channel default_logfile {
file "/opt/app/var/log/named.log"; file "/opt/app/var/log/named.log";
print-time yes; print-time yes;

View File

@ -1,25 +1,21 @@
import syslog
import sys import sys
class Logger(object): class Logger(object):
@staticmethod @staticmethod
def log(data): def log(data):
syslog.syslog(syslog.LOG_INFO, data) with open(Logger.filename, 'a') as f:
if Logger.debugFlag: f.write(data)
# print data
sys.stderr.write(data)
@staticmethod @staticmethod
def debug(data): def debug(data):
if Logger.debugFlag: if Logger.debugFlag:
syslog.syslog(syslog.LOG_DEBUG, data) with open(Logger.filename, 'a') as f:
# print data f.write(data)
sys.stderr.write(data)
@staticmethod @staticmethod
def openlog(): def openlog(filename):
syslog.openlog('yadyn', syslog.LOG_PID, syslog.LOG_LOCAL0) Logger.filename = filename
@staticmethod @staticmethod
def debugEnable(): def debugEnable():
@ -30,4 +26,4 @@ class Logger(object):
Logger.debugFlag = False Logger.debugFlag = False
debugFlag = False debugFlag = False
filename = '/tmp/yadyn.log'

View File

@ -48,6 +48,7 @@ PID_FILE = "/var/run/yadyn.pid"
ENTRIES_FILE = "/opt/app/var/data/entries" ENTRIES_FILE = "/opt/app/var/data/entries"
CUSTOMERS_FILE = "/opt/app/var/data/customers" CUSTOMERS_FILE = "/opt/app/var/data/customers"
ACTIONLOG_DIR = "/opt/app/var/log/actionlog" ACTIONLOG_DIR = "/opt/app/var/log/actionlog"
LOG_FILE = "/opt/app/var/log/yadyn.log"
ADMIN_PWD = 'test123' ADMIN_PWD = 'test123'
DNS_DUMMY = False DNS_DUMMY = False
DEBUG = True DEBUG = True
@ -69,7 +70,7 @@ if pid:
Logger.openlog() Logger.openlog(LOG_FILE)
if DEBUG: if DEBUG:
Logger.debugEnable() Logger.debugEnable()

View File

@ -5,10 +5,10 @@ echo "Generating tsig key ..."
KEY=`cat /etc/bind/local.key | awk -F\" '/secret/ {print $2}'` KEY=`cat /etc/bind/local.key | awk -F\" '/secret/ {print $2}'`
sed -i "s,KEYVALUE,$KEY," /opt/app/yadyn sed -i "s,KEYVALUE,$KEY," /opt/app/yadyn
# echo "Generating rndc key ..." echo "Generating rndc key ..."
# /usr/sbin/rndc-confgen > /etc/bind/rndc.conf /usr/sbin/rndc-confgen -a
# KEY=`cat /etc/bind/rndc.conf | egrep "^\s*secret" | awk -F\" '{print $2}'` KEY=`cat /etc/bind/rndc.key | awk -F\" '/secret/ {print $2}'`
# sed -i "s,RNDCKEY,$KEY," /etc/bind/named.conf.rndc sed -i "s,RNDCKEY,$KEY," /etc/bind/named.conf.rndc
echo "Starting named ..." echo "Starting named ..."
/usr/sbin/named /usr/sbin/named