Use ssh home property.

This commit is contained in:
Pavel Punegov
2019-03-20 14:01:23 +03:00
committed by Pavel Punegov
parent 3baee198fd
commit 98f86591f7
@@ -173,6 +173,7 @@ private fun sshExecutor(project: Project) : ExecutorService = object : ExecutorS
private val remote: String = project.property("remote").toString()
private val sshArgs: List<String> = System.getenv("SSH_ARGS")?.split(" ") ?: emptyList()
private val sshHome = System.getenv("SSH_HOME") ?: "/usr/bin"
// Unique remote dir name to be used in the target host
private val remoteDir = run {
@@ -191,7 +192,7 @@ private fun sshExecutor(project: Project) : ExecutorService = object : ExecutorS
upload(executable)
executable = "$remoteDir/${File(executable).name}"
execFile = executable
commandLine = arrayListOf("/usr/bin/ssh") + sshArgs + remote + commandLine
commandLine = arrayListOf("$sshHome/ssh") + sshArgs + remote + commandLine
}
}
cleanup(execFile!!)
@@ -200,19 +201,19 @@ private fun sshExecutor(project: Project) : ExecutorService = object : ExecutorS
private fun createRemoteDir() {
project.exec {
it.commandLine = arrayListOf("/usr/bin/ssh") + sshArgs + remote + "mkdir" + "-p" + remoteDir
it.commandLine = arrayListOf("$sshHome/ssh") + sshArgs + remote + "mkdir" + "-p" + remoteDir
}
}
private fun upload(fileName: String) {
project.exec {
it.commandLine = arrayListOf("/usr/bin/scp") + sshArgs + fileName + "$remote:$remoteDir"
it.commandLine = arrayListOf("$sshHome/scp") + sshArgs + fileName + "$remote:$remoteDir"
}
}
private fun cleanup(fileName: String) {
project.exec {
it.commandLine = arrayListOf("/usr/bin/ssh") + sshArgs + remote + "rm" + fileName
it.commandLine = arrayListOf("$sshHome/ssh") + sshArgs + remote + "rm" + fileName
}
}
}