X-Git-Url: https://git.adam-barratt.org.uk/?p=mirror%2Fuserdir-ldap.git;a=blobdiff_plain;f=ud-replicated;h=dd58a24ea5eeb803951635b19cd08940a34939fc;hp=8bef0a51d327fdeb18a6f140db908f63818f8759;hb=f8181b0dfa59390433a8329e61f0cfbc2f720644;hpb=d443df6cb43a527b8aee45f2127c44981b048c7c diff --git a/ud-replicated b/ud-replicated index 8bef0a5..dd58a24 100755 --- a/ud-replicated +++ b/ud-replicated @@ -31,6 +31,7 @@ import logging.handlers import optparse import os import platform +import stat import subprocess import sys import time @@ -65,7 +66,7 @@ SFORMAT='ud-replicated[%(process)s]: %(message)s' logging.basicConfig(format=FORMAT, level=lvl) LOG = logging.getLogger(__name__) logsock = '/dev/log' -if os.path.exists('/var/run/log'): # Kfreebsd randomly different +if os.path.exists('/var/run/log') and stat.S_ISSOCK(os.stat('/var/run/log').st_mode): # Kfreebsd randomly different logsock = '/var/run/log' syslog_handler = logging.handlers.SysLogHandler(address = logsock) formatter = logging.Formatter(SFORMAT) @@ -87,7 +88,7 @@ def do_replicate(message): timestamp = message.get('timestamp', last_update) message = message.get('message', 'update required') LOG.debug("Got message at %s: %s" % (last_update, message)) - if last_run > timestamp, last_update): + if last_run > timestamp: return command = ['/usr/bin/ud-replicate'] @@ -103,7 +104,8 @@ def do_replicate(message): else: LOG.debug('%s finished with ret: 0' % ' '.join(command)) finally: - os.environ['TERM'] = old_term + if old_term is not None: + os.environ['TERM'] = old_term last_run = last_update def main():