#!/bin/bash ############################################################################### # Establish a PPP connection using a Siemens phone, IrDA and GPRS. # # Originaly developed by: Per Weijnitz # Modified to use any network by: Maciej Kosiedowski ############################################################################### if [[ $1 != "" && $2 != "" && $3 != "" ]]; then USER="$1" PASS="$2" APN="$3" IRCOMMDEV=/dev/ircomm0 if [[ $4 == "" ]]; then NUMBER="*99***1#" else NUMBER="$4" fi # See whether there is irda0 interface if ! /sbin/ifconfig irda0 >/dev/null 2>/dev/null then echo "Cannot find network interface irda0!" >&2 exit 1 fi # Write connection script echo "Starting pppd..." cat << SCRIPTEOF > /tmp/chat_irda_gprs ABORT NOCARRIER ABORT BUSY ABORT ERROR '' ATZ OK 'AT+CGDCONT=1,"IP","$APN"' OK ATDT$NUMBER SCRIPTEOF # Connect if ! pppd crtscts lock asyncmap 0 modem usepeerdns nodetach defaultroute user $USER password $PASS $IRCOMMDEV 115200 connect '/usr/sbin/chat -t 60 -f /tmp/chat_irda_gprs' & then echo "pppd could not setup modem!" >&2 exit 1 fi PPPPID=$! echo "Give it some time to boot..." sleep 10 # Set up routes echo "Setting up routes..." route del default route add -net 10.10.10.0 netmask 255.255.255.0 dev ppp0 route add default gw 10.10.10.10 cp /etc/ppp/resolv.conf /etc/resolv.conf echo -n "Press ENTER to shutdown... " read TMP kill $PPPPID else echo "usage: $0 username password APN [number]" fi