diff --git a/install/chef.sh b/install/chef.sh index 0db7b6b3..0dbe9c8e 100755 --- a/install/chef.sh +++ b/install/chef.sh @@ -19,7 +19,8 @@ sudo mkdir -p /root/backup/chef sudo rpm -q chef-server if [[ "$?" != "0" ]]; then - download $CHEF_SRV chef-server install || exit $? + CHEF_SRV_SOURCE=`fastesturl "$CHEF_SRV" "$CHEF_SRV_HUAWEI"` + download $CHEF_SRV_SOURCE chef-server install || exit $? else echo "chef-server has already installed" fi @@ -41,12 +42,13 @@ fi echo "configure chef client and knife" # configure chef client and knife -rpm -q chef -if [[ "$?" != "0" ]]; then - download $CHEF_CLIENT `basename $CHEF_CLIENT` install || exit $? +if [[ `rpm -q chef` ]]; then + sudo rpm -e `rpm -q chef` else - echo "chef has already installed" + echo "going to install chef client" fi +CENTOS_CHEF_CLIENT_SOURCE=`fastesturl "$CENTOS_CHEF_CLIENT" "$CENTOS_CHEF_CLIENT_HUAWEI"` +download $CENTOS_CHEF_CLIENT_SOURCE `basename $CENTOS_CHEF_CLIENT_SOURCE` install || exit $? sudo mkdir -p ~/.chef @@ -71,7 +73,9 @@ if [ $? -ne 0 ]; then exit 1 fi -knife cookbook upload --all --cookbook-path /var/chef/cookbooks +# Fix after bug 1397309 is fixed by upgrading chef-server +# work around by reducing concurrency to 1 +knife cookbook upload --all --cookbook-path /var/chef/cookbooks --concurrency 1 if [[ "$?" != "0" ]]; then echo "failed to add cookbooks" exit 1 diff --git a/install/cobbler.sh b/install/cobbler.sh index 99b19b80..f12b9712 100755 --- a/install/cobbler.sh +++ b/install/cobbler.sh @@ -235,12 +235,7 @@ fi # download packages cd /var/lib/cobbler/repo_mirror/centos_ppa_repo/ -fastesturl http://mirrors.hustunique.com http://mirror.centos.org -if [[ "$?" != "0" ]]; then - echo "failed to determine the fastest url for downloading centos ppa packages" - exit 1 -fi -read -r PPA_REPO_URL $time" | bc) -eq 1 ]; then - shortest=$time - echo "$url" > /tmp/url - fastest_url=$url + result=($(curl --max-time 20 -o /dev/null --header "Range: bytes=0-20000" -s -w "%{http_code} %{time_total}" $url)) + code=${result[0]} + time=${result[1]} + if [[ ${good_code[*]} =~ $code ]]; then + if [ $(echo "$shortest > $time" | bc) -eq 1 ]; then + shortest=$time + fastest_url=$url + fi fi shift done - echo "$fastest_url is the fastest source, using it" + if [[ -z $fastest_url ]]; then + exit 1 + fi + echo "$fastest_url" } copy2dir() diff --git a/install/prepare.sh b/install/prepare.sh index 7592c008..5a3be80c 100755 --- a/install/prepare.sh +++ b/install/prepare.sh @@ -236,12 +236,7 @@ else fi # download cobbler related packages -fastesturl "http://mirrors.hustunique.com" "http://mirror.centos.org" -if [[ "$?" != "0" ]]; then - echo "failed to determine the fastest source for centos ppa rpms" - exit 1 -fi -read -r CENTOS_PPA_SOURCE