def generateDynamicVariableScript(): cfg_path = os.path.join(config.Config.broctlconfigdir, "broctl-config.sh") cfg_file = open(cfg_path, 'w') for substvartuple in config.Config.options(): substvar = substvartuple[0] # don't write out if it has an invalid bash variable name if not re.search("-", substvar): substvarvalue = substvartuple[1] cfg_file.write("%s=\"%s\"\n" % (substvar.replace(".", "_"), substvarvalue)) cfg_file.close() symlink = os.path.join(config.Config.scriptsdir, "broctl-config.sh") try: if os.readlink(symlink) != cfg_path: # attempt to update the symlink try: util.force_symlink(cfg_path, symlink) except OSError, e: util.error( "failed to update symlink '%s' to point to '%s': %s" % (symlink, cfg_path, e.strerror)) except OSError, e: util.error("error checking status of symlink '%s': %s" % (symlink, e.strerror))
def install(local_only): hadError = False config.Config.determineBroVersion() manager = config.Config.manager() # Delete previously installed policy files to not mix things up. policies = [config.Config.policydirsiteinstall, config.Config.policydirsiteinstallauto] for p in policies: if os.path.isdir(p): util.output("removing old policies in %s ..." % p, False) if not execute.rmdir(manager, p): hadError = True util.output(" done.") util.output("creating policy directories ...", False) for p in policies: if not execute.mkdir(manager, p): hadError = True util.output(" done.") # Install local site policy. if config.Config.sitepolicypath: util.output("installing site policies ...", False) dst = config.Config.policydirsiteinstall for dir in config.Config.sitepolicypath.split(":"): dir = config.Config.subst(dir) for file in glob.glob(os.path.join(dir, "*")): if not execute.install(manager, file, dst): hadError = True util.output(" done.") makeLayout(config.Config.policydirsiteinstallauto) if not makeLocalNetworks(config.Config.policydirsiteinstallauto): hadError = True makeConfig(config.Config.policydirsiteinstallauto) current = config.Config.subst(os.path.join(config.Config.logdir, "current")) try: util.force_symlink(manager.cwd(), current) except (IOError, OSError), e: util.error("failed to update current log symlink")
def install(local_only): config.Config.determineBroVersion() manager = config.Config.manager() # Delete previously installed policy files to not mix things up. policies = [ config.Config.policydirsiteinstall, config.Config.policydirsiteinstallauto ] for p in policies: if os.path.isdir(p): util.output("removing old policies in %s ..." % p, False) execute.rmdir(manager, p) util.output(" done.") util.output("creating policy directories ...", False) for p in policies: execute.mkdir(manager, p) util.output(" done.") # Install local site policy. if config.Config.sitepolicypath: util.output("installing site policies ...", False) dst = config.Config.policydirsiteinstall for dir in config.Config.sitepolicypath.split(":"): dir = config.Config.subst(dir) for file in glob.glob(os.path.join(dir, "*")): if execute.isfile(manager, file): execute.install(manager, file, dst) util.output(" done.") makeLayout(config.Config.policydirsiteinstallauto) makeLocalNetworks(config.Config.policydirsiteinstallauto) makeConfig(config.Config.policydirsiteinstallauto) current = config.Config.subst(os.path.join(config.Config.logdir, "current")) try: util.force_symlink(manager.cwd(), current) except (IOError, OSError), e: util.error("failed to update current log symlink")
def generateDynamicVariableScript(): cfg_path = os.path.join(config.Config.broctlconfigdir, "broctl-config.sh") cfg_file = open(cfg_path, 'w') for substvartuple in config.Config.options(): substvar = substvartuple[0] # don't write out if it has an invalid bash variable name if not re.search("-", substvar): substvarvalue = substvartuple[1] cfg_file.write("%s=\"%s\"\n" % (substvar.replace(".", "_"), substvarvalue)) cfg_file.close() symlink = os.path.join(config.Config.scriptsdir, "broctl-config.sh") try: if os.readlink(symlink) != cfg_path: # attempt to update the symlink try: util.force_symlink(cfg_path, symlink) except OSError, e: util.error("failed to update symlink '%s' to point to '%s': %s" % (symlink, cfg_path, e.strerror)) except OSError, e: util.error("error checking status of symlink '%s': %s" % (symlink, e.strerror))