diff --git a/build.gradle b/build.gradle index bf759d2..153431f 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ plugins { } group 'com.hi.dhl' -version '2.3' +version '2.4' repositories { mavenLocal() @@ -103,6 +103,10 @@ patchPluginXml { + Version 2.4 + """ } diff --git a/src/main/java/com/hi/dhl/console/CommandManager.kt b/src/main/java/com/hi/dhl/console/CommandManager.kt index d4710cd..46dc3d3 100644 --- a/src/main/java/com/hi/dhl/console/CommandManager.kt +++ b/src/main/java/com/hi/dhl/console/CommandManager.kt @@ -157,10 +157,11 @@ object CommandManager { || password.equals(R.String.ui.tfRemotePassword)) { return "" } else { - return "set +e;chmod 777 ${shellInstallSshpass} && bash ${shellInstallSshpass} && sshpass -p '${remoteMachineInfo.remoteUserPassword}' " + return "set +e;chmod 777 ${shellInstallSshpass} && bash ${shellInstallSshpass}; ${getSshpassPath()} -p '${remoteMachineInfo.remoteUserPassword}' " } } + fun getSshpassPath() = "/usr/local/bin/sshpass" fun makeSshpassCommand(remoteMachineInfo: RemoteMachineInfo): String{ if (SystemInfoRt.isWindows) { @@ -172,7 +173,7 @@ object CommandManager { ) { return "" } else { - return "sshpass -p '${remoteMachineInfo.remoteUserPassword}' " + return "${getSshpassPath()} -p '${remoteMachineInfo.remoteUserPassword}' " } } diff --git a/src/main/java/com/hi/dhl/ext/PluginVersion.kt b/src/main/java/com/hi/dhl/ext/PluginVersion.kt index 602debb..cb17b65 100644 --- a/src/main/java/com/hi/dhl/ext/PluginVersion.kt +++ b/src/main/java/com/hi/dhl/ext/PluginVersion.kt @@ -17,7 +17,8 @@ object PluginVersion { val VERSION_2_1 = "2.1" val VERSION_2_2 = "2.2" val VERSION_2_3 = "2.3" - val CURRENT_VERSION = VERSION_2_3 + val VERSION_2_4 = "2.4" + val CURRENT_VERSION = VERSION_2_4 } fun upgrad(localProjectBasePath: String) { diff --git a/src/main/java/com/hi/dhl/utils/ExecutableUtils.kt b/src/main/java/com/hi/dhl/utils/ExecutableUtils.kt index 55d6023..de1582d 100644 --- a/src/main/java/com/hi/dhl/utils/ExecutableUtils.kt +++ b/src/main/java/com/hi/dhl/utils/ExecutableUtils.kt @@ -15,11 +15,20 @@ object ExecutableUtils { fun findExecutable(): String { LogUtils.logI(executablePath) - if (!executablePath.isNullOrEmpty()) { + if (!executablePath.isEmpty()) { return executablePath } - executablePath = findExecutableOnPath("bash") - return if (!executablePath.isNullOrEmpty()) executablePath else "/bin/bash" + if (compareVersion(SystemInfoRt.OS_VERSION, "10.15.0") >= 0) { + executablePath = findExecutableOnPath("zsh") + if (executablePath.isEmpty()) { + executablePath = findExecutableOnPath("bash") + } + } else { + executablePath = findExecutableOnPath("bash") + } + return if (!executablePath.isEmpty()) executablePath + else if (compareVersion(SystemInfoRt.OS_VERSION, "10.15.0") >= 0) "/bin/zsh" + else "/bin/bash" } fun findExecutableOnPath(name: String): String { @@ -36,4 +45,30 @@ object ExecutableUtils { return "" } + fun compareVersion(version1: String?, version2: String?): Int { + if (version1 == null || version2 == null) { + return -1 + } + val versions1 = version1.split(".") + val versions2 = version2.split(".") + var index = 0 + val minLength = Math.min(versions1.size, versions2.size) + var diff = 0 + + while (index < minLength + && (versions1[index].length - versions2[index].length) == 0 + && versions1[index].compareTo(versions2[index]) == 0 + ) { + ++index + } + if(index < minLength){ + diff = versions1[index].compareTo(versions2[index]) + } + return diff + } +} + +fun main() { + val result = ExecutableUtils.compareVersion("10.15.7" ,"10.14.7"); + println(result) } \ No newline at end of file