
echo
echo "SGS2 ClockworkMod Manager by Chainfire"
echo "--------------------------------------"
echo
echo "This script will install the ClockworkMod Manager app for the"
echo "Samsung Galaxy S2.  This is required if you need the custom"
echo "recovery menu and you are not using the CF-Root zImage (which"
echo "would have installed the app automatically)."
echo
echo "NOTE: You'll still need a custom/rooted kernel for this app"
echo "to run."
echo

echo -n "Proceed (y/n)? (default: y): "
read do_cwm
echo

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


if [ -d WORKING_* ]
then
  echo
  echo Working folder found
else
  echo
  echo Working folder not found, you will need to create one!
  exit 0
fi


scripts/check_galaxy_s2
if [ "$?" != "1" ]
then
  echo "Error: ROM is not compatible"
  exit 0
fi


cwm_file=CWMManager.apk

cd WORKING_*

res=`find . -name $cwm_file`
if [ "$res" != "" ]
then
  echo "$res already found"
  cd ..
  exit 0
fi

cd ..
scripts/add_data_app dont_ask
cd WORKING_*

echo
echo "Copying app ..."
cp -v ../tools/samsung_files/sgs2_cwm/$cwm_file data/app/
cd ..

echo 
echo "Done"
