#!/bin/bash
# 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.

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 debug user $1 -detach connect "chat -v -f /etc/ppp/chatscript '' crtscts defaultroute
  echo "**** PPP FAILED at `date`"
  sleep $delay
done

#!/usr/bin/sh
# get the process ID of pppd using 'awk'
# use 'kill' to terminate the pppd process

for i in 'ps -e | grep pppd | awk '{print $1}'' 
 do kill $i 
done