#!/bin/sh
#
# The environment is cleared before executing this script
# so the path must be reset.
#
PATH=/usr/bin:/usr/sbin:/usr/local/bin:/sbin:/bin
export PATH

# This will print to the screen the local & remote IP address when you
# make a successful ppp connection.  $4 = Local IP $5 = Remote IP
#
# The CARRIER speed at which you connected will be reported, if it's in
# the /var/log/messages file.  You also need the programs "tail" "cut"
# "tr" "grep" and "syslogd" running for this to work.
# You may have to add S95=46 to your modem init string
# to get your modem to report the DCE = CARRIER speed.
# Example: AT&FS95=46

echo "START: `date`" >> /etc/ppp/connection.log

if [ -s /var/log/messages ] && ( ps xc 2>/dev/null | grep -q syslogd 2>/dev/null )
then
  S=`tail -n 30 /var/log/messages 2>/dev/null | grep "CARRIER[^)]" 2>/dev/null | tr -d "^M" 2>/dev/null | cut -d: -f4 2>/dev/null`
  echo -n "$S" >> /etc/ppp/connection.log
  echo " Local: $4 -> Remote: $5 $1" >> /etc/ppp/connection.log
else
  echo " Local: $4 -> Remote: $5 $1" >> /etc/ppp/connection.log
fi

# Setup Firewall Rules for Masquerading

/etc/ppp/masquerade > /dev/null
