Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions core/src/main/groovy/noe/common/utils/Cmd.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

/**
Expand Down
36 changes: 23 additions & 13 deletions core/src/main/groovy/noe/common/utils/JBFile.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/groovy/noe/server/ServerAbstract.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down