import textwrap
import ipaddress
import stat
+import shutil
# Third party modules
import six
from .pidfile import PidFileError, InvalidPidFileError, PidFileInUseError, PidFile
-__version__ = '0.6.4'
+__version__ = '0.6.5'
LOG = logging.getLogger(__name__)
self.temp_log_cfg_file = None
self.temp_zones_cfg_file = None
+ self.backup_suffix = (
+ '.' + datetime.datetime.utcnow().strftime('%Y-%m-%d_%H-%M-%S') + '.bak')
+
self.reload_necessary = False
self.restart_necessary = False
self.files2replace = {}
+ self.moved_files = {}
self.acls = {
'allow-notify': ['dnsmaster.pixelpark.com'],
self.create_temp_files()
self.compare_files()
self.check_directories()
+ self.replace_configfiles()
finally:
if self.tempdir:
return True
+ # -------------------------------------------------------------------------
+ def replace_configfiles(self):
+
+ if not self.files2replace:
+ LOG.debug("No replacement of any config files necessary.")
+ return
+
+ LOG.debug("Start replacing of config files ...")
+
+ for tgt_file in self.files2replace.keys():
+
+ backup_file = tgt_file + self.backup_suffix
+ self.moved_files[tgt_file] = backup_file
+
+ if os.path.exists(tgt_file):
+ LOG.info("Copying {!r} => {!r} ...".format(tgt_file, backup_file))
+ if not self.simulate:
+ shutil.copy2(tgt_file, backup_file)
+
+ for tgt_file in self.files2replace.keys():
+ src_file = self.files2replace[tgt_file]
+ LOG.info("Copying {!r} => {!r} ...".format(src_file, tgt_file))
+ if not self.simulate:
+ shutil.copy2(src_file, tgt_file)
+
# =============================================================================
if __name__ == "__main__":