mirror of https://github.com/apache/jclouds.git
InstallJDK for 32bit vms
This commit is contained in:
parent
4d919ce14e
commit
c72b3ae236
|
@ -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'",
|
format("ls %s/bundles/org/jboss/as/osgi/configadmin/main|sed -e 's/.*-//g' -e 's/.jar//g'",
|
||||||
JBOSS_HOME)), configureSeconds));
|
JBOSS_HOME)), configureSeconds));
|
||||||
|
|
||||||
for (Entry<String, URI> download : ImmutableMap.<String, URI> of("jboss7", JBOSS7_URL, "jdk7", InstallJDK.FromURL.JDK7_URL)
|
for (Entry<String, URI> download : ImmutableMap.<String, URI> of("jboss7", JBOSS7_URL, "jdk7",
|
||||||
.entrySet()) {
|
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
|
// note we cannot use nslookup until we've configured the system, as
|
||||||
// it may have not been present checking the address of the download
|
// it may have not been present checking the address of the download
|
||||||
// host using the local node's DNS config
|
// host using the local node's DNS config
|
||||||
|
|
|
@ -133,6 +133,42 @@ function setupPublicCurl() {
|
||||||
ensure_can_resolve_public_dns
|
ensure_can_resolve_public_dns
|
||||||
return 0
|
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
|
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}}
|
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
|
test -f /etc/shadow.${SUDO_USER:=${USER}} && mv /etc/shadow.${SUDO_USER:=${USER}} /etc/shadow
|
||||||
setupPublicCurl || return 1
|
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 -)
|
installJDK || return 1
|
||||||
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
|
|
||||||
|
|
||||||
END_OF_JCLOUDS_SCRIPT
|
END_OF_JCLOUDS_SCRIPT
|
||||||
|
|
||||||
|
|
|
@ -133,6 +133,42 @@ function setupPublicCurl() {
|
||||||
ensure_can_resolve_public_dns
|
ensure_can_resolve_public_dns
|
||||||
return 0
|
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
|
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}}
|
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
|
test -f /etc/shadow.${SUDO_USER:=${USER}} && mv /etc/shadow.${SUDO_USER:=${USER}} /etc/shadow
|
||||||
setupPublicCurl || return 1
|
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 -)
|
installJDK || return 1
|
||||||
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
|
|
||||||
iptables -I INPUT 1 -p tcp --dport 22 -j ACCEPT
|
iptables -I INPUT 1 -p tcp --dport 22 -j ACCEPT
|
||||||
iptables -I INPUT 1 -p tcp --dport 8080 -j ACCEPT
|
iptables -I INPUT 1 -p tcp --dport 8080 -j ACCEPT
|
||||||
iptables-save
|
iptables-save
|
||||||
|
|
|
@ -133,6 +133,42 @@ function setupPublicCurl() {
|
||||||
ensure_can_resolve_public_dns
|
ensure_can_resolve_public_dns
|
||||||
return 0
|
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
|
END_OF_JCLOUDS_SCRIPT
|
||||||
|
|
||||||
|
@ -142,26 +178,7 @@ END_OF_JCLOUDS_SCRIPT
|
||||||
rm -f $INSTANCE_HOME/rc
|
rm -f $INSTANCE_HOME/rc
|
||||||
trap 'echo $?>$INSTANCE_HOME/rc' 0 1 2 3 15
|
trap 'echo $?>$INSTANCE_HOME/rc' 0 1 2 3 15
|
||||||
setupPublicCurl || exit 1
|
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 -)
|
installJDK || exit 1
|
||||||
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
|
|
||||||
|
|
||||||
END_OF_JCLOUDS_SCRIPT
|
END_OF_JCLOUDS_SCRIPT
|
||||||
|
|
||||||
|
|
|
@ -18,18 +18,13 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.scriptbuilder.statements.java;
|
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.call;
|
||||||
import static org.jclouds.scriptbuilder.domain.Statements.exec;
|
|
||||||
import static org.jclouds.scriptbuilder.domain.Statements.extractTargzIntoDirectory;
|
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
import org.jclouds.scriptbuilder.domain.Statement;
|
import org.jclouds.scriptbuilder.domain.Statement;
|
||||||
import org.jclouds.scriptbuilder.domain.StatementList;
|
import org.jclouds.scriptbuilder.domain.StatementList;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Installs a default JDK to a host
|
* Installs a default JDK to a host
|
||||||
*
|
*
|
||||||
|
@ -46,31 +41,12 @@ public class InstallJDK {
|
||||||
|
|
||||||
public static class FromURL extends StatementList {
|
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() {
|
public FromURL() {
|
||||||
this(JDK7_URL);
|
super(call("setupPublicCurl"), call("installJDK"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final ImmutableSet<String> exportJavaHomeAndAddToPath = ImmutableSet.of(
|
|
||||||
"export JAVA_HOME=/usr/local/jdk", "export PATH=$JAVA_HOME/bin:$PATH");
|
|
||||||
|
|
||||||
public FromURL(URI jdk7Url) {
|
public FromURL(URI jdk7Url) {
|
||||||
super(call("setupPublicCurl"), //
|
super(call("setupPublicCurl"), call("installJDK", jdk7Url.toASCIIString()));
|
||||||
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"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -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
|
||||||
|
}
|
|
@ -42,8 +42,7 @@ public class InstallJDKTest {
|
||||||
Statement installJDK = InstallJDK.fromURL();
|
Statement installJDK = InstallJDK.fromURL();
|
||||||
|
|
||||||
public void testInstallJDKUNIX() throws IOException {
|
public void testInstallJDKUNIX() throws IOException {
|
||||||
assertEquals(InstallJDK.fromURL().render(OsFamily.UNIX), CharStreams.toString(Resources.newReaderSupplier(
|
assertEquals(InstallJDK.fromURL().render(OsFamily.UNIX), "setupPublicCurl || return 1\ninstallJDK || return 1\n");
|
||||||
Resources.getResource("test_install_jdk_from_url." + ShellToken.SH.to(OsFamily.UNIX)), Charsets.UTF_8)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testInstallJDKUNIXInScriptBuilderSourcesSetupPublicCurl() throws IOException {
|
public void testInstallJDKUNIXInScriptBuilderSourcesSetupPublicCurl() throws IOException {
|
||||||
|
@ -54,12 +53,8 @@ public class InstallJDKTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testInstallJDKUNIXWithURL() throws IOException {
|
public void testInstallJDKUNIXWithURL() throws IOException {
|
||||||
assertEquals(
|
assertEquals(InstallJDK.fromURL(URI.create("http://foo")).render(OsFamily.UNIX),
|
||||||
InstallJDK.fromURL(URI.create("http://foo")).render(OsFamily.UNIX),
|
"setupPublicCurl || return 1\ninstallJDK http://foo || return 1\n");
|
||||||
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"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
|
|
@ -133,6 +133,42 @@ function setupPublicCurl() {
|
||||||
ensure_can_resolve_public_dns
|
ensure_can_resolve_public_dns
|
||||||
return 0
|
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
|
END_OF_JCLOUDS_SCRIPT
|
||||||
|
|
||||||
|
@ -142,26 +178,7 @@ END_OF_JCLOUDS_SCRIPT
|
||||||
rm -f $INSTANCE_HOME/rc
|
rm -f $INSTANCE_HOME/rc
|
||||||
trap 'echo $?>$INSTANCE_HOME/rc' 0 1 2 3 15
|
trap 'echo $?>$INSTANCE_HOME/rc' 0 1 2 3 15
|
||||||
setupPublicCurl || exit 1
|
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 -)
|
installJDK || exit 1
|
||||||
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
|
|
||||||
|
|
||||||
END_OF_JCLOUDS_SCRIPT
|
END_OF_JCLOUDS_SCRIPT
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue