address case when curl is not yet installed

This commit is contained in:
Adrian Cole 2012-01-14 21:06:05 -08:00
parent b3d6ad2ae8
commit a28a981931
4 changed files with 14 additions and 9 deletions

View File

@ -149,18 +149,23 @@ public class RunScriptData {
public static String aptInstall = "apt-get install -f -y -qq --force-yes";
public static String aptInstallLazyUpgrade(String packageName) {
return aptInstall + " " + packageName + "|| (" + "apt-get update -qq&&" + "apt-get upgrade -y -qq" + ")&&"
+ aptInstall + " " + packageName;
}
public static final Statement APT_RUN_SCRIPT = newStatementList(//
exec("which nslookup >&- 2>&-|| " + aptInstallLazyUpgrade("dnsutils")),//
normalizeHostAndDNSConfig(),//
exec("which curl >&- 2>&-|| " + aptInstall + " curl"),//
exec("which nslookup >&- 2>&-|| " + aptInstall + " dnsutils"),//
exec("which curl >&- 2>&-|| " + aptInstallLazyUpgrade("curl")),//
JDK7_INSTALL_TGZ);
public static String yumInstall = "yum --nogpgcheck -y install";
public static final Statement YUM_RUN_SCRIPT = newStatementList(//
exec("which nslookup >&- 2>&-|| " + yumInstall + " bind-utils"),//
normalizeHostAndDNSConfig(),//
exec("which curl >&- 2>&-|| " + yumInstall + " curl"),//
exec("which nslookup >&- 2>&-|| " + yumInstall + " bind-utils"),//
JDK7_INSTALL_TGZ);
public static final Statement ZYPPER_RUN_SCRIPT = newStatementList(//

View File

@ -99,10 +99,10 @@ PermitRootLogin no
/etc/init.d/sshd reload||/etc/init.d/ssh reload
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
which nslookup >&- 2>&-|| apt-get install -f -y -qq --force-yes dnsutils|| (apt-get update -qq&&apt-get upgrade -y -qq)&&apt-get install -f -y -qq --force-yes dnsutils
grep `hostname` /etc/hosts >/dev/null || awk -v hostname=`hostname` 'END { print $1" "hostname }' /proc/net/arp >> /etc/hosts
nslookup yahoo.com >/dev/null || echo nameserver 208.67.222.222 >> /etc/resolv.conf
which curl >&- 2>&-|| apt-get install -f -y -qq --force-yes curl
which nslookup >&- 2>&-|| apt-get install -f -y -qq --force-yes dnsutils
which curl >&- 2>&-|| apt-get install -f -y -qq --force-yes curl|| (apt-get update -qq&&apt-get upgrade -y -qq)&&apt-get install -f -y -qq --force-yes curl
mkdir -p /usr/local/jdk
curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET http://download.oracle.com/otn-pub/java/jdk/7u2-b13/jdk-7u2-linux-x64.tar.gz |(mkdir -p /usr/local &&cd /usr/local &&tar -xpzf -)
mv /usr/local/jdk1.7*/* /usr/local/jdk/

View File

@ -99,10 +99,10 @@ PermitRootLogin no
/etc/init.d/sshd reload||/etc/init.d/ssh reload
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
which nslookup >&- 2>&-|| apt-get install -f -y -qq --force-yes dnsutils|| (apt-get update -qq&&apt-get upgrade -y -qq)&&apt-get install -f -y -qq --force-yes dnsutils
grep `hostname` /etc/hosts >/dev/null || awk -v hostname=`hostname` 'END { print $1" "hostname }' /proc/net/arp >> /etc/hosts
nslookup yahoo.com >/dev/null || echo nameserver 208.67.222.222 >> /etc/resolv.conf
which curl >&- 2>&-|| apt-get install -f -y -qq --force-yes curl
which nslookup >&- 2>&-|| apt-get install -f -y -qq --force-yes dnsutils
which curl >&- 2>&-|| apt-get install -f -y -qq --force-yes curl|| (apt-get update -qq&&apt-get upgrade -y -qq)&&apt-get install -f -y -qq --force-yes curl
mkdir -p /usr/local/jdk
curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET http://download.oracle.com/otn-pub/java/jdk/7u2-b13/jdk-7u2-linux-x64.tar.gz |(mkdir -p /usr/local &&cd /usr/local &&tar -xpzf -)
mv /usr/local/jdk1.7*/* /usr/local/jdk/

View File

@ -78,10 +78,10 @@ END_OF_SCRIPT
# add desired commands from the user
cat >> $INSTANCE_HOME/runScriptWithCreds.sh <<'END_OF_SCRIPT'
cd $INSTANCE_HOME
which nslookup >&- 2>&-|| apt-get install -f -y -qq --force-yes dnsutils|| (apt-get update -qq&&apt-get upgrade -y -qq)&&apt-get install -f -y -qq --force-yes dnsutils
grep `hostname` /etc/hosts >/dev/null || awk -v hostname=`hostname` 'END { print $1" "hostname }' /proc/net/arp >> /etc/hosts
nslookup yahoo.com >/dev/null || echo nameserver 208.67.222.222 >> /etc/resolv.conf
which curl >&- 2>&-|| apt-get install -f -y -qq --force-yes curl
which nslookup >&- 2>&-|| apt-get install -f -y -qq --force-yes dnsutils
which curl >&- 2>&-|| apt-get install -f -y -qq --force-yes curl|| (apt-get update -qq&&apt-get upgrade -y -qq)&&apt-get install -f -y -qq --force-yes curl
mkdir -p /usr/local/jdk
curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET http://download.oracle.com/otn-pub/java/jdk/7u2-b13/jdk-7u2-linux-x64.tar.gz |(mkdir -p /usr/local &&cd /usr/local &&tar -xpzf -)
mv /usr/local/jdk1.7*/* /usr/local/jdk/