#!/bin/sh
ppp-go
echo PPP dialer done
ifconfig ppp0 | cut -b 21-34 > /etc/ppp/ifcon
echo Checking ip address
#WARNING: replace the 208 in the folowing line with the first three numbers
# of your IP. (the first three dont change, even with a dynamic IP)
cat /etc/ppp/ifcon | grep 208 > /etc/ppp/ifcon
sleep 2
echo Matching IP to DNS
nslookup `cat /etc/ppp/ifcon` > /etc/ppp/ifcon
echo Extracting hostname from DNS
#WARNING: replace the 'dial' in the following line with the first few
# characters of your DNS (usually is the same (well, hopefully)) 
cat /etc/ppp/ifcon | grep dial > /etc/ppp/ifcon
#WARNING: you may have to increase the 50 in the below line if you have a
# long domain name
cat /etc/ppp/ifcon | cut -b 10-50 > /etc/ppp/ifcon
cat /etc/ppp/ifcon | cut -f1 -d . > /tmp/HOSTNAME
echo Setting hostname
hostname `cat /tmp/HOSTNAME`
echo Killing and resetting
killall -1 agetty
killall -9 sendmail
killall -1 inetd
sendmail -bd -q5m
echo Setting time
#WARNING: replace the 'idt.net' in the following line with a time server of
# your choice
date -s `netdate idt.net | cut -b 37-44`
rm /tmp/hostname