@@ -274,17 +274,22 @@ public void installDependencies(HostDTO hostDTO, String hostname, InstalledStatu
274274 try {
275275 String script = ProjectPathUtils .getServerScriptPath () + File .separator + "setup-agent.sh" ;
276276 String content = Files .readString (Path .of (script ));
277- command = "cat << 'EOF' > ./setup-agent.sh\n "
278- + content
279- + "\n EOF\n "
280- + "chmod +x ./setup-agent.sh && ./setup-agent.sh " + path + " " + repoUrl + " " + grpcPort ;
277+ command = "cat << 'EOF' > ./setup-agent.sh\n " + content + "\n EOF\n " + "chmod +x ./setup-agent.sh" ;
278+ ShellResult result = execCommandOnRemoteHost (hostDTO , hostname , command );
279+ if (result .getExitCode () != MessageConstants .SUCCESS_CODE ) {
280+ log .error ("Unable to write agent script, hostname: {}, msg: {}" , hostname , result );
281+ installedStatusVO .setStatus (InstalledStatusEnum .FAILED );
282+ installedStatusVO .setMessage (result .getErrMsg ());
283+ return ;
284+ }
281285 } catch (IOException e ) {
282286 log .error ("Unable to write agent script, hostname: {}, msg: {}" , hostname , e .getMessage ());
283287 installedStatusVO .setStatus (InstalledStatusEnum .FAILED );
284288 installedStatusVO .setMessage (e .getMessage ());
285289 return ;
286290 }
287291
292+ command = "./setup-agent.sh " + path + " " + repoUrl + " " + grpcPort ;
288293 ShellResult result = execCommandOnRemoteHost (hostDTO , hostname , command );
289294 if (result .getExitCode () != MessageConstants .SUCCESS_CODE ) {
290295 log .error ("Unable to setup agent, hostname: {}, msg: {}" , hostname , result );
0 commit comments