|
|
@@ -19,6 +19,7 @@ import java.util.Objects;
|
|
|
@Slf4j
|
|
|
public class Sftp {
|
|
|
private final TextFile textFile = new TextFile();
|
|
|
+ private final String bash = "/usr/bin/bash";
|
|
|
|
|
|
public Session getSession(RemoteHost remoteHost) throws Exception {
|
|
|
String host = remoteHost.getHost();
|
|
|
@@ -207,10 +208,11 @@ public class Sftp {
|
|
|
Session session = getSession(remoteHost);
|
|
|
boolean exist = mkdir(session, remoteDir);
|
|
|
if (exist) {
|
|
|
- String command = String.format("cd %s && sh shutdown.sh", remoteDir);
|
|
|
+ String command = String.format("cd %s && %s shutdown.sh", remoteDir, bash);
|
|
|
ShellResult shellResult = exec(session, command);
|
|
|
if (!shellResult.isSuccess()) {
|
|
|
- log.info("shutdown application failed: {} - {}", shellResult.getExitCode(), shellResult.getResult());
|
|
|
+ log.info("shutdown application failed\nexitCode {}\nmsg:{}", shellResult.getExitCode(), shellResult.getResult());
|
|
|
+ System.exit(-1);
|
|
|
} else {
|
|
|
log.info("shutdown application successfully");
|
|
|
}
|
|
|
@@ -221,10 +223,11 @@ public class Sftp {
|
|
|
upload(session, localDir, remoteDir);
|
|
|
log.info("files uploaded");
|
|
|
|
|
|
- String command = String.format("cd %s && sh start.sh", remoteDir);
|
|
|
+ String command = String.format("cd %s && %s start.sh", remoteDir, bash);
|
|
|
ShellResult shellResult = exec(session, command);
|
|
|
if (!shellResult.isSuccess()) {
|
|
|
- log.info("start application failed: {} - {}", shellResult.getExitCode(), shellResult.getResult());
|
|
|
+ log.info("start application failed\nexitCode {}\nmsg:{}", shellResult.getExitCode(), shellResult.getResult());
|
|
|
+ System.exit(-1);
|
|
|
} else {
|
|
|
log.info("start application successfully");
|
|
|
}
|