123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- #!@PYTHON@
- # Copyright (C) 2010 Internet Systems Consortium.
- #
- # Permission to use, copy, modify, and distribute this software for any
- # purpose with or without fee is hereby granted, provided that the above
- # copyright notice and this permission notice appear in all copies.
- #
- # THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SYSTEMS CONSORTIUM
- # DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
- # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
- # INTERNET SYSTEMS CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
- # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
- # FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
- # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
- # WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- # $Id$
- import sys; sys.path.append ('@@PYTHONPATH@@')
- from isc.config.cfgmgr import ConfigManager, ConfigManagerDataReadError
- from isc.cc import SessionError
- import signal
- import os
- # If B10_FROM_SOURCE is set in the environment, we use data files
- # from a directory relative to that, otherwise we use the ones
- # installed on the system
- if "B10_FROM_SOURCE" in os.environ:
- DATA_PATH = os.environ["B10_FROM_SOURCE"]
- else:
- PREFIX = "@prefix@"
- DATA_PATH = "@localstatedir@/@PACKAGE@".replace("${prefix}", PREFIX)
- cm = None
- def signal_handler(signal, frame):
- global cm
- if cm:
- cm.running = False
- def main():
- global cm
- try:
- cm = ConfigManager(DATA_PATH)
- signal.signal(signal.SIGINT, signal_handler)
- signal.signal(signal.SIGTERM, signal_handler)
- cm.read_config()
- cm.notify_boss()
- cm.run()
- except SessionError as se:
- print("[b10-cfgmgr] Error creating config manager, "
- "is the command channel daemon running?")
- return 1
- except KeyboardInterrupt as kie:
- print("[b10-cfgmgr] Interrupted, exiting")
- except ConfigManagerDataReadError as cmdre:
- print("[b10-cfgmgr] " + str(cmdre))
- return 2
- if cm:
- return cm.write_config()
- return 0
- if __name__ == "__main__":
- sys.exit(main())
|