update_bundler() {
  gem list | grep 'bundler' &> /dev/null
  if [ $? -gt 0 ]; then
    gem install bundler
  fi
  if [ "$1" = 'quiet' ]; then
    bundle update  #> /dev/null 2> /dev/null
  else
    bundle update
  fi
  bundle check > /dev/null 2> /dev/null
  return $?
}

i="0"

until (bundle check > /dev/null 2> /dev/null) || (update_bundler 'quiet') || [ $i -gt 10 ]; do
  echo "Bundle update. Attempt: $i"
  update_bundler 'quiet'
  i=$[$i+1]
done

if !(bundle check > /dev/null 2> /dev/null); then
  echo "Last Bundle update attempt."
  update_bundler
fi

update_bundler() {
  gem list | grep 'bundler' &> /dev/null
  if [ $? -gt 0 ]; then
    gem install bundler
  fi
  if [ "$1" = 'quiet' ]; then
    bundle install --deployment > /dev/null 2> /dev/null
  else
    bundle install --deployment
  fi
}

i="0"

until (bundle check > /dev/null 2> /dev/null) || [ $i -gt 10 ]; do
  echo "Bundle update. Attempt: $i"
  update_bundler 'quiet'
  i=$[$i+1]
done

if !(bundle check > /dev/null 2> /dev/null); then
  echo "Last Bundle update attempt."
  update_bundler
fi

--- 
+++ 
@@ -4,17 +4,15 @@
     gem install bundler
   fi
   if [ "$1" = 'quiet' ]; then
-    bundle update  #> /dev/null 2> /dev/null
+    bundle install --deployment > /dev/null 2> /dev/null
   else
-    bundle update
+    bundle install --deployment
   fi
-  bundle check > /dev/null 2> /dev/null
-  return $?
 }
 
 i="0"
 
-until (bundle check > /dev/null 2> /dev/null) || (update_bundler 'quiet') || [ $i -gt 10 ]; do
+until (bundle check > /dev/null 2> /dev/null) || [ $i -gt 10 ]; do
   echo "Bundle update. Attempt: $i"
   update_bundler 'quiet'
   i=$[$i+1]
Rework the script to deal with non-presence of bundler from the get go

git-svn-id: d8f3215415546ce936cf3b822120ca56e5ebeaa0@1531464 13f79535-47bb-0310-9956-ffa450edef68
