final String dir = getComboBoxValue("directory").getValueForConfig();
boolean confirm = false; /* confirm only once */
for (final Host host : getBrowser().getClusterHosts()) {
final String statCmd = DistResource.SUDO + "stat -c \"%F\" " + dir + "||true";
final String text = statCmd.replaceAll(DistResource.SUDO, "");
final SshOutput ret = host.captureCommandProgressIndicator(text,
new ExecCommandConfig().command(statCmd));
if (ret == null || !"directory".equals(ret.getOutput().trim())) {
String title = Tools.getString("ClusterBrowser.CreateDir.Title");
String desc = Tools.getString("ClusterBrowser.CreateDir.Description");
title = title.replaceAll("@DIR@", dir);
title = title.replaceAll("@HOST@", host.getName());
desc = desc.replaceAll("@DIR@", dir);
desc = desc.replaceAll("@HOST@", host.getName());
if (confirm || application.confirmDialog(title,
desc,
Tools.getString("ClusterBrowser.CreateDir.Yes"),
Tools.getString("ClusterBrowser.CreateDir.No"))) {
final String cmd = DistResource.SUDO + "/bin/mkdir " + dir;
final String progressText = cmd.replaceAll(DistResource.SUDO, "");
final SshOutput out = host.captureCommandProgressIndicator(progressText,
new ExecCommandConfig().command(cmd));
confirm = true;
}
}
}