#!/bin/sh
# Script to establish a routed and NAT'd ppp link between a Palm PDA
# and your PC.

# This script accompanies the article at 
# http://atulchitnis.net/writings/palm-ppp.php

# By Atul Chitnis <http://atulchitnis.net>

# Version 1.1

# Note - if you are using a USB connection, start the connection 
# at the Palm end *FIRST*, wait 2-3 seconds, then run this script.

# ---- start of parameter block 

if [ "$1" == "" ] ; then
	echo usage: palm-ppp /dev/device_file
	exit 1
fi

# The port your Palm is connected to
MyPort="$1"

# The speed it talks at (ignored for USB connections)
MyBaud="115200"

# The IP address to assign to the Palm
MyPalmIP="192.168.99.2"

# The IP address to assign to PC's side of the link
MyPcIP="192.168.99.1"

# What DNS should the Palm use?
MyDNS=`grep ^nameserver /etc/resolv.conf|awk '{ print "ms-dns " $2 }'`
# Comment the previous line and uncomment and edit the next line if you
# prefer to use a DNS different from the ones in your /etc/resolv.conf
# MyDNS="192.168.1.1"

# Where are my tools?
MyTools="/sbin/"

# Where is pppd?
MyPPPD="/usr/sbin/pppd"

# ---- end of parameter block 

# All done, kick off pppd to talk to the port and establish a link
# pppd will wait for the actual connection to happen before going 
# into the background

${MyPPPD} ${MyPort} ${MyBaud} local noauth \
  ${MyPcIP}:${MyPalmIP} $MyDNS passive nodetach asyncmap 0

exit $?
