mirror of https://github.com/apache/jclouds.git
Issue 891: switch to openjdk; tested on ubuntu
This commit is contained in:
parent
59fe35f91c
commit
a6429398fd
|
@ -61,7 +61,7 @@ public class RunScriptData {
|
||||||
public static StatementList installAdminUserJBossAndOpenPorts(OperatingSystem os) throws IOException {
|
public static StatementList installAdminUserJBossAndOpenPorts(OperatingSystem os) throws IOException {
|
||||||
return new StatementList(//
|
return new StatementList(//
|
||||||
AdminAccess.builder().adminUsername("web").build(),//
|
AdminAccess.builder().adminUsername("web").build(),//
|
||||||
InstallJDK.fromURL(),//
|
InstallJDK.fromOpenJDK(),//
|
||||||
authorizePortsInIpTables(22, 8080),//
|
authorizePortsInIpTables(22, 8080),//
|
||||||
extractTargzIntoDirectory(JBOSS7_URL, "/usr/local"),//
|
extractTargzIntoDirectory(JBOSS7_URL, "/usr/local"),//
|
||||||
exec("{md} " + JBOSS_HOME), exec("mv /usr/local/jboss-*/* " + JBOSS_HOME),//
|
exec("{md} " + JBOSS_HOME), exec("mv /usr/local/jboss-*/* " + JBOSS_HOME),//
|
||||||
|
|
|
@ -213,7 +213,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseVersionedServiceLiv
|
||||||
|
|
||||||
@Test(enabled = true, expectedExceptions = NoSuchElementException.class)
|
@Test(enabled = true, expectedExceptions = NoSuchElementException.class)
|
||||||
public void testCorrectExceptionRunningNodesNotFound() throws Exception {
|
public void testCorrectExceptionRunningNodesNotFound() throws Exception {
|
||||||
client.runScriptOnNodesMatching(runningInGroup("zebras-are-awesome"), InstallJDK.fromURL());
|
client.runScriptOnNodesMatching(runningInGroup("zebras-are-awesome"), InstallJDK.fromOpenJDK());
|
||||||
}
|
}
|
||||||
|
|
||||||
// since surefire and eclipse don't otherwise guarantee the order, we are
|
// since surefire and eclipse don't otherwise guarantee the order, we are
|
||||||
|
@ -375,7 +375,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseVersionedServiceLiv
|
||||||
|
|
||||||
protected static Template addRunScriptToTemplate(Template template) {
|
protected static Template addRunScriptToTemplate(Template template) {
|
||||||
template.getOptions().runScript(
|
template.getOptions().runScript(
|
||||||
Statements.newStatementList(AdminAccess.standard(), InstallJDK.fromURL()));
|
Statements.newStatementList(AdminAccess.standard(), InstallJDK.fromOpenJDK()));
|
||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -439,7 +439,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseVersionedServiceLiv
|
||||||
|
|
||||||
protected Map<? extends NodeMetadata, ExecResponse> runScriptWithCreds(final String group, OperatingSystem os,
|
protected Map<? extends NodeMetadata, ExecResponse> runScriptWithCreds(final String group, OperatingSystem os,
|
||||||
LoginCredentials creds) throws RunScriptOnNodesException {
|
LoginCredentials creds) throws RunScriptOnNodesException {
|
||||||
return client.runScriptOnNodesMatching(runningInGroup(group), InstallJDK.fromURL(), overrideLoginCredentials(creds)
|
return client.runScriptOnNodesMatching(runningInGroup(group), InstallJDK.fromOpenJDK(), overrideLoginCredentials(creds)
|
||||||
.nameTask("runScriptWithCreds"));
|
.nameTask("runScriptWithCreds"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -133,41 +133,40 @@ function setupPublicCurl() {
|
||||||
ensure_can_resolve_public_dns
|
ensure_can_resolve_public_dns
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
function setupJavaHomeInProfile() {
|
||||||
|
test -n \"$SUDO_USER\" && cat >> `getent passwd $SUDO_USER| cut -f6 -d:`/.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
|
||||||
|
}
|
||||||
|
|
||||||
function installJDK() {
|
function installJDK() {
|
||||||
if hash curl 2>/dev/null; then
|
if hash apt-get 2>/dev/null; then
|
||||||
if [ `uname -m` == 'x86_64' ]; then
|
export pkg=openjdk-7-jdk
|
||||||
local url=${1:-http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz}
|
apt-get-install $pkg || ( apt-get-upgrade && apt-get-install $pkg )
|
||||||
else
|
elif hash yum 2>/dev/null; then
|
||||||
local url=${1:-http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-i586.tar.gz}
|
export pkg=java-1.7.0-openjdk
|
||||||
fi
|
yum --nogpgcheck -y ensure $pkg
|
||||||
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
|
else
|
||||||
abort "curl not available.. cannot install openjdk"
|
abort "we only support apt-get and yum right now... please contribute!"
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
return 0
|
JAVA_HOME=`ls -d /usr/lib/jvm/java-7-openjdk-*|grep -v common`
|
||||||
|
ln -Fs $JAVA_HOME /usr/local/jdk
|
||||||
|
/usr/local/jdk/bin/java -version || abort "cannot run java"
|
||||||
|
setupJavaHomeInProfile
|
||||||
}
|
}
|
||||||
|
|
||||||
END_OF_JCLOUDS_SCRIPT
|
END_OF_JCLOUDS_SCRIPT
|
||||||
|
@ -198,7 +197,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
|
||||||
installJDK || return 1
|
installOpenJDK || return 1
|
||||||
|
|
||||||
END_OF_JCLOUDS_SCRIPT
|
END_OF_JCLOUDS_SCRIPT
|
||||||
|
|
||||||
|
|
|
@ -133,41 +133,40 @@ function setupPublicCurl() {
|
||||||
ensure_can_resolve_public_dns
|
ensure_can_resolve_public_dns
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
function setupJavaHomeInProfile() {
|
||||||
|
test -n \"$SUDO_USER\" && cat >> `getent passwd $SUDO_USER| cut -f6 -d:`/.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
|
||||||
|
}
|
||||||
|
|
||||||
function installJDK() {
|
function installJDK() {
|
||||||
if hash curl 2>/dev/null; then
|
if hash apt-get 2>/dev/null; then
|
||||||
if [ `uname -m` == 'x86_64' ]; then
|
export pkg=openjdk-7-jdk
|
||||||
local url=${1:-http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz}
|
apt-get-install $pkg || ( apt-get-upgrade && apt-get-install $pkg )
|
||||||
else
|
elif hash yum 2>/dev/null; then
|
||||||
local url=${1:-http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-i586.tar.gz}
|
export pkg=java-1.7.0-openjdk
|
||||||
fi
|
yum --nogpgcheck -y ensure $pkg
|
||||||
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
|
else
|
||||||
abort "curl not available.. cannot install openjdk"
|
abort "we only support apt-get and yum right now... please contribute!"
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
return 0
|
JAVA_HOME=`ls -d /usr/lib/jvm/java-7-openjdk-*|grep -v common`
|
||||||
|
ln -Fs $JAVA_HOME /usr/local/jdk
|
||||||
|
/usr/local/jdk/bin/java -version || abort "cannot run java"
|
||||||
|
setupJavaHomeInProfile
|
||||||
}
|
}
|
||||||
|
|
||||||
END_OF_JCLOUDS_SCRIPT
|
END_OF_JCLOUDS_SCRIPT
|
||||||
|
@ -198,7 +197,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
|
||||||
installJDK || return 1
|
installOpenJDK || return 1
|
||||||
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,41 +133,40 @@ function setupPublicCurl() {
|
||||||
ensure_can_resolve_public_dns
|
ensure_can_resolve_public_dns
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
function setupJavaHomeInProfile() {
|
||||||
|
test -n \"$SUDO_USER\" && cat >> `getent passwd $SUDO_USER| cut -f6 -d:`/.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
|
||||||
|
}
|
||||||
|
|
||||||
function installJDK() {
|
function installJDK() {
|
||||||
if hash curl 2>/dev/null; then
|
if hash apt-get 2>/dev/null; then
|
||||||
if [ `uname -m` == 'x86_64' ]; then
|
export pkg=openjdk-7-jdk
|
||||||
local url=${1:-http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz}
|
apt-get-install $pkg || ( apt-get-upgrade && apt-get-install $pkg )
|
||||||
else
|
elif hash yum 2>/dev/null; then
|
||||||
local url=${1:-http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-i586.tar.gz}
|
export pkg=java-1.7.0-openjdk
|
||||||
fi
|
yum --nogpgcheck -y ensure $pkg
|
||||||
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
|
else
|
||||||
abort "curl not available.. cannot install openjdk"
|
abort "we only support apt-get and yum right now... please contribute!"
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
return 0
|
JAVA_HOME=`ls -d /usr/lib/jvm/java-7-openjdk-*|grep -v common`
|
||||||
|
ln -Fs $JAVA_HOME /usr/local/jdk
|
||||||
|
/usr/local/jdk/bin/java -version || abort "cannot run java"
|
||||||
|
setupJavaHomeInProfile
|
||||||
}
|
}
|
||||||
|
|
||||||
END_OF_JCLOUDS_SCRIPT
|
END_OF_JCLOUDS_SCRIPT
|
||||||
|
@ -178,7 +177,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
|
||||||
installJDK || exit 1
|
installOpenJDK || exit 1
|
||||||
|
|
||||||
END_OF_JCLOUDS_SCRIPT
|
END_OF_JCLOUDS_SCRIPT
|
||||||
|
|
||||||
|
|
|
@ -149,7 +149,7 @@ public class PlacementGroupClientLiveTest extends BaseVersionedServiceLiveTest {
|
||||||
assertEquals(template.getImage().getUserMetadata().get("hypervisor"), "xen");
|
assertEquals(template.getImage().getUserMetadata().get("hypervisor"), "xen");
|
||||||
|
|
||||||
template.getOptions().runScript(
|
template.getOptions().runScript(
|
||||||
Statements.newStatementList(AdminAccess.standard(), InstallJDK.fromURL()));
|
Statements.newStatementList(AdminAccess.standard(), InstallJDK.fromOpenJDK()));
|
||||||
|
|
||||||
String group = PREFIX + "cccluster";
|
String group = PREFIX + "cccluster";
|
||||||
context.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group));
|
context.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group));
|
||||||
|
|
|
@ -31,22 +31,43 @@ import org.jclouds.scriptbuilder.domain.StatementList;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class InstallJDK {
|
public class InstallJDK {
|
||||||
|
// TODO: this doesn't work
|
||||||
|
public static Statement fromOracle() {
|
||||||
|
throw new UnsupportedOperationException("Oracle JDK install doesn't currently work due to license agreement");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Statement fromOpenJDK() {
|
||||||
|
return new FromOpenJDK();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see fromOpenJDK
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public static Statement fromURL() {
|
public static Statement fromURL() {
|
||||||
return new FromURL();
|
return fromOpenJDK();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Statement fromURL(URI url) {
|
public static Statement fromURL(URI url) {
|
||||||
return new FromURL(url);
|
return new FromURL(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class FromOpenJDK extends StatementList {
|
||||||
|
|
||||||
|
public FromOpenJDK() {
|
||||||
|
super(call("setupPublicCurl"), call("installOpenJDK"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static class FromURL extends StatementList {
|
public static class FromURL extends StatementList {
|
||||||
|
|
||||||
public FromURL() {
|
public FromURL() {
|
||||||
super(call("setupPublicCurl"), call("installJDK"));
|
super(call("setupPublicCurl"), call("installJDKFromURL"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public FromURL(URI jdk7Url) {
|
public FromURL(URI jdk7Url) {
|
||||||
super(call("setupPublicCurl"), call("installJDK", jdk7Url.toASCIIString()));
|
super(call("setupPublicCurl"), call("installJDKFromURL", jdk7Url.toASCIIString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,7 @@
|
||||||
function installJDK() {
|
# note this does not work until someone addresses user auth
|
||||||
|
# https://issues.jenkins-ci.org/browse/JENKINS-10556
|
||||||
|
# https://forums.oracle.com/forums/thread.jspa?messageID=10236239&tstart=0
|
||||||
|
function installJDKFromURL() {
|
||||||
if hash curl 2>/dev/null; then
|
if hash curl 2>/dev/null; then
|
||||||
if [ `uname -m` == 'x86_64' ]; 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}
|
local url=${1:-http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz}
|
|
@ -0,0 +1,35 @@
|
||||||
|
function setupJavaHomeInProfile() {
|
||||||
|
test -n \"$SUDO_USER\" && cat >> `getent passwd $SUDO_USER| cut -f6 -d:`/.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
|
||||||
|
}
|
||||||
|
|
||||||
|
function installJDK() {
|
||||||
|
if hash apt-get 2>/dev/null; then
|
||||||
|
export pkg=openjdk-7-jdk
|
||||||
|
apt-get-install $pkg || ( apt-get-upgrade && apt-get-install $pkg )
|
||||||
|
elif hash yum 2>/dev/null; then
|
||||||
|
export pkg=java-1.7.0-openjdk
|
||||||
|
yum --nogpgcheck -y ensure $pkg
|
||||||
|
else
|
||||||
|
abort "we only support apt-get and yum right now... please contribute!"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
JAVA_HOME=`ls -d /usr/lib/jvm/java-7-openjdk-*|grep -v common`
|
||||||
|
ln -Fs $JAVA_HOME /usr/local/jdk
|
||||||
|
/usr/local/jdk/bin/java -version || abort "cannot run java"
|
||||||
|
setupJavaHomeInProfile
|
||||||
|
}
|
|
@ -39,14 +39,14 @@ import com.google.common.io.Resources;
|
||||||
@Test(groups = "unit", testName = "InstallJDKTest")
|
@Test(groups = "unit", testName = "InstallJDKTest")
|
||||||
public class InstallJDKTest {
|
public class InstallJDKTest {
|
||||||
|
|
||||||
Statement installJDK = InstallJDK.fromURL();
|
Statement installJDK = InstallJDK.fromOpenJDK();
|
||||||
|
|
||||||
public void testInstallJDKUNIX() throws IOException {
|
public void testInstallJDKUNIX() throws IOException {
|
||||||
assertEquals(InstallJDK.fromURL().render(OsFamily.UNIX), "setupPublicCurl || return 1\ninstallJDK || return 1\n");
|
assertEquals(InstallJDK.fromOpenJDK().render(OsFamily.UNIX), "setupPublicCurl || return 1\ninstallOpenJDK || return 1\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testInstallJDKUNIXInScriptBuilderSourcesSetupPublicCurl() throws IOException {
|
public void testInstallJDKUNIXInScriptBuilderSourcesSetupPublicCurl() throws IOException {
|
||||||
assertEquals(InitScript.builder().name("install_jdk").run(InstallJDK.fromURL()).build().render(OsFamily.UNIX),
|
assertEquals(InitScript.builder().name("install_jdk").run(InstallJDK.fromOpenJDK()).build().render(OsFamily.UNIX),
|
||||||
CharStreams.toString(Resources.newReaderSupplier(
|
CharStreams.toString(Resources.newReaderSupplier(
|
||||||
Resources.getResource("test_install_jdk_scriptbuilder." + ShellToken.SH.to(OsFamily.UNIX)),
|
Resources.getResource("test_install_jdk_scriptbuilder." + ShellToken.SH.to(OsFamily.UNIX)),
|
||||||
Charsets.UTF_8)));
|
Charsets.UTF_8)));
|
||||||
|
@ -54,7 +54,7 @@ public class InstallJDKTest {
|
||||||
|
|
||||||
public void testInstallJDKUNIXWithURL() throws IOException {
|
public void testInstallJDKUNIXWithURL() throws IOException {
|
||||||
assertEquals(InstallJDK.fromURL(URI.create("http://foo")).render(OsFamily.UNIX),
|
assertEquals(InstallJDK.fromURL(URI.create("http://foo")).render(OsFamily.UNIX),
|
||||||
"setupPublicCurl || return 1\ninstallJDK http://foo || return 1\n");
|
"setupPublicCurl || return 1\ninstallJDKFromURL http://foo || return 1\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,41 +133,40 @@ function setupPublicCurl() {
|
||||||
ensure_can_resolve_public_dns
|
ensure_can_resolve_public_dns
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
function setupJavaHomeInProfile() {
|
||||||
|
test -n \"$SUDO_USER\" && cat >> `getent passwd $SUDO_USER| cut -f6 -d:`/.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
|
||||||
|
}
|
||||||
|
|
||||||
function installJDK() {
|
function installJDK() {
|
||||||
if hash curl 2>/dev/null; then
|
if hash apt-get 2>/dev/null; then
|
||||||
if [ `uname -m` == 'x86_64' ]; then
|
export pkg=openjdk-7-jdk
|
||||||
local url=${1:-http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.tar.gz}
|
apt-get-install $pkg || ( apt-get-upgrade && apt-get-install $pkg )
|
||||||
else
|
elif hash yum 2>/dev/null; then
|
||||||
local url=${1:-http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-i586.tar.gz}
|
export pkg=java-1.7.0-openjdk
|
||||||
fi
|
yum --nogpgcheck -y ensure $pkg
|
||||||
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
|
else
|
||||||
abort "curl not available.. cannot install openjdk"
|
abort "we only support apt-get and yum right now... please contribute!"
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
return 0
|
JAVA_HOME=`ls -d /usr/lib/jvm/java-7-openjdk-*|grep -v common`
|
||||||
|
ln -Fs $JAVA_HOME /usr/local/jdk
|
||||||
|
/usr/local/jdk/bin/java -version || abort "cannot run java"
|
||||||
|
setupJavaHomeInProfile
|
||||||
}
|
}
|
||||||
|
|
||||||
END_OF_JCLOUDS_SCRIPT
|
END_OF_JCLOUDS_SCRIPT
|
||||||
|
@ -178,7 +177,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
|
||||||
installJDK || exit 1
|
installOpenJDK || exit 1
|
||||||
|
|
||||||
END_OF_JCLOUDS_SCRIPT
|
END_OF_JCLOUDS_SCRIPT
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue