bind10_config.py.in 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # Copyright (C) 2010 Internet Systems Consortium.
  2. #
  3. # Permission to use, copy, modify, and distribute this software for any
  4. # purpose with or without fee is hereby granted, provided that the above
  5. # copyright notice and this permission notice appear in all copies.
  6. #
  7. # THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SYSTEMS CONSORTIUM
  8. # DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
  9. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
  10. # INTERNET SYSTEMS CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
  11. # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
  12. # FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
  13. # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  14. # WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. # This is a base-level module intended to provide configure-time
  16. # variables to python scripts and libraries.
  17. import os
  18. def reload():
  19. # In a function, for testing purposes
  20. global BIND10_MSGQ_SOCKET_FILE
  21. global DATA_PATH
  22. global PLUGIN_PATHS
  23. global PREFIX
  24. global LIBEXECPATH
  25. BIND10_MSGQ_SOCKET_FILE = os.path.join("@localstatedir@",
  26. "@PACKAGE_NAME@",
  27. "msgq_socket").replace("${prefix}",
  28. "@prefix@")
  29. PREFIX = "@prefix@"
  30. # B10_FROM_SOURCE is set in the environment for internal tests and
  31. # an experimental run without installagion. In that case we need to
  32. # specialize some configuration variables, generally so that they refer
  33. # to somewhere in the source tree instead of the appropriate places
  34. # after installation.
  35. #
  36. # DATA_PATH: used by the config manager to find configuration files.
  37. # When "FROM_SOURCE", we use data files from a directory relative to the
  38. # value of that variable, or, if defined, relative to the value of
  39. # B10_FROM_SOURCE_LOCALSTATEDIR. Otherwise we use the ones installed on
  40. # the system.
  41. # PLUGIN_PATHS: configuration modules that are not associated to specific
  42. # process
  43. # LIBEXECPATH: Paths to programs invoked by the boss process
  44. # The boss process (directly or via a helper module) uses this as
  45. # the prefererred PATH before starting a child process.
  46. # When "FROM_SOURCE", it lists the directories where the programs are
  47. # built so that when BIND 10 is experimentally started on the source
  48. # tree the programs in the tree (not installed ones) will be used.
  49. #
  50. # B10_FROM_SOURCE_LOCALSTATEDIR is specifically intended to be used for
  51. # tests where we want to use variuos types of configuration within the test
  52. # environment. (We may want to make it even more generic so that the path
  53. # is passed from the boss process)
  54. if "B10_FROM_SOURCE" in os.environ:
  55. if "B10_FROM_SOURCE_LOCALSTATEDIR" in os.environ:
  56. DATA_PATH = os.environ["B10_FROM_SOURCE_LOCALSTATEDIR"]
  57. else:
  58. DATA_PATH = os.environ["B10_FROM_SOURCE"]
  59. PLUGIN_PATHS = [os.environ["B10_FROM_SOURCE"] +
  60. '/src/bin/cfgmgr/plugins']
  61. programdirs = ['auth', 'cfgmgr', 'cmdctl', 'ddns', 'dhcp6', 'msgq',
  62. 'resolver', 'sockcreator', 'stats', 'xfrin', 'xfrout',
  63. 'zonemgr']
  64. LIBEXECPATH = ':'.join(['@abs_top_builddir@/src/bin/' + p for p in
  65. programdirs])
  66. else:
  67. DATA_PATH = "@localstatedir@/@PACKAGE@".replace("${prefix}", PREFIX)
  68. PLUGIN_PATHS = ["@prefix@/share/@PACKAGE@/config_plugins"]
  69. LIBEXECPATH = ("@libexecdir@/@PACKAGE@"). \
  70. replace("${exec_prefix}", "@exec_prefix@"). \
  71. replace("${prefix}", "@prefix@")
  72. # For testing the plugins so they can find their own spec files
  73. if "B10_TEST_PLUGIN_DIR" in os.environ:
  74. PLUGIN_PATHS = os.environ["B10_TEST_PLUGIN_DIR"].split(':')
  75. reload()