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