#! /usr/bin/perl #********************************************************************* # # dhclient-perl -- perl script that prints out DHCP data # # This script is part of FAI (Fully Automatic Installation) # Copyright (c) 2000-2006 by Thomas Lange, Universitaet zu Koeln # #********************************************************************* # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; see the file COPYING. If not, write to the # Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, # MA 02111-1307, USA. #********************************************************************* # TODO: extract search info from DOMAIN # map dhcp names to bootp names %names = qw/ ip_address IPADDR host_name HOSTNAME network_number NETWORK subnet_mask NETMASK broadcast_address BROADCAST routers GATEWAYS domain_name DOMAIN domain_name_servers DNSSRVS server_name SERVER time_servers TIMESRVS ntp_servers NTPSRVS subnet_cidr SUBNET_CIDR dhcp_server_identifier DHCP_SERVER_IDENTIFIER nis_domain YPDOMAIN nis_servers YPSRVR fai_config_src FAI_CONFIG_SRC fai_action FAI_ACTION fai_flags FAI_FLAGS option_170 FAI_CONFIG_SRC option_171 FAI_ACTION option_172 FAI_FLAGS option_173 reserved173 option_174 reserved174 option_175 reserved175 /; # these lists should also be listed as single items @list = qw/domain_name_servers routers time_servers ntp_servers nis_servers/; %listitem = map { $_ => 1 } @list; # use short host name $ENV{new_host_name} = (split '\.',$ENV{new_host_name})[0]; foreach $name (sort keys %names) { $dhcpname="new_$name"; if ($ENV{$dhcpname}) { print "$names{$name}='$ENV{$dhcpname}'\n"; items($name) if $listitem{$name}; } } exit 0; # - - - - - - - - - - - - - - - - - - - - - sub items { my $key = shift; my $i = 1; foreach (split /\s+/,$ENV{"new_$key"}){ print "$names{$key}_$i='$_'\n"; $i++; } }