private boolean isWindows() { return this.systemInfo.getOperatingSystemType() == OperatingSystemType.WINDOWS; }
Cli() { // When running the CLI on Windows, make sure no "pause" message is shown after script execution // Otherwise the CLI process will just keep running so we'll never get the exit code if (systemInfo.getOperatingSystemType() == OperatingSystemType.WINDOWS) { startScriptEnv.put("NOPAUSE", "1"); } }
private boolean isWindows(ResourceDiscoveryContext context) { return context.getSystemInformation().getOperatingSystemType() == OperatingSystemType.WINDOWS; }
public Map<String, String> getEnvironmentVariables() { if (this.procEnv == null) { return Collections.emptyMap(); } if (this.environmentVariables == null) { this.environmentVariables = new HashMap<String, String>(this.procEnv.size()); SystemInfo systemInfo = SystemInfoFactory.createJavaSystemInfo(); boolean isWindows = systemInfo.getOperatingSystemType() == OperatingSystemType.WINDOWS; if (isWindows) { // Windows environment is case-insensitive so convert variable names to all-caps, // this way we will be able to do case-insensitive lookups from the map later for (Map.Entry<String, String> env : this.procEnv.entrySet()) { this.environmentVariables.put(env.getKey().toUpperCase(), env.getValue()); } } else { this.environmentVariables.putAll(procEnv); } } return this.environmentVariables; }
public Map<String, String> getEnvironmentVariables() { if (this.procEnv == null) { return Collections.emptyMap(); } if (this.environmentVariables == null) { this.environmentVariables = new HashMap<String, String>(this.procEnv.size()); SystemInfo systemInfo = SystemInfoFactory.createJavaSystemInfo(); boolean isWindows = systemInfo.getOperatingSystemType() == OperatingSystemType.WINDOWS; if (isWindows) { // Windows environment is case-insensitive so convert variable names to all-caps, // this way we will be able to do case-insensitive lookups from the map later for (Map.Entry<String, String> env : this.procEnv.entrySet()) { this.environmentVariables.put(env.getKey().toUpperCase(), env.getValue()); } } else { this.environmentVariables.putAll(procEnv); } } return this.environmentVariables; }
/** * Retrieves a specific environment property if it exists, <code>null</code> otherwise. * * @param name the name of the property to find * * @return the environment value */ @Nullable public String getEnvironmentVariable(@NotNull String name) { if (this.procEnv == null) { return null; } SystemInfo systemInfo = SystemInfoFactory.createJavaSystemInfo(); boolean isWindows = systemInfo.getOperatingSystemType() == OperatingSystemType.WINDOWS; // Windows env names are case insensitive, so convert the specified name to all-caps before doing the lookup. return getEnvironmentVariables().get((isWindows) ? name.toUpperCase() : name); }
/** * Retrieves a specific environment property if it exists, <code>null</code> otherwise. * * @param name the name of the property to find * * @return the environment value */ @Nullable public String getEnvironmentVariable(@NotNull String name) { if (this.procEnv == null) { return null; } SystemInfo systemInfo = SystemInfoFactory.createJavaSystemInfo(); boolean isWindows = systemInfo.getOperatingSystemType() == OperatingSystemType.WINDOWS; // Windows env names are case insensitive, so convert the specified name to all-caps before doing the lookup. return getEnvironmentVariables().get((isWindows) ? name.toUpperCase() : name); }
if (systemInfo.getOperatingSystemType() == OperatingSystemType.WINDOWS && isBatchFile(file)) {
private ProcessExecutionResults startNode(File basedir) { if (log.isDebugEnabled()) { log.debug("Starting node at " + basedir); } File binDir = new File(basedir, "bin"); File startScript; SystemInfo systemInfo = SystemInfoFactory.createSystemInfo(); ProcessExecution startScriptExe; if (systemInfo.getOperatingSystemType() == OperatingSystemType.WINDOWS) { startScript = new File(binDir, "cassandra.bat"); startScriptExe = createProcessExecution(null, startScript); } else { startScript = new File(binDir, "cassandra"); startScriptExe = createProcessExecution(null, startScript); startScriptExe.addArguments(Arrays.asList("-p", "cassandra.pid")); } startScriptExe.setWaitForCompletion(0); ProcessExecutionResults results = systemInfo.executeProcess(startScriptExe); if (log.isDebugEnabled()) { log.debug(startScript + " returned with exit code [" + results.getExitCode() + "]"); } return results; }
/** * Runs the provided script against the server. * * @param scriptFile the script file to run * @return the execution results */ public ProcessExecutionResults executeCliScript(File scriptFile) { File homeDir = serverPluginConfig.getHomeDir(); File script = scriptFile; if (!script.isAbsolute()) { script = new File(homeDir, scriptFile.getPath()); } File executable = new File("bin", serverMode.getCliScriptFileName()); String connect = disconnected ? null : "--connect"; String file = "--file=" + script.getAbsolutePath(); String user = disconnected ? null : "--user=" + serverPluginConfig.getUser(); String password = disconnected ? null : "--password=" + serverPluginConfig.getPassword(); String controller = disconnected ? null : "--controller=" + serverPluginConfig.getNativeHost() + ":" + serverPluginConfig.getNativePort(); if (systemInfo.getOperatingSystemType() != OperatingSystemType.WINDOWS) { return execute(null, executable, connect, file, user, password, controller); } WinCliHelper cliHelper = new WinCliHelper(executable, connect, file, user, password, controller); return cliHelper.execute(); } }
tokens.put(TOKEN_PREFIX + "os.name", systemInfo.getOperatingSystemName()); tokens.put(TOKEN_PREFIX + "os.version", systemInfo.getOperatingSystemVersion()); tokens.put(TOKEN_PREFIX + "os.type", systemInfo.getOperatingSystemType().toString()); tokens.put(TOKEN_PREFIX + "architecture", systemInfo.getSystemArchitecture()); try {
tokens.put(TOKEN_PREFIX + "os.name", systemInfo.getOperatingSystemName()); tokens.put(TOKEN_PREFIX + "os.version", systemInfo.getOperatingSystemVersion()); tokens.put(TOKEN_PREFIX + "os.type", systemInfo.getOperatingSystemType().toString()); tokens.put(TOKEN_PREFIX + "architecture", systemInfo.getSystemArchitecture()); try {
AdditionalJavaOpts additionalJavaOptsConfig = null; if (OperatingSystemType.WINDOWS.equals(context.getSystemInformation().getOperatingSystemType())) { configFile = new File(binDirectory, "standalone.conf.bat"); additionalJavaOptsConfig = new AdditionalJavaOpts.WindowsConfiguration();
if (OperatingSystemType.WINDOWS.equals(resourceContext.getSystemInformation().getOperatingSystemType())) { configFile = new File(binDirectory, "standalone.conf.bat"); additionalJavaOptsConfig = new AdditionalJavaOpts.WindowsConfiguration();
/** * Runs (a series of) CLI commands against the server. * The commands are separated by either a newline or a comma (or a mix thereof). * * @param commands the commands to execute in order * @return the execution results */ public ProcessExecutionResults executeCliCommand(String commands) { File executable = new File("bin", serverMode.getCliScriptFileName()); String connect = disconnected ? null : "--connect"; commands = commands.replace('\n', ','); String user = disconnected ? null : "--user=" + serverPluginConfig.getUser(); String password = disconnected ? null : "--password=" + serverPluginConfig.getPassword(); String controller = disconnected ? null : "--controller=" + serverPluginConfig.getNativeHost() + ":" + serverPluginConfig.getNativePort(); if (systemInfo.getOperatingSystemType() != OperatingSystemType.WINDOWS) { return execute(null, executable, connect, commands, user, password, controller); } WinCliHelper cliHelper = new WinCliHelper(executable, connect, commands, user, password, controller); return cliHelper.execute(); }