############################################################################
#
# Copyright (c) 2012 - dsixda (dislam@rocketmail.com)
#
# Android Kitchen is 100% free.  This script file is intended for personal
# and/or educational use only.  It may not be duplicated for monetary
# benefit or any other purpose without the permission of the developer.
#
############################################################################

clear

echo
echo "----------------------------------------------------------------"
echo  
echo "The Bash command shell is handy for command line completion when "
echo "using a terminal emulator (e.g. ConnectBot) on your Android"
echo "device.  To start it from a shell, type: bash"
echo
echo "----------------------------------------------------------------"
echo 

echo -n "Proceed with install (y/n)? (default: y): "
read do_install

if [ "$do_install" == "n" ]
then
  exit 0
fi

echo 

if [ -d WORKING_* ]
then
  echo Found working folder
else
  echo No working folder found!
  exit 0
fi

cd WORKING_*

if [ ! -d system ]
then
  echo "No system folder found!"
  cd ..
  exit 0
fi


bash_path=`find . -name bash`
if [ "$bash_path" == "" ] 
then

  if [ -d system/xbin ]
  then
    echo Found /system/xbin
  else
    echo Creating /system/xbin
    mkdir system/xbin
  fi

  echo "Adding /system/xbin/bash"
  cp ../tools/bash system/xbin/
else
  echo "Found $bash_path"
fi

cd ..
scripts/add_bash_to_update_script

