diff --git a/core/src/main/groovy/noe/common/utils/Cmd.groovy b/core/src/main/groovy/noe/common/utils/Cmd.groovy index a5e28f7d..2d791149 100644 --- a/core/src/main/groovy/noe/common/utils/Cmd.groovy +++ b/core/src/main/groovy/noe/common/utils/Cmd.groovy @@ -240,8 +240,23 @@ public class Cmd { * * @deprecated args */ - public static int executeCommand(command, File targetDir, Map args = null, Map tmpProps = null) { - return executeCommandRedirectIO(command, targetDir, null, System.out, System.err, args, tmpProps) + static int executeCommand(command, File targetDir, Map args = null, Map tmpProps = null) { + + if (command instanceof String || command instanceof GString) { + if (command.length() > 2 && command[0] == "[" && command[command.length() - 1] == "]") { + command = command[1..command.length() - 2] + } + command = command.tokenize(", ") + } + + Map rv = executeCommandConsumeStreams(command as List, targetDir, null, 60000L, tmpProps) + if (!rv.stdOut.isEmpty()) { + log.info(rv.stdOut) + } + if (!rv.stdErr.isEmpty()) { + log.trace(rv.stdErr) + } + return rv.exitValue } /** diff --git a/core/src/main/groovy/noe/common/utils/JBFile.groovy b/core/src/main/groovy/noe/common/utils/JBFile.groovy index c6423cc8..fc6e573b 100644 --- a/core/src/main/groovy/noe/common/utils/JBFile.groovy +++ b/core/src/main/groovy/noe/common/utils/JBFile.groovy @@ -186,21 +186,31 @@ class JBFile { } def returnValue = 0 - try { - // try to copy with ant - ant.copy(file: src.getAbsolutePath(), tofile: dest.getAbsolutePath(), overwrite: "true") - } catch (e) { - // Try it with sudo rights - if (!platform.isWindows()) { - def args = (preserveRights) ? '-p' : '' - args += (dereference) ? ' -L' : '' - if (useAdminPrivileges) { - returnValue += Cmd.executeSudoCommand("cp -r ${args} ${src.absolutePath} ${dest}", new File('.')) - } else { - returnValue += Cmd.executeCommand("cp -r ${args} ${src.absolutePath} ${dest}", new File('.')) + if (platform.isWindows()) { + File absDest = src.isDirectory() ? new File(dest, src.name) : dest + def command = ["xcopy", "${src.absolutePath}", absDest.absolutePath, "/H", "/S", "/E", "/I", "/Y", "/C", "/F", "/R", "/K", "/X"] + returnValue = Cmd.executeCommand(command, new File('.')) + if (returnValue > 0) { + try { + // try to copy with ant + if (src.isDirectory()) { + ant.copy(todir: dest.getAbsolutePath(), overwrite: true) { fileset(dir: src.getAbsolutePath()) } + } else { + ant.copy(file: src.getAbsolutePath(), todir: dest.getAbsolutePath(), overwrite: "true") + } + returnValue = 0 + } catch (e) { + log.trace("JBFIle.copy with ant failed", e) + returnValue = 2 } + } + } else { + def args = (preserveRights) ? '-p' : '' + args += (dereference) ? ' -L' : '' + if (useAdminPrivileges) { + returnValue += Cmd.executeSudoCommand("cp -r ${args} ${src.absolutePath} ${dest}", new File('.')) } else { - returnValue = -1 + returnValue += Cmd.executeCommand("cp -r ${args} ${src.absolutePath} ${dest}", new File('.')) } } return returnValue == 0 diff --git a/core/src/main/groovy/noe/server/ServerAbstract.groovy b/core/src/main/groovy/noe/server/ServerAbstract.groovy index 7a90c0fc..52f3d064 100644 --- a/core/src/main/groovy/noe/server/ServerAbstract.groovy +++ b/core/src/main/groovy/noe/server/ServerAbstract.groovy @@ -32,7 +32,7 @@ abstract class ServerAbstract implements IApp { //TODO: EWS specific, pls remove. Boolean ignoreShutdownPort /// def start ///standard startup command (apachectl start) - def stop ///standard shutdown command (apachectl stop) + String stop ///standard shutdown command (apachectl stop) String binPath // relative path (server root) to dir where stop handler is stored List configDirs = [] // relative paths to dir where server config files are stored List logDirs = [] // relative paths to dir where server logs are stored