@Override public boolean addModule(Module module) throws IOException { if (module.isDynamic()) { if (module.hasIniTemplate()) { // warn StartLog.warn("%-15s not adding [ini-template] from dynamic module", module.getName()); } return false; } String mode = ""; if (module.isTransitive()) { mode = "(transitively) "; } if (module.hasIniTemplate() || !module.isTransitive()) { // Create start.d/{name}.ini Path ini = startDir.resolve(module.getName() + ".ini"); StartLog.info("%-15s initialised %sin %s", module.getName(), mode, baseHome.toShortForm(ini)); try (BufferedWriter writer = Files.newBufferedWriter( ini, StandardCharsets.UTF_8, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING)) { writeModuleSection(writer, module); } return true; } return false; }
protected void writeModuleSection(BufferedWriter writer, Module module) { PrintWriter out = new PrintWriter(writer); out.println("# --------------------------------------- "); out.println("# Module: " + module.getName()); out.println("--module=" + module.getName()); out.println(); for (String line : module.getIniTemplate()) { out.println(line); } out.println(); out.flush(); }