diff --git a/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java b/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java index a67fec02ac..6824f909ee 100644 --- a/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java @@ -676,8 +676,8 @@ public abstract class BaseComputeServiceLiveTest extends BaseVersionedServiceLiv format("ls %s/bundles/org/jboss/as/osgi/configadmin/main|sed -e 's/.*-//g' -e 's/.jar//g'", JBOSS_HOME)), configureSeconds)); - for (Entry download : ImmutableMap. of("jboss7", JBOSS7_URL, "jdk7", InstallJDK.FromURL.JDK7_URL) - .entrySet()) { + for (Entry download : ImmutableMap. of("jboss7", JBOSS7_URL, "jdk7", + URI.create("http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz")).entrySet()) { // note we cannot use nslookup until we've configured the system, as // it may have not been present checking the address of the download // host using the local node's DNS config diff --git a/compute/src/test/resources/initscript_with_java.sh b/compute/src/test/resources/initscript_with_java.sh index e22fa6d73b..b085af364d 100644 --- a/compute/src/test/resources/initscript_with_java.sh +++ b/compute/src/test/resources/initscript_with_java.sh @@ -133,6 +133,42 @@ function setupPublicCurl() { ensure_can_resolve_public_dns return 0 } +function installJDK() { + if hash curl 2>/dev/null; then + if [ `uname -m` == 'x86_64' ]; then + local url=${1:-http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz} + else + local url=${1:-http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-i586.tar.gz} + fi + curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET $url |(mkdir -p /usr/local &&cd /usr/local &&tar -xpzf -) + mv /usr/local/jdk* /usr/local/jdk/ + test -n \"$SUDO_USER\" && cat >> /home/$SUDO_USER/.bashrc <<-'END_OF_JCLOUDS_FILE' + export JAVA_HOME=/usr/local/jdk + export PATH=$JAVA_HOME/bin:$PATH +END_OF_JCLOUDS_FILE + cat >> /etc/bashrc <<-'END_OF_JCLOUDS_FILE' + export JAVA_HOME=/usr/local/jdk + export PATH=$JAVA_HOME/bin:$PATH +END_OF_JCLOUDS_FILE + cat >> $HOME/.bashrc <<-'END_OF_JCLOUDS_FILE' + export JAVA_HOME=/usr/local/jdk + export PATH=$JAVA_HOME/bin:$PATH +END_OF_JCLOUDS_FILE + cat >> /etc/skel/.bashrc <<-'END_OF_JCLOUDS_FILE' + export JAVA_HOME=/usr/local/jdk + export PATH=$JAVA_HOME/bin:$PATH +END_OF_JCLOUDS_FILE + # TODO: eventhough we are setting the above, sometimes images (ex. + # cloudservers ubuntu) kick out of .bashrc (ex. [ -z "$PS1" ] && + # return), for this reason, we should also explicitly link. + # A better way would be to update using alternatives or the like + ln -fs /usr/local/jdk/bin/java /usr/bin/java + /usr/bin/java -version || abort "cannot run /usr/bin/java" + else + abort "curl not available.. cannot install openjdk" + fi + return 0 +} END_OF_JCLOUDS_SCRIPT @@ -162,26 +198,7 @@ END_OF_JCLOUDS_SCRIPT awk -v user=^${SUDO_USER:=${USER}}: -v password='crypt(randompassword)' 'BEGIN { FS=OFS=":" } $0 ~ user { $2 = password } 1' /etc/shadow >/etc/shadow.${SUDO_USER:=${USER}} test -f /etc/shadow.${SUDO_USER:=${USER}} && mv /etc/shadow.${SUDO_USER:=${USER}} /etc/shadow setupPublicCurl || return 1 - curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz |(mkdir -p /usr/local &&cd /usr/local &&tar -xpzf -) - mv /usr/local/jdk* /usr/local/jdk/ - test -n "$SUDO_USER" && - cat >> /home/$SUDO_USER/.bashrc <<-'END_OF_JCLOUDS_FILE' - export JAVA_HOME=/usr/local/jdk - export PATH=$JAVA_HOME/bin:$PATH - END_OF_JCLOUDS_FILE - cat >> /etc/bashrc <<-'END_OF_JCLOUDS_FILE' - export JAVA_HOME=/usr/local/jdk - export PATH=$JAVA_HOME/bin:$PATH - END_OF_JCLOUDS_FILE - cat >> $HOME/.bashrc <<-'END_OF_JCLOUDS_FILE' - export JAVA_HOME=/usr/local/jdk - export PATH=$JAVA_HOME/bin:$PATH - END_OF_JCLOUDS_FILE - cat >> /etc/skel/.bashrc <<-'END_OF_JCLOUDS_FILE' - export JAVA_HOME=/usr/local/jdk - export PATH=$JAVA_HOME/bin:$PATH - END_OF_JCLOUDS_FILE - ln -fs /usr/local/jdk/bin/java /usr/bin/java + installJDK || return 1 END_OF_JCLOUDS_SCRIPT diff --git a/compute/src/test/resources/initscript_with_jboss.sh b/compute/src/test/resources/initscript_with_jboss.sh index 36216b850d..1a9052097f 100644 --- a/compute/src/test/resources/initscript_with_jboss.sh +++ b/compute/src/test/resources/initscript_with_jboss.sh @@ -133,6 +133,42 @@ function setupPublicCurl() { ensure_can_resolve_public_dns return 0 } +function installJDK() { + if hash curl 2>/dev/null; then + if [ `uname -m` == 'x86_64' ]; then + local url=${1:-http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz} + else + local url=${1:-http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-i586.tar.gz} + fi + curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET $url |(mkdir -p /usr/local &&cd /usr/local &&tar -xpzf -) + mv /usr/local/jdk* /usr/local/jdk/ + test -n \"$SUDO_USER\" && cat >> /home/$SUDO_USER/.bashrc <<-'END_OF_JCLOUDS_FILE' + export JAVA_HOME=/usr/local/jdk + export PATH=$JAVA_HOME/bin:$PATH +END_OF_JCLOUDS_FILE + cat >> /etc/bashrc <<-'END_OF_JCLOUDS_FILE' + export JAVA_HOME=/usr/local/jdk + export PATH=$JAVA_HOME/bin:$PATH +END_OF_JCLOUDS_FILE + cat >> $HOME/.bashrc <<-'END_OF_JCLOUDS_FILE' + export JAVA_HOME=/usr/local/jdk + export PATH=$JAVA_HOME/bin:$PATH +END_OF_JCLOUDS_FILE + cat >> /etc/skel/.bashrc <<-'END_OF_JCLOUDS_FILE' + export JAVA_HOME=/usr/local/jdk + export PATH=$JAVA_HOME/bin:$PATH +END_OF_JCLOUDS_FILE + # TODO: eventhough we are setting the above, sometimes images (ex. + # cloudservers ubuntu) kick out of .bashrc (ex. [ -z "$PS1" ] && + # return), for this reason, we should also explicitly link. + # A better way would be to update using alternatives or the like + ln -fs /usr/local/jdk/bin/java /usr/bin/java + /usr/bin/java -version || abort "cannot run /usr/bin/java" + else + abort "curl not available.. cannot install openjdk" + fi + return 0 +} END_OF_JCLOUDS_SCRIPT @@ -162,26 +198,7 @@ END_OF_JCLOUDS_SCRIPT awk -v user=^${SUDO_USER:=${USER}}: -v password='crypt(randompassword)' 'BEGIN { FS=OFS=":" } $0 ~ user { $2 = password } 1' /etc/shadow >/etc/shadow.${SUDO_USER:=${USER}} test -f /etc/shadow.${SUDO_USER:=${USER}} && mv /etc/shadow.${SUDO_USER:=${USER}} /etc/shadow setupPublicCurl || return 1 - curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz |(mkdir -p /usr/local &&cd /usr/local &&tar -xpzf -) - mv /usr/local/jdk* /usr/local/jdk/ - test -n "$SUDO_USER" && - cat >> /home/$SUDO_USER/.bashrc <<-'END_OF_JCLOUDS_FILE' - export JAVA_HOME=/usr/local/jdk - export PATH=$JAVA_HOME/bin:$PATH - END_OF_JCLOUDS_FILE - cat >> /etc/bashrc <<-'END_OF_JCLOUDS_FILE' - export JAVA_HOME=/usr/local/jdk - export PATH=$JAVA_HOME/bin:$PATH - END_OF_JCLOUDS_FILE - cat >> $HOME/.bashrc <<-'END_OF_JCLOUDS_FILE' - export JAVA_HOME=/usr/local/jdk - export PATH=$JAVA_HOME/bin:$PATH - END_OF_JCLOUDS_FILE - cat >> /etc/skel/.bashrc <<-'END_OF_JCLOUDS_FILE' - export JAVA_HOME=/usr/local/jdk - export PATH=$JAVA_HOME/bin:$PATH - END_OF_JCLOUDS_FILE - ln -fs /usr/local/jdk/bin/java /usr/bin/java + installJDK || return 1 iptables -I INPUT 1 -p tcp --dport 22 -j ACCEPT iptables -I INPUT 1 -p tcp --dport 8080 -j ACCEPT iptables-save diff --git a/compute/src/test/resources/runscript.sh b/compute/src/test/resources/runscript.sh index 927daac349..844ba16f3c 100644 --- a/compute/src/test/resources/runscript.sh +++ b/compute/src/test/resources/runscript.sh @@ -133,6 +133,42 @@ function setupPublicCurl() { ensure_can_resolve_public_dns return 0 } +function installJDK() { + if hash curl 2>/dev/null; then + if [ `uname -m` == 'x86_64' ]; then + local url=${1:-http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz} + else + local url=${1:-http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-i586.tar.gz} + fi + curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET $url |(mkdir -p /usr/local &&cd /usr/local &&tar -xpzf -) + mv /usr/local/jdk* /usr/local/jdk/ + test -n \"$SUDO_USER\" && cat >> /home/$SUDO_USER/.bashrc <<-'END_OF_JCLOUDS_FILE' + export JAVA_HOME=/usr/local/jdk + export PATH=$JAVA_HOME/bin:$PATH +END_OF_JCLOUDS_FILE + cat >> /etc/bashrc <<-'END_OF_JCLOUDS_FILE' + export JAVA_HOME=/usr/local/jdk + export PATH=$JAVA_HOME/bin:$PATH +END_OF_JCLOUDS_FILE + cat >> $HOME/.bashrc <<-'END_OF_JCLOUDS_FILE' + export JAVA_HOME=/usr/local/jdk + export PATH=$JAVA_HOME/bin:$PATH +END_OF_JCLOUDS_FILE + cat >> /etc/skel/.bashrc <<-'END_OF_JCLOUDS_FILE' + export JAVA_HOME=/usr/local/jdk + export PATH=$JAVA_HOME/bin:$PATH +END_OF_JCLOUDS_FILE + # TODO: eventhough we are setting the above, sometimes images (ex. + # cloudservers ubuntu) kick out of .bashrc (ex. [ -z "$PS1" ] && + # return), for this reason, we should also explicitly link. + # A better way would be to update using alternatives or the like + ln -fs /usr/local/jdk/bin/java /usr/bin/java + /usr/bin/java -version || abort "cannot run /usr/bin/java" + else + abort "curl not available.. cannot install openjdk" + fi + return 0 +} END_OF_JCLOUDS_SCRIPT @@ -142,26 +178,7 @@ END_OF_JCLOUDS_SCRIPT rm -f $INSTANCE_HOME/rc trap 'echo $?>$INSTANCE_HOME/rc' 0 1 2 3 15 setupPublicCurl || exit 1 - curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz |(mkdir -p /usr/local &&cd /usr/local &&tar -xpzf -) - mv /usr/local/jdk* /usr/local/jdk/ - test -n "$SUDO_USER" && - cat >> /home/$SUDO_USER/.bashrc <<-'END_OF_JCLOUDS_FILE' - export JAVA_HOME=/usr/local/jdk - export PATH=$JAVA_HOME/bin:$PATH - END_OF_JCLOUDS_FILE - cat >> /etc/bashrc <<-'END_OF_JCLOUDS_FILE' - export JAVA_HOME=/usr/local/jdk - export PATH=$JAVA_HOME/bin:$PATH - END_OF_JCLOUDS_FILE - cat >> $HOME/.bashrc <<-'END_OF_JCLOUDS_FILE' - export JAVA_HOME=/usr/local/jdk - export PATH=$JAVA_HOME/bin:$PATH - END_OF_JCLOUDS_FILE - cat >> /etc/skel/.bashrc <<-'END_OF_JCLOUDS_FILE' - export JAVA_HOME=/usr/local/jdk - export PATH=$JAVA_HOME/bin:$PATH - END_OF_JCLOUDS_FILE - ln -fs /usr/local/jdk/bin/java /usr/bin/java + installJDK || exit 1 END_OF_JCLOUDS_SCRIPT diff --git a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/statements/java/InstallJDK.java b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/statements/java/InstallJDK.java index 30c040acf0..5f24f1decf 100644 --- a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/statements/java/InstallJDK.java +++ b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/statements/java/InstallJDK.java @@ -18,18 +18,13 @@ */ package org.jclouds.scriptbuilder.statements.java; -import static org.jclouds.scriptbuilder.domain.Statements.appendFile; import static org.jclouds.scriptbuilder.domain.Statements.call; -import static org.jclouds.scriptbuilder.domain.Statements.exec; -import static org.jclouds.scriptbuilder.domain.Statements.extractTargzIntoDirectory; import java.net.URI; import org.jclouds.scriptbuilder.domain.Statement; import org.jclouds.scriptbuilder.domain.StatementList; -import com.google.common.collect.ImmutableSet; - /** * Installs a default JDK to a host * @@ -46,31 +41,12 @@ public class InstallJDK { public static class FromURL extends StatementList { - public static final URI JDK7_URL = URI.create(System.getProperty("jdk7-url", - "http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz")); - public FromURL() { - this(JDK7_URL); + super(call("setupPublicCurl"), call("installJDK")); } - public static final ImmutableSet exportJavaHomeAndAddToPath = ImmutableSet.of( - "export JAVA_HOME=/usr/local/jdk", "export PATH=$JAVA_HOME/bin:$PATH"); - public FromURL(URI jdk7Url) { - super(call("setupPublicCurl"), // - extractTargzIntoDirectory(jdk7Url, "/usr/local"),// - exec("mv /usr/local/jdk* /usr/local/jdk/"),// - exec("test -n \"$SUDO_USER\" && "), // - appendFile("/home/$SUDO_USER/.bashrc", exportJavaHomeAndAddToPath),// - appendFile("/etc/bashrc", exportJavaHomeAndAddToPath),// - appendFile("$HOME/.bashrc", exportJavaHomeAndAddToPath),// - appendFile("/etc/skel/.bashrc", exportJavaHomeAndAddToPath),// - // TODO: - // eventhough we are setting the above, sometimes images (ex. - // cloudservers ubuntu) kick out of .bashrc (ex. [ -z "$PS1" ] && - // return), for this reason, we should also explicitly link. - // A better way would be to update using alternatives or the like - exec("ln -fs /usr/local/jdk/bin/java /usr/bin/java")); + super(call("setupPublicCurl"), call("installJDK", jdk7Url.toASCIIString())); } } } \ No newline at end of file diff --git a/scriptbuilder/src/main/resources/functions/installJDK.sh b/scriptbuilder/src/main/resources/functions/installJDK.sh new file mode 100644 index 0000000000..a800582483 --- /dev/null +++ b/scriptbuilder/src/main/resources/functions/installJDK.sh @@ -0,0 +1,36 @@ +function installJDK() { + if hash curl 2>/dev/null; then + if [ `uname -m` == 'x86_64' ]; then + local url=${1:-http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz} + else + local url=${1:-http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-i586.tar.gz} + fi + curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET $url |(mkdir -p /usr/local &&cd /usr/local &&tar -xpzf -) + mv /usr/local/jdk* /usr/local/jdk/ + test -n \"$SUDO_USER\" && cat >> /home/$SUDO_USER/.bashrc <<-'END_OF_JCLOUDS_FILE' + export JAVA_HOME=/usr/local/jdk + export PATH=$JAVA_HOME/bin:$PATH +END_OF_JCLOUDS_FILE + cat >> /etc/bashrc <<-'END_OF_JCLOUDS_FILE' + export JAVA_HOME=/usr/local/jdk + export PATH=$JAVA_HOME/bin:$PATH +END_OF_JCLOUDS_FILE + cat >> $HOME/.bashrc <<-'END_OF_JCLOUDS_FILE' + export JAVA_HOME=/usr/local/jdk + export PATH=$JAVA_HOME/bin:$PATH +END_OF_JCLOUDS_FILE + cat >> /etc/skel/.bashrc <<-'END_OF_JCLOUDS_FILE' + export JAVA_HOME=/usr/local/jdk + export PATH=$JAVA_HOME/bin:$PATH +END_OF_JCLOUDS_FILE + # TODO: eventhough we are setting the above, sometimes images (ex. + # cloudservers ubuntu) kick out of .bashrc (ex. [ -z "$PS1" ] && + # return), for this reason, we should also explicitly link. + # A better way would be to update using alternatives or the like + ln -fs /usr/local/jdk/bin/java /usr/bin/java + /usr/bin/java -version || abort "cannot run /usr/bin/java" + else + abort "curl not available.. cannot install openjdk" + fi + return 0 +} \ No newline at end of file diff --git a/scriptbuilder/src/test/java/org/jclouds/scriptbuilder/statements/java/InstallJDKTest.java b/scriptbuilder/src/test/java/org/jclouds/scriptbuilder/statements/java/InstallJDKTest.java index 4730ffbc6a..dee09e0e3b 100644 --- a/scriptbuilder/src/test/java/org/jclouds/scriptbuilder/statements/java/InstallJDKTest.java +++ b/scriptbuilder/src/test/java/org/jclouds/scriptbuilder/statements/java/InstallJDKTest.java @@ -42,8 +42,7 @@ public class InstallJDKTest { Statement installJDK = InstallJDK.fromURL(); public void testInstallJDKUNIX() throws IOException { - assertEquals(InstallJDK.fromURL().render(OsFamily.UNIX), CharStreams.toString(Resources.newReaderSupplier( - Resources.getResource("test_install_jdk_from_url." + ShellToken.SH.to(OsFamily.UNIX)), Charsets.UTF_8))); + assertEquals(InstallJDK.fromURL().render(OsFamily.UNIX), "setupPublicCurl || return 1\ninstallJDK || return 1\n"); } public void testInstallJDKUNIXInScriptBuilderSourcesSetupPublicCurl() throws IOException { @@ -54,12 +53,8 @@ public class InstallJDKTest { } public void testInstallJDKUNIXWithURL() throws IOException { - assertEquals( - InstallJDK.fromURL(URI.create("http://foo")).render(OsFamily.UNIX), - CharStreams.toString( - Resources.newReaderSupplier( - Resources.getResource("test_install_jdk_from_url." + ShellToken.SH.to(OsFamily.UNIX)), - Charsets.UTF_8)).replace(InstallJDK.FromURL.JDK7_URL.toASCIIString(), "http://foo")); + assertEquals(InstallJDK.fromURL(URI.create("http://foo")).render(OsFamily.UNIX), + "setupPublicCurl || return 1\ninstallJDK http://foo || return 1\n"); } } diff --git a/scriptbuilder/src/test/resources/test_install_jdk_from_url.sh b/scriptbuilder/src/test/resources/test_install_jdk_from_url.sh deleted file mode 100644 index f1638bb15d..0000000000 --- a/scriptbuilder/src/test/resources/test_install_jdk_from_url.sh +++ /dev/null @@ -1,21 +0,0 @@ -setupPublicCurl || return 1 -curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz |(mkdir -p /usr/local &&cd /usr/local &&tar -xpzf -) -mv /usr/local/jdk* /usr/local/jdk/ -test -n "$SUDO_USER" && -cat >> /home/$SUDO_USER/.bashrc <<-'END_OF_JCLOUDS_FILE' - export JAVA_HOME=/usr/local/jdk - export PATH=$JAVA_HOME/bin:$PATH -END_OF_JCLOUDS_FILE -cat >> /etc/bashrc <<-'END_OF_JCLOUDS_FILE' - export JAVA_HOME=/usr/local/jdk - export PATH=$JAVA_HOME/bin:$PATH -END_OF_JCLOUDS_FILE -cat >> $HOME/.bashrc <<-'END_OF_JCLOUDS_FILE' - export JAVA_HOME=/usr/local/jdk - export PATH=$JAVA_HOME/bin:$PATH -END_OF_JCLOUDS_FILE -cat >> /etc/skel/.bashrc <<-'END_OF_JCLOUDS_FILE' - export JAVA_HOME=/usr/local/jdk - export PATH=$JAVA_HOME/bin:$PATH -END_OF_JCLOUDS_FILE -ln -fs /usr/local/jdk/bin/java /usr/bin/java diff --git a/scriptbuilder/src/test/resources/test_install_jdk_scriptbuilder.sh b/scriptbuilder/src/test/resources/test_install_jdk_scriptbuilder.sh index 971338e0e8..a253c0f725 100644 --- a/scriptbuilder/src/test/resources/test_install_jdk_scriptbuilder.sh +++ b/scriptbuilder/src/test/resources/test_install_jdk_scriptbuilder.sh @@ -133,6 +133,42 @@ function setupPublicCurl() { ensure_can_resolve_public_dns return 0 } +function installJDK() { + if hash curl 2>/dev/null; then + if [ `uname -m` == 'x86_64' ]; then + local url=${1:-http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz} + else + local url=${1:-http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-i586.tar.gz} + fi + curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET $url |(mkdir -p /usr/local &&cd /usr/local &&tar -xpzf -) + mv /usr/local/jdk* /usr/local/jdk/ + test -n \"$SUDO_USER\" && cat >> /home/$SUDO_USER/.bashrc <<-'END_OF_JCLOUDS_FILE' + export JAVA_HOME=/usr/local/jdk + export PATH=$JAVA_HOME/bin:$PATH +END_OF_JCLOUDS_FILE + cat >> /etc/bashrc <<-'END_OF_JCLOUDS_FILE' + export JAVA_HOME=/usr/local/jdk + export PATH=$JAVA_HOME/bin:$PATH +END_OF_JCLOUDS_FILE + cat >> $HOME/.bashrc <<-'END_OF_JCLOUDS_FILE' + export JAVA_HOME=/usr/local/jdk + export PATH=$JAVA_HOME/bin:$PATH +END_OF_JCLOUDS_FILE + cat >> /etc/skel/.bashrc <<-'END_OF_JCLOUDS_FILE' + export JAVA_HOME=/usr/local/jdk + export PATH=$JAVA_HOME/bin:$PATH +END_OF_JCLOUDS_FILE + # TODO: eventhough we are setting the above, sometimes images (ex. + # cloudservers ubuntu) kick out of .bashrc (ex. [ -z "$PS1" ] && + # return), for this reason, we should also explicitly link. + # A better way would be to update using alternatives or the like + ln -fs /usr/local/jdk/bin/java /usr/bin/java + /usr/bin/java -version || abort "cannot run /usr/bin/java" + else + abort "curl not available.. cannot install openjdk" + fi + return 0 +} END_OF_JCLOUDS_SCRIPT @@ -142,26 +178,7 @@ END_OF_JCLOUDS_SCRIPT rm -f $INSTANCE_HOME/rc trap 'echo $?>$INSTANCE_HOME/rc' 0 1 2 3 15 setupPublicCurl || exit 1 - curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz |(mkdir -p /usr/local &&cd /usr/local &&tar -xpzf -) - mv /usr/local/jdk* /usr/local/jdk/ - test -n "$SUDO_USER" && - cat >> /home/$SUDO_USER/.bashrc <<-'END_OF_JCLOUDS_FILE' - export JAVA_HOME=/usr/local/jdk - export PATH=$JAVA_HOME/bin:$PATH - END_OF_JCLOUDS_FILE - cat >> /etc/bashrc <<-'END_OF_JCLOUDS_FILE' - export JAVA_HOME=/usr/local/jdk - export PATH=$JAVA_HOME/bin:$PATH - END_OF_JCLOUDS_FILE - cat >> $HOME/.bashrc <<-'END_OF_JCLOUDS_FILE' - export JAVA_HOME=/usr/local/jdk - export PATH=$JAVA_HOME/bin:$PATH - END_OF_JCLOUDS_FILE - cat >> /etc/skel/.bashrc <<-'END_OF_JCLOUDS_FILE' - export JAVA_HOME=/usr/local/jdk - export PATH=$JAVA_HOME/bin:$PATH - END_OF_JCLOUDS_FILE - ln -fs /usr/local/jdk/bin/java /usr/bin/java + installJDK || exit 1 END_OF_JCLOUDS_SCRIPT