#!/bin/bash
here=$(dirname "$0")

COUNT=2
if [ $# -lt $COUNT ] 
then
   echo
   echo "Deploys a folder of bars to a device."
   echo
   echo "Usage: batchbar-deploy.sh path-to-bars device-ip [device-password]"
   echo
   exit 65
fi

if [ $# -eq $COUNT ] 
then
  for f in $1/*.bar
  do
    echo Deploying "$f"
    ${here}/blackberry-deploy -installApp $2 "$f"
    echo
  done
else
  for f in $1/*.bar
  do
    echo Deploying "$f"
    ${here}/blackberry-deploy -installApp $2 "$f" -password $3
    echo
  done  
fi
