setExpandedInstallDir(Os.mergePaths(getInstallDir(), resolver.getUnpackedDirectoryName(format("docker-%s", getVersion()))));
}
@Override
public void install() {
OsDetails osDetails = getMachine().getMachineDetails().getOsDetails();
String osVersion = osDetails.getVersion();
String arch = osDetails.getArch();
if (!osDetails.is64bit()) {
throw new IllegalStateException("Docker supports only 64bit OS");
}
if (osDetails.getName().equalsIgnoreCase("ubuntu") && osVersion.equals("12.04")) {
List<String> commands = ImmutableList.<String>builder().add(installPackage("linux-image-generic-lts-raring"))
.add(installPackage("linux-headers-generic-lts-raring"))
.add(sudo("reboot"))
.build();
executeKernelInstallation(commands);
}
if (osDetails.getName().equalsIgnoreCase("centos")) {
List<String> commands = ImmutableList.<String>builder()
.add(sudo("yum -y --nogpgcheck upgrade kernel"))
.add(sudo("reboot"))
.build();
executeKernelInstallation(commands);
}
log.info("waiting for Docker host {} to be sshable", getLocation());
boolean isSshable = Repeater.create()
.every(Duration.TEN_SECONDS)
.until(new Callable<Boolean>() {
public Boolean call() {
return getLocation().isSshable();
}
})
.limitTimeTo(Duration.minutes(15)) // Because of the reboot
.run();
if (!isSshable) {
throw new IllegalStateException(String.format("The entity %s is not ssh'able after reboot", entity));
}
log.info("Docker host {} is now sshable; continuing with setup", getLocation());
List<String> commands = Lists.newArrayList();
if (osDetails.getName().equalsIgnoreCase("ubuntu")) {
commands.add(installDockerOnUbuntu());
} else if (osDetails.getName().equalsIgnoreCase("centos")) {
commands.add(ifExecutableElse0("yum", useYum(osVersion, arch, getEpelRelease())));
commands.add(installPackage(ImmutableMap.of("yum", "docker-io"), null));
} else {
commands.add(installDockerFallback());
}