diff --git a/bin/zsnapper b/bin/zsnapper index 879898a..43293b0 100644 --- a/bin/zsnapper +++ b/bin/zsnapper @@ -288,7 +288,8 @@ def weed_snapshots(fslist, snapshots, config, failed_snapshots): def main(): config = configparser.ConfigParser() - config.read('/etc/zsnapper.ini') + config.read('/usr/local/etc/zsnapper.ini', '/etc/zsnapper.ini') + ret = RET_CODES['SUCCESS'] log = logging.getLogger(LOGGER) @@ -403,9 +404,22 @@ if __name__ == '__main__': handler.setLevel(logging.WARNING) log.addHandler(handler) - handler = logging.handlers.SysLogHandler(address='/dev/log') - formatter = logging.Formatter(fmt='zsnapper[%(process)s] %(message)s') - handler.setFormatter(formatter) - handler.setLevel(logging.INFO) - log.addHandler(handler) + handler = None + for logsocket in ('/var/run/log', '/dev/log'): + try: + mode = os.stat(logsocket).st_mode + except FileNotFoundError: + continue + + if stat.S_ISSOCK(mode): + handler = logging.handlers.SysLogHandler(address=logsocket) + formatter = logging.Formatter(fmt='zsnapper[%(process)s] %(message)s') + handler.setFormatter(formatter) + handler.setLevel(logging.INFO) + log.addHandler(handler) + break + + if not handler: + log.warning('No syslog socket found, will not log to syslog') + sys.exit(main())