]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - src/rc.d/helper/getdnsfromdhcpc.pl
Ein NTFS-Update fuer den Heiner :D
[people/teissler/ipfire-2.x.git] / src / rc.d / helper / getdnsfromdhcpc.pl
1 #!/usr/bin/perl
2 #
3 # Helper program to get DNS info from dhcpc .info file.
4 #
5 # (c) Lawrence Manning, 2001
6
7 use strict;
8 require 'CONFIG_ROOT/general-functions.pl';
9
10 my $count = $ARGV[0];
11 my ($dhcp, $dns, @alldns, %dhcpc);
12
13 if ($count eq "" || $count < 1) {
14 die "Bad DNS number given"; }
15
16 if (open(FILE, "${General::swroot}/red/iface")) {
17 my $iface = <FILE>;
18 close FILE;
19 chomp ($iface);
20 if (!&General::readhash("${General::swroot}/dhcpc/dhcpcd-$iface.info", \%dhcpc)) {
21 die "Could not open dhcpc info file";
22 }
23 } else {
24 die "Could not open interface file";
25 }
26
27
28 $dns = $dhcpc{'DNS'};
29
30 @alldns = split(',', $dns);
31
32 print "$alldns[$count - 1]\n";