コード例 #1
0
 static String makeCommandExecutingInDirectory(
     String command, String executionDir, EntityLocal entity) {
   String finalCommand = command;
   String execDir = executionDir;
   if (Strings.isBlank(execDir)) {
     // default to run dir
     execDir = entity.getAttribute(SoftwareProcess.RUN_DIR);
     // if no run dir, default to home
     if (Strings.isBlank(execDir)) {
       execDir = "~";
     }
   } else if (!Os.isAbsolutish(execDir)) {
     // relative paths taken wrt run dir
     String runDir = entity.getAttribute(SoftwareProcess.RUN_DIR);
     if (!Strings.isBlank(runDir)) {
       execDir = Os.mergePaths(runDir, execDir);
     }
   }
   if (!"~".equals(execDir)) {
     finalCommand = "mkdir -p '" + execDir + "' && cd '" + execDir + "' && " + finalCommand;
   }
   return finalCommand;
 }
コード例 #2
0
 protected static String resolveAgainstBaseDir(StringConfigMap brooklynProperties, String path) {
   if (!Os.isAbsolutish(path)) path = Os.mergePaths(getMgmtBaseDir(brooklynProperties), path);
   return Os.tidyPath(path);
 }