#!/usr/bin/sh
# Run ppp daemon, with user-specified parameters. Daemon is run in
# a loop, so that if connection is dropped, we attempt reconnection
# automatically.

# These parameters work for the Iridium base unit attempting connection to the internet.

# Script asks for your username on sidearm as part of the options to open a ppp connection.

chmod a+rw /dev/ttySX13
port=/dev/ttySX13
baud=19200

delay=3

if [$1 = ""]
then
	echo "Usage: pppon <username>"
	exit 1
fi

while :
do
  echo Setting up the ppp link for user $1 at ${baud} baud on $port
  date
  pppd $port $baud noccp -detach debug user $1 connect "chat -v -f /etc/ppp/chatscript" crtscts defaultroute
  echo "**** PPP FAILED at `date`"
  sh ./pppoff
  sleep $delay
done
