<commit_before>/*
 * Copyright (c) 2014-2015 University of Ulm
 *
 * See the NOTICE file distributed with this work for additional information
 * regarding copyright ownership.  Licensed under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package components.installer;

import de.uniulm.omi.cloudiator.sword.api.remote.RemoteConnection;
import de.uniulm.omi.cloudiator.sword.api.remote.RemoteException;
import models.Tenant;
import models.VirtualMachine;
import play.Logger;
import play.Play;


/**
 * Created by <NAME> on 19.05.2015.
 */
public class UnixInstaller extends AbstractInstaller {

    protected final String homeDir;
    private static final String JAVA_ARCHIVE = "jre8.tar.gz";
    private static final String JAVA_DOWNLOAD =
        Play.application().configuration().getString("colosseum.installer.linux.java.download");
    private static final String DOCKER_DOWNLOAD = Play.application().configuration()
        .getString("colosseum.installer.linux.lance.docker.download");
    private static final String DOCKER_INSTALL = "docker_install.sh";

    public UnixInstaller(RemoteConnection remoteConnection, VirtualMachine virtualMachine,
        Tenant tenant) {
        super(remoteConnection, virtualMachine, tenant);

        this.homeDir = "~";
    }

    @Override public void initSources() {

        //java
        this.sourcesList
            .add("wget " + UnixInstaller.JAVA_DOWNLOAD + " -O " + UnixInstaller.JAVA_ARCHIVE);
        //lance
        this.sourcesList
            .add("wget " + UnixInstaller.LANCE_DOWNLOAD + " -O " + UnixInstaller.LANCE_JAR);
        //docker
        this.sourcesList
            .add("wget " + UnixInstaller.DOCKER_DOWNLOAD + " -O " + UnixInstaller.DOCKER_INSTALL);
        //kairosDB
        this.sourcesList.add(
            "wget " + UnixInstaller.KAIROSDB_DOWNLOAD + " -O " + UnixInstaller.KAIROSDB_ARCHIVE);
        //visor
        this.sourcesList
            .add("wget " + UnixInstaller.VISOR_DOWNLOAD + " -O " + UnixInstaller.VISOR_JAR);

    }



    @Override public void installJava() throws RemoteException {

        Logger.debug("Starting Java installation...");
        //create directory
        this.remoteConnection.executeCommand("mkdir " + UnixInstaller.JAVA_DIR);
        //extract java
        this.remoteConnection.executeCommand(
            "tar zxvf " + UnixInstaller.JAVA_ARCHIVE + " -C " + UnixInstaller.JAVA_DIR
                + " --strip-components=1");
        //set symbolic link
        this.remoteConnection.executeCommand(
            "sudo ln -s " + this.homeDir + "/" + UnixInstaller.JAVA_DIR
                + "/bin/java /usr/bin/java");
        Logger.debug("Java was successfully installed!");
    }

    @Override public void installVisor() throws RemoteException {

        Logger.debug("setting up Visor...");
<commit_msg>PS-92 changed unix download command from wget to curl<commit_after>/*
 * Copyright (c) 2014-2015 University of Ulm
 *
 * See the NOTICE file distributed with this work for additional information
 * regarding copyright ownership.  Licensed under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package components.installer;

import de.uniulm.omi.cloudiator.sword.api.remote.RemoteConnection;
import de.uniulm.omi.cloudiator.sword.api.remote.RemoteException;
import models.Tenant;
import models.VirtualMachine;
import play.Logger;
import play.Play;


/**
 * Created by <NAME> on 19.05.2015.
 */
public class UnixInstaller extends AbstractInstaller {

    protected final String homeDir;
    private static final String JAVA_ARCHIVE = "jre8.tar.gz";
    private static final String JAVA_DOWNLOAD =
        Play.application().configuration().getString("colosseum.installer.linux.java.download");
    private static final String DOCKER_DOWNLOAD = Play.application().configuration()
        .getString("colosseum.installer.linux.lance.docker.download");
    private static final String DOCKER_INSTALL = "docker_install.sh";

    public UnixInstaller(RemoteConnection remoteConnection, VirtualMachine virtualMachine,
        Tenant tenant) {
        super(remoteConnection, virtualMachine, tenant);

        this.homeDir = "~";
    }

    @Override public void initSources() {

        //java
        this.sourcesList
                .add("curl " + UnixInstaller.JAVA_DOWNLOAD + "  -o " + UnixInstaller.JAVA_ARCHIVE);
        //lance
        this.sourcesList
                .add("curl " + UnixInstaller.LANCE_DOWNLOAD + "  -o " + UnixInstaller.LANCE_JAR);
        //docker
        this.sourcesList
                .add("curl " + UnixInstaller.DOCKER_DOWNLOAD + "  -o " + UnixInstaller.DOCKER_INSTALL);
        //kairosDB
        this.sourcesList.
                add("curl " + UnixInstaller.KAIROSDB_DOWNLOAD + "  -o " + UnixInstaller.KAIROSDB_ARCHIVE);
        //visor
        this.sourcesList
                .add("curl " + UnixInstaller.VISOR_DOWNLOAD + "  -o " + UnixInstaller.VISOR_JAR);

    }



    @Override public void installJava() throws RemoteException {

        Logger.debug("Starting Java installation...");
        //create directory
        this.remoteConnection.executeCommand("mkdir " + UnixInstaller.JAVA_DIR);
        //extract java
        this.remoteConnection.executeCommand(
            "tar zxvf " + UnixInstaller.JAVA_ARCHIVE + " -C " + UnixInstaller.JAVA_DIR
                + " --strip-components=1");
        //set symbolic link
        this.remoteConnection.executeCommand(
            "sudo ln -s " + this.homeDir + "/" + UnixInstaller.JAVA_DIR
                + "/bin/java /usr/bin/java");
        Logger.debug("Java was successfully installed!");
    }

    @Override public void installVisor() throws RemoteException {

        Logger.debug("setting up Visor...");

{'fraction_non_alphanumeric': 0.10049129075480125, 'fraction_numerical': 0.006848295369956826, 'mean_word_length': 2.8854829381145173, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '358854', 'n_tokens_mistral': 1977, 'n_tokens_neox': 1827, 'n_words': 494}