#!/bin/sh
#	ip-up
#
#	script ip-up (taken from linux Slackware 7.1's :
#	http://www.slackware.com), shows local and remote IP's and
#	starts ip-check
#	as of version 0.4, you can also enable an option to try and
#	keep the same IP after having been disconnected (see $keepip).
#	you should add the persist option in your peers/adsl file or wathever
#	options file you use to connect
#
#							Olivier Mehani, 2002
#							   <shtrom@ssji.net>
#
#	$Date: 2002/11/10 21:10:47 $
#	$Revision: 1.5 $
#

PATH=/usr/bin:/usr/sbin:/usr/local/bin:/sbin:/bin
export PATH

logterm=/dev/tty7
keepip=0	#try to keep the same ip, 0=no 1=yes
keeptime=12	#killing -HUP period (in hours), this should be okay

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" > $logterm 2>&1
echo "Local: $4 -> Remote: $5 $1" > $logterm 2>&1
else
echo "Local: $4 -> Remote: $5 $1" > $logterm 2>&1
fi

###PPPDIR###/ip-check > $logterm 2>&1

if [ "$keepip" == "1" ]; then
    echo -n Scheduling kill -HUP
    at now + $keeptime hours < ###STARTUPDIR###/ppp-kill-at > /dev/null 2>&1
    echo " Done"
fi
