#!/bin/bash
#----------------------------------------------------------------
# Script to connect to the GPRS service on a cellphone via bluetooth
# Tested on Debian Etch and Ubuntu Hardy
# For any help with this script : raza.sayed@gmail.com
# Enjoy ! ;)
#-----------------------------------------------------------------
echo "Getting your phones bluetooth address, wait a moment..."
addr="$(hcitool scan)"
addr=${addr:14:17}
if [ ${#addr} -eq 0 ]
then
echo "Oops !,cannot connect to phone . Is bluetooth activated on the phone ?"
exit 0
fi
echo "OK"
if [ ! -f "/usr/bin/settings_exist" ]
then
touch /usr/bin/settings_exist
echo Enter your Access Point name :
read ap
echo "Enter the dial up number (If you are not sure then enter *99#)"
read dialnum
if [ ! -f "/etc/bluetooth/pin" ]
then
echo "\"1234\"" > /etc/bluetooth/pin
fi
echo "#!/bin/sh" > /etc/bluetooth/pin-helper
echo "echo -n \"PIN:\" cat /etc/bluetooth/pin" >> /etc/bluetooth/pin-helper
echo "rfcomm0{" > /etc/bluetooth/rfcomm.conf
echo "bind yes;" >> /etc/bluetooth/rfcomm.conf
echo "device" $addr";" >> /etc/bluetooth/rfcomm.conf
echo "channel 1;" >> /etc/bluetooth/rfcomm.conf
echo "comment \"Nokia\";" >> /etc/bluetooth/rfcomm.conf
echo "}" >> /etc/bluetooth/rfcomm.conf
echo "/dev/rfcomm0 115200" > /etc/ppp/peers/gprs
echo "connect '/usr/sbin/chat -v -f/etc/ppp/chat-gprs'" >> /etc/ppp/peers/gprs
echo "crtscts" >> /etc/ppp/peers/gprs
echo "modem -detach" >> /etc/ppp/peers/gprs
echo "noccp" >> /etc/ppp/peers/gprs
echo "defaultroute" >> /etc/ppp/peers/gprs
echo "usepeerdns" >> /etc/ppp/peers/gprs
echo "noauth" >> /etc/ppp/peers/gprs
echo "ipcp-accept-remote" >> /etc/ppp/peers/gprs
echo "ipcp-accept-local" >> /etc/ppp/peers/gprs
echo "noipdefault" >> /etc/ppp/peers/gprs
echo "''ATZ OK" > /etc/ppp/chat-gprs
echo "AT+CGDCONT=1,\"IP\",\""$ap"\"" >> /etc/ppp/chat-gprs
echo "OK \"ATD"$dialnum"\"" >> /etc/ppp/chat-gprs
echo "CONNECT ''" >> /etc/ppp/chat-gprs
echo "Setup completed successfully ! :)"
echo "Now lets connect :)"
fi
echo "Connecting..."
rfcomm bind /dev/rfcomm0 $addr
pppd call gprs
exit 0