public static ScriptBuilder makeInitScriptStatement(String instanceName, String instanceHome, String logDir,
Map<String, String> exports, StatementList init, StatementList run) {
Map<String, String> defaultExports = ImmutableMap.of("INSTANCE_NAME", instanceName, "INSTANCE_HOME", instanceHome,
"LOG_DIR", logDir);
String exitStatusFile = format("%s/rc", logDir);
run = new StatementList(ImmutableList.<Statement> builder().add(interpret("rm -f " + exitStatusFile))
.add(interpret(format("trap 'echo $?>%s' 0 1 2 3 15", exitStatusFile))).addAll(run.delegate()).build());
CreateRunScript createRunScript = createRunScript(instanceName,
concat(exports.keySet(), defaultExports.keySet()), "{varl}INSTANCE_HOME{varr}", run);