Skip to content

Commit

Permalink
Merge pull request #86 from ClogenyTechnologies/ali/add_chfclnt_vrsn_…
Browse files Browse the repository at this point in the history
…option

Added code for Ubuntu and CentOS to accept version of Chef to download and install.
  • Loading branch information
Nimisha Sharad committed Nov 10, 2015
2 parents f02b942 + 3ac761e commit 697e345
Showing 1 changed file with 42 additions and 3 deletions.
45 changes: 42 additions & 3 deletions ChefExtensionHandler/bin/chef-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,27 @@ curl_status(){
fi
}

get_config_settings_file() {
config_files_path="$chef_extension_root/config/*.settings"
config_file_name=`ls $config_files_path 2>/dev/null | sort -V | tail -1`

echo $config_file_name
}

get_chef_version() {
config_file_name=$(get_config_settings_file)
if [[ -z "$config_file_name" ]]; then
echo "No config file found !!"
else
if cat $config_file_name 2>/dev/null | grep -q "bootstrap_version"; then
chef_version=`sed 's/.*bootstrap_version":"\(.*\)".*/\1/' $config_file_name 2>/dev/null`
echo $chef_version
else
echo ""
fi
fi
}

install_from_repo_centos(){
platform="centos"
curl_check $platform
Expand All @@ -106,7 +127,16 @@ install_from_repo_centos(){
curl_exit_code=$?
curl_status $curl_exit_code $yum_repo_config_url $yum_repo_path

yum -y install chef
echo "Installing chef-client package"
chef_version=$(get_chef_version)
if [ "$chef_version" = "No config file found !!" ]; then
echo "Configuration error. Azure chef extension Settings file missing."
exit 1
elif [[ -z "$chef_version" ]]; then
yum -y install chef
else
yum -y install chef-$chef_version
fi
check_installation_status
}

Expand Down Expand Up @@ -143,8 +173,17 @@ install_from_repo_ubuntu() {
apt-get update
echo "done."

echo "Installing chef-client package"
apt-get install chef
echo "Installing chef-client package"
chef_version=$(get_chef_version)
if [ "$chef_version" = "No config file found !!" ]; then
echo "Configuration error. Azure chef extension Settings file missing."
exit 1
elif [[ -z "$chef_version" ]]; then
apt-get install chef
else
apt-get install chef=$chef_version\*
fi

check_installation_status
}

Expand Down

0 comments on commit 697e345

Please sign in to comment.