summaryrefslogtreecommitdiffstats
path: root/common/scripts/DrakconnectConf.pm
blob: c85f0c35b0ce1a620389794ec5ba906251d1d11a (plain)
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
#!/usr/bin/perl

package DrakconnectConf;
require "/usr/share/wizards/common/scripts/Vareqval.pm";
use strict;

my	$file = "/etc/sysconfig/network-scripts/drakconnect_conf";
sub	new {
    my	$self = {};
    
    my %mdk = Vareqval->get($file);
    $self->{mdk} = \%mdk;
    foreach (keys %{$self->{mdk}}) {
	if (/.*(Eth\d)Known.*/) {
	    my $device = $1;
	    $self->{mdk}{$_} =~ /.*true.*/ and $self->{device} = $device;
	}
    }
    !$self->{device} and return -1;
    bless $self;
}

sub	get_device {
    my	$self = shift;

    $self->{device};
}

sub	is_dhcp {
    my	$self = shift;

    $self->get_from_known_dev("BootProto") =~ /.*dhcp.*/;
}

sub	get {
    my	$self = shift;
    my	$key = shift;

    exists $self->{mdk}->{$key} or die "no $key field in $file";
    $self->{mdk}->{$key};
}

sub	get_from_known_dev {
    my	$self = shift;
    my	$arg = shift;

    my	$device = $self->{device};
    exists $self->{mdk}{$device.$arg} or die "no $arg for $device in $file";
    $self->{mdk}{$device.$arg};
}