#!/bin/sh
#
# This file /etc/ppp/ip-up is run by pppd when there's a
# successful ppp connection.
#
# Put any commands you want run after a successful connection
# in this file.
#
# Any commands you want printed to the screen should be directed
# to: >/dev/console
#
# Other commands should not be directed to: >/dev/console
#
# The companion file is /etc/ppp/ip-down, it's run when the PPP
# connection ends.
#
# This file is created when you run pppsetup: Wed Jan 28 16:43:20  1998
#
# 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 W1 or S95=46 to your modem init string
# to get your modem to report the DCE = CARRIER speed.
# Examples: AT&FW1 or AT&FS95=46

echo >/dev/console
echo " * YES! PPP connected. *" >/dev/console

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" >/dev/console
echo " Local IP: $4 -> Remote IP: $5" >/dev/console
else
echo " Local IP: $4 -> Remote IP: $5" >/dev/console
fi

# If you want sendmail to send any mail in /var/spool/mqueue when
# you connect, remove the # below.

#sendmail -q

# If you want fetchmail to get your mail when you connect and check
# every 300 seconds = 5 minutes for mail, remove the # below.

#fetchmail -d 300

# End...
