@Override public String apply(@Nullable String dir) { return ifExecutableElse1(Urls.mergePaths(dir, filename), chainGroup("echo 'found "+filename+" in "+dir+" so linking to it in "+linkToMake+"'", "ln -s "+dir+" "+linkToMake)); } };
@Beta // implementation not portable across distros public static String iptablesService(String cmd) { return sudo(alternatives( BashCommands.ifExecutableElse1("service", "service iptables " + cmd), "/sbin/service iptables " + cmd)); }
@Beta // implementation not portable across distros public static String firewalldService(String cmd) { return sudo(alternatives( BashCommands.ifExecutableElse1("systemctl", "systemctl " + cmd + " firewalld"), "/usr/bin/systemctl " + cmd + " firewalld")); }
private String setupYumRepo(SshMachineLocation sshMachineLocation) { final String osDetailsVersion = getOsVersion(sshMachineLocation); String repoUrl; if (osDetailsVersion.startsWith("7")) { repoUrl = CENTOS_7_AMBARI_REPO_LOCATION; } else if (osDetailsVersion.startsWith("6")) { repoUrl = CENTOS_6_AMBARI_REPO_LOCATION; } else { repoUrl = CENTOS_5_AMBARI_REPO_LOCATION; } return ifExecutableElse1("yum", sudo(commandToDownloadUrlAs(String.format(repoUrl, repoBaseUrl, getMajorVersion(), version), CENTOS_REPO_LIST_LOCATION))); }
private String setupZypperRepo() { return ifExecutableElse1("zypper", sudo(commandToDownloadUrlAs(String.format(SUSE_AMBARI_REPO_LOCATION, repoBaseUrl, getMajorVersion(), version), SUSE_REPO_LIST_LOCATION))); }
private String setupAptRepo(SshMachineLocation sshMachineLocation) { final String osDetailsVersion = getOsVersion(sshMachineLocation); String repoUrl; if (osDetailsVersion.startsWith("14")) { repoUrl = UBUNTU_14_AMBARI_REPO_LOCATION; } else { repoUrl = UBUNTU_12_AMBARI_REPO_LOCATION; } return ifExecutableElse1("apt-get", chainGroup(sudo(commandToDownloadUrlAs(String.format(repoUrl, repoBaseUrl, getMajorVersion(), version), UBUNTU_REPO_LIST_LOCATION)), sudo("apt-key adv --recv-keys --keyserver keyserver.ubuntu.com B9733A7A07513CAD"), sudo("apt-get update"))); }
commands.add(format("which %s", ifMissing)); if (zypperInstall != null) commands.add(ifExecutableElse1("zypper", chainGroup( "echo zypper exists, doing refresh", sudo(zypperInstall)))); if (aptInstall != null) commands.add(ifExecutableElse1("apt-get", chainGroup( "echo apt-get exists, doing update", commands.add(ifExecutableElse1("yum", chainGroup( "echo yum exists, doing update", sudo(yumInstall)))); if (brewInstall != null) commands.add(ifExecutableElse1("brew", brewInstall)); if (portInstall != null) commands.add(ifExecutableElse1("port", sudo(portInstall)));
/** * Install a particular Java runtime, fails if not possible. * <p> * <em><strong>Note</strong> Java 8 is not yet supported on SUSE</em> * * @return The command to install the given Java runtime. * @see #installJava6OrFail() * @see #installJava7Or6OrFail() * @see #installJavaLatestOrFail() */ public static String installJava(int version) { Preconditions.checkArgument(version == 6 || version == 7 || version == 8, "Supported Java versions are 6, 7, or 8"); List<String> commands = new LinkedList<String>(); commands.add(ok(addOpenJDKPPK())); commands.add(installPackageOr(MutableMap.of("apt", "openjdk-" + version + "-jdk","yum", "java-1." + version + ".0-openjdk-devel"), null, ifExecutableElse1("zypper", chainGroup( ok(sudo("zypper --non-interactive addrepo http://download.opensuse.org/repositories/Java:/openjdk6:/Factory/SLE_11_SP3 java_sles_11")), ok(sudo("zypper --non-interactive addrepo http://download.opensuse.org/repositories/Java:/openjdk6:/Factory/openSUSE_11.4 java_suse_11")), ok(sudo("zypper --non-interactive addrepo http://download.opensuse.org/repositories/Java:/openjdk6:/Factory/openSUSE_12.3 java_suse_12")), ok(sudo("zypper --non-interactive addrepo http://download.opensuse.org/repositories/Java:/openjdk6:/Factory/openSUSE_13.1 java_suse_13")), alternatives(installPackageOrFail(MutableMap.of("zypper", "java-1_" + version + "_0-openjdk-devel"), null), installPackageOrFail(MutableMap.of("zypper", "java-1_" + version + "_0-ibm"), null)))))); commands.add(ok(upgradeNSS())); return chainGroup(commands); }
commands.add(installDockerOnUbuntu()); } else if ("centos".equalsIgnoreCase(osDetails.getName())) { // should work for RHEL also? commands.add(ifExecutableElse1("yum", useYum(osVersion, arch, getEpelRelease()))); commands.add(installPackage(ImmutableMap.of("yum", "docker-io"), null)); commands.add(sudo(format("curl https://get.docker.com/builds/Linux/x86_64/docker-%s -o /usr/bin/docker", getVersion())));
.append(ifExecutableElse1("pg_ctl", chainGroup( "PG_EXECUTABLE=`which pg_ctl`", "PG_DIR=`dirname $PG_EXECUTABLE`",