#!/usr/bin/perl

# This script restores /etc/hosts to a standalone configuration and resets
# the host name after a PPP connection has been terminated.  This script is
# provided "As is" and all responsibility for its use is assumed by the user.
# Copyright Mark A. Martin 1999.

# Replace "host1" with the name of your machine.

$host = 'host1';

# Resets the system hostname to $host.

system "/bin/hostname ${host}.localdomain";

# Writes a new /etc/hosts file with local network information.
# 10.0.0.1 is an IP address that cannot be assigned to a host on the Internet.
# See TCP/IP Network Administration by Craig Hunt or the Linux Network
# Administrator's Guide for more information.

open  FILE, ">/etc/hosts";
print FILE <<EOF;
127.0.0.1	localhost	localhost.localdomain
10.0.0.1	$host    	$host.localdomain
EOF
close FILE;

# Remove the backup copy of the original file if it exists.

if (-f '/etc/hosts.old') { unlink '/etc/hosts.old' }
