| 1 |
#! /usr/bin/perl
|
| 2 |
|
| 3 |
# $Id$
|
| 4 |
#*********************************************************************
|
| 5 |
#
|
| 6 |
# dhclient-perl -- perl script that prints out DHCP data
|
| 7 |
#
|
| 8 |
# This script is part of FAI (Fully Automatic Installation)
|
| 9 |
# Copyright (c) 2000 by Thomas Lange, Universitaet zu Koeln
|
| 10 |
#
|
| 11 |
#*********************************************************************
|
| 12 |
# This program is free software; you can redistribute it and/or modify
|
| 13 |
# it under the terms of the GNU General Public License as published by
|
| 14 |
# the Free Software Foundation; either version 2 of the License, or
|
| 15 |
# (at your option) any later version.
|
| 16 |
#
|
| 17 |
# This program is distributed in the hope that it will be useful, but
|
| 18 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 19 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 20 |
# General Public License for more details.
|
| 21 |
#
|
| 22 |
# You should have received a copy of the GNU General Public License
|
| 23 |
# along with this program; see the file COPYING. If not, write to the
|
| 24 |
# Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
| 25 |
# MA 02111-1307, USA.
|
| 26 |
#*********************************************************************
|
| 27 |
|
| 28 |
# TODO: extract search info from DOMAIN
|
| 29 |
|
| 30 |
# map dhcp names to bootp names
|
| 31 |
%names = qw/
|
| 32 |
ip_address IPADDR
|
| 33 |
hostname HOSTNAME
|
| 34 |
network_number NETWORK
|
| 35 |
subnet_mask NETMASK
|
| 36 |
broadcast_address BROADCAST
|
| 37 |
routers GATEWAYS
|
| 38 |
domain_name DOMAIN
|
| 39 |
domain_name_servers DNSSRVS
|
| 40 |
server_name SERVER
|
| 41 |
time_servers TIMESRVS
|
| 42 |
ntp_servers NTPSRVS
|
| 43 |
nis_domain YPDOMAIN
|
| 44 |
nis_servers YPSRVR
|
| 45 |
option_170 FAI_LOCATION
|
| 46 |
option_171 FAI_ACTION
|
| 47 |
option_172 FAI_FLAGS
|
| 48 |
option_173 FAI_NFSSERVER_USR
|
| 49 |
option_174 reseved174
|
| 50 |
option_175 reseved175
|
| 51 |
/;
|
| 52 |
|
| 53 |
# these lists should be listed also as single items
|
| 54 |
@list = qw/domain_name_servers routers time_servers ntp_servers nis_servers/;
|
| 55 |
foreach (@list) { $listitem{$_} = 1; }
|
| 56 |
|
| 57 |
# exit if no data is available
|
| 58 |
exit 0 unless $ENV{new_option_170};
|
| 59 |
|
| 60 |
foreach $name (sort keys %names) {
|
| 61 |
$dhcpname="new_$name";
|
| 62 |
if ($ENV{$dhcpname}) {
|
| 63 |
print "$names{$name}='$ENV{$dhcpname}'\n";
|
| 64 |
items($name) if $listitem{$name};
|
| 65 |
}
|
| 66 |
}
|
| 67 |
|
| 68 |
exit 0;
|
| 69 |
|
| 70 |
|
| 71 |
# - - - - - - - - - - - - - - - - - - - - -
|
| 72 |
sub items {
|
| 73 |
my $key = shift;
|
| 74 |
my $i = 1;
|
| 75 |
foreach (split /\s+/,$ENV{"new_$key"}){
|
| 76 |
print "$names{$key}_$i='$_'\n";
|
| 77 |
$i++;
|
| 78 |
}
|
| 79 |
}
|