diff options
author | Julian C. Dunn <jdunn@chef.io> | 2015-02-13 23:05:11 -0500 |
---|---|---|
committer | Bryan McLellan <btm@chef.io> | 2015-04-20 15:31:31 -0400 |
commit | 71a03417bd5a9b7b4520693cbb494e325ec8fef2 (patch) | |
tree | 36ebb8c10c77c4bd22711fb94df79adfa34f4cf6 | |
parent | c59ec730919f5265b787b26c68e0990deb9359a3 (diff) | |
download | chef-71a03417bd5a9b7b4520693cbb494e325ec8fef2.tar.gz |
Several bugs found during testing:
* Use -o option in curl to send the install.sh to a file.
This way stderr/stdout can be reserved for errors like
"curl: not found", ensuring it is captured.
* On AIX, ksh was shell-substituting $ARGV[0] before script
interpretation, so use a shift() trick to avoid the $
* If the chef-client binary doesn't exist at all, then avoid
proceeding with the rest of should_update_chef()
Tested on: AIX 7.1 + sudo, FreeBSD 10 + ca_root_nss + sudo
-rw-r--r-- | lib/chef/knife/bootstrap/templates/chef-full.erb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/chef/knife/bootstrap/templates/chef-full.erb b/lib/chef/knife/bootstrap/templates/chef-full.erb index 9260049ee6..c65cfaf725 100644 --- a/lib/chef/knife/bootstrap/templates/chef-full.erb +++ b/lib/chef/knife/bootstrap/templates/chef-full.erb @@ -16,6 +16,7 @@ tmp_dir="$tmp/install.sh.$$" # @return 0 if omnibus needs to be installed, non-zero otherwise should_update_chef() { if test ! -d "$1" ; then return 0 + elif test ! -f "$1/bin/chef-client" ; then return 0 elif test "$2" = "true" ; then return 1 elif test "$2" = "latest" ; then return 0 fi @@ -75,7 +76,7 @@ do_wget() { # do_curl URL FILENAME do_curl() { echo "trying curl..." - curl -sL <%= "--proxy \"#{knife_config[:bootstrap_proxy]}\" " if knife_config[:bootstrap_proxy] %> <%= knife_config[:bootstrap_curl_options] %> -D $tmp_dir/stderr "$1" > "$2" + curl -sL <%= "--proxy \"#{knife_config[:bootstrap_proxy]}\" " if knife_config[:bootstrap_proxy] %> <%= knife_config[:bootstrap_curl_options] %> -D $tmp_dir/stderr -o "$2" "$1" 2>$tmp_dir/stderr rc=$? # check for 404 grep "404 Not Found" $tmp_dir/stderr 2>&1 >/dev/null @@ -105,7 +106,7 @@ do_fetch() { # do_perl URL FILENAME do_perl() { echo "trying perl..." - perl -e 'use LWP::Simple; getprint($ARGV[0]);' "$1" > "$2" 2>$tmp_dir/stderr + perl -e "use LWP::Simple; getprint(shift @ARGV);" "$1" > "$2" 2>$tmp_dir/stderr rc=$? # check for 404 grep "404 Not Found" $tmp_dir/stderr 2>&1 >/dev/null |