@Override public String toString() { return ln(template).formatByMap(tokens); } }
public static String i18n(String str, Map<String, String> args) { Map<String, String> nargs = new HashMap<>(); args.forEach((k, v) -> nargs.put(k, toI18nString(v))); return ln(toI18nString(str)).formatByMap(nargs); }
ScriptRunner(String script) { String remoteScript = ln( "/bin/bash << EOF", "cat << EOF1 > {remotePath}", "{scriptContent}", "EOF1", "/bin/bash {remotePath} 1>{stdout} 2>{stderr}", "ret=$?", "test -f {stdout} && cat {stdout}", "test -f {stderr} && cat {stderr} 1>&2", "rm -f {remotePath}", "rm -f {stdout}", "rm -f {stderr}", "exit $ret", "EOF" ).formatByMap(map(e("remotePath", String.format("/tmp/%s", UUID.randomUUID().toString())), e("scriptContent", script), e("stdout", String.format("/tmp/%s", UUID.randomUUID().toString())), e("stderr", String.format("/tmp/%s", UUID.randomUUID().toString())) )); scriptCommand = createCommand(remoteScript); }
scriptContent = s(contents).formatByMap(token); String remoteScript = ln( "/bin/bash << EOF", "cat << EOF1 > {remotePath}",
try { if (privateKeyFile != null) { ssh = ln( "ssh -i {0} -o UserKnownHostsFile=/dev/null -o PasswordAuthentication=no -o StrictHostKeyChecking=no -p {1} -T {2}@{3} << 'EOF'", "s=`mktemp`", tempPasswordFile = File.createTempFile("zstack", "tmp"); FileUtils.writeStringToFile(tempPasswordFile, password); ssh = ln( "sshpass -f{0} ssh -o UserKnownHostsFile=/dev/null -o PubkeyAuthentication=no -o StrictHostKeyChecking=no -p {1} -T {2}@{3} << 'EOF'", "s=`mktemp`",
@Deferred private void setupPublicKeyOnRemote() { String script = ln( "#!/bin/sh", "if [ ! -d ~/.ssh ]; then",
agentYamlContent = ln(agentYamlContent).formatByMap(map( e("remoteRoot", AgentConstant.DST_ANSIBLE_ROOT), e("srcRoot", srcRootFolder),