echo "This script will patch Vagrant 1.8.5 so that it works with RHEL based os.  You need to be root to use this"
id_user=`id -u`
if [ $id_user -ne 0 ] ; then
   echo "Must be root to use this script"
   exit 1
fi
vagrant_dir="/opt/vagrant/embedded/gems/gems/vagrant-1.8.5/plugins/guests/linux/cap/"
vagrant_patched_file="public_key.rb"
sed_binary='sed'
if [ -s $vagrant_dir/$vagrant_patched_file ] ; then
   sed_bin=`which $sed_binary`
   if [ -z $sed_bin ] ; then 
         echo "sed is not installed"
         exit 2
   fi
   cd $vagrant_dir
   if [ ! -s ${vagrant_patched_file}.orig ] ; then
     cp -a $vagrant_patched_file ${vagrant_patched_file}.orig
   fi
   $sed_bin "/mv ~\/.ssh\/authorized_keys.tmp/a\\\t      chmod 0600 ~/.ssh/authorized_keys" ${vagrant_patched_file}.orig > $vagrant_patched_file 
else
   echo "Vagrant not in $vagrant_dir"
fi
