#!/bin/sh # Arguments: # interface serial-device serial-speed local-ip remote-ip # e.g. ppp0 /dev/modem 38400 128.146.116.42 128.146.116.4 PATH=/sbin:/usr/sbin:/bin:/usr/bin:/etc/ppp/scripts:/usr/local/sbin DEVICE="$1" IPADDR="$4" DUMMY=dummy0 TIMESERVER=ntp1.net.ohio-state.edu . /etc/sysconfig/network export HOSTNAME cd /etc/sysconfig/network-scripts # first take down old dummy interface if [ -e ifcfg-$DUMMY ]; then ifdown $DUMMY fi # fix /etc/hosts if [ -z "$IPADDR" ] then echo "ERROR: did not get a network address!" 1>2 ifdown $DEVICE exit 1 fi ipname=`host $IPADDR|awk '/^Name:/{print $2}'` hostline="$IPADDR $ipname $HOSTNAME" echo $hostline if [ ! -e /etc/hosts.bak ]; then cat /etc/hosts | egrep -iv '[:space:]'$HOSTNAME'\>' > /etc/hosts.bak grep -q '^127\.0\.0\.1[:space:]' /etc/hosts.bak || echo -e '127.0.0.1\tlocalhost\tlocalhost.localdomain' >> /etc/hosts.bak fi echo $hostline | cat /etc/hosts.bak - > /etc/hosts # put dummy device back up if [ -e ifcfg-$DUMMY ]; then ifup $DUMMY fi # now fix date rdate $TIMESERVER # restart sendmail if we have a pid file [ -f /var/run/sendmail.pid ] && kill -1 `head -1 /var/run/sendmail.pid` # flush mail queue sendmail -q