File: dhclient-perl

package info (click to toggle)
fai 6.5.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,084 kB
  • sloc: sh: 6,774; perl: 5,665; makefile: 138
file content (83 lines) | stat: -rwxr-xr-x 2,733 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#! /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++;
    }
}