@Override public void install() { Maybe<Object> url = ((EntityInternal) getEntity()).config().getRaw(SoftwareProcess.DOWNLOAD_URL); if (url.isPresentAndNonNull()) { DownloadResolver resolver = Entities.newDownloader(this); List<String> urls = resolver.getTargets(); downloadedFilename = resolver.getFilename(); List<String> commands = new LinkedList<String>(); commands.addAll(BashCommands.commandsToDownloadUrlsAs(urls, downloadedFilename)); commands.addAll(ArchiveUtils.installCommands(downloadedFilename)); int result = newScript(ImmutableMap.of(INSTALL_INCOMPLETE, true), INSTALLING) .failOnNonZeroResultCode(false) .body .append(commands) .execute(); if (result != 0) { // could not install at remote machine; try resolving URL here and copying across for (String urlI : urls) { result = ArchiveUtils.install( getMachine(), urlI, Urls.mergePaths(getInstallDir(), downloadedFilename)); if (result == 0) break; } if (result != 0) throw new IllegalStateException("Error installing archive: " + downloadedFilename); } } // If downloadUrl did partial install (see INSTALL_INCOMPLETE above) then always execute install // so mark it as completed. String installCommand = getEntity().getConfig(VanillaSoftwareProcess.INSTALL_COMMAND); if (url.isPresentAndNonNull() && Strings.isBlank(installCommand)) installCommand = "# mark as complete"; if (Strings.isNonBlank(installCommand)) { newScript(INSTALLING) .failOnNonZeroResultCode() .environmentVariablesReset(getShellEnvironment()) .body .append(installCommand) .execute(); } }
@Override public void install() { String uploadUrl = entity.getConfig(BrooklynNode.DISTRO_UPLOAD_URL); // Need to explicitly give file, because for snapshot URLs you don't get a clean filename from // the URL. // This filename is used to generate the first URL to try: [BROOKLYN_VERSION_BELOW] // file://$HOME/.brooklyn/repository/BrooklynNode/0.9.0-SNAPSHOT/brooklynnode-0.8.0-snapshot.tar.gz // (DOWNLOAD_URL overrides this and has a default which comes from maven) List<String> urls = resolver.getTargets(); String saveAs = resolver.getFilename(); newScript("createInstallDir") .body .append("mkdir -p " + getInstallDir()) .failOnNonZeroResultCode() .execute(); List<String> commands = Lists.newArrayList(); // TODO use machine.installTo ... but that only works w a single location currently if (uploadUrl != null) { // Only upload if not already installed boolean exists = newScript("checkIfInstalled") .body .append("cd " + getInstallDir(), "test -f BROOKLYN") .execute() == 0; if (!exists) { InputStream distroStream = resource.getResourceFromUrl(uploadUrl); getMachine().copyTo(distroStream, getInstallDir() + "/" + saveAs); } } else { commands.addAll(BashCommands.commandsToDownloadUrlsAs(urls, saveAs)); } commands.add(BashCommands.INSTALL_TAR); commands.add("tar xzfv " + saveAs); newScript(INSTALLING).failOnNonZeroResultCode().body.append(commands).execute(); }