summaryrefslogtreecommitdiffstats
path: root/common/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'common/scripts')
-rw-r--r--common/scripts/DrakconnectConf.pm26
1 files changed, 20 insertions, 6 deletions
diff --git a/common/scripts/DrakconnectConf.pm b/common/scripts/DrakconnectConf.pm
index 9b9a4e06..80ddbbfb 100644
--- a/common/scripts/DrakconnectConf.pm
+++ b/common/scripts/DrakconnectConf.pm
@@ -4,27 +4,40 @@ package DrakconnectConf;
require "__WIZ_HOME__/common/scripts/Vareqval.pm";
use strict;
+my $file = "/etc/sysconfig/network-scripts/drakconnect_conf";
sub new {
my $self = {};
- my %mdk = Vareqval->get("/etc/sysconfig/network-scripts/drakconnect_conf");
+ my %mdk = Vareqval->get($file);
$self->{mdk} = \%mdk;
foreach (keys %{$self->{mdk}}) {
if (/.*(Eth\d)Known.*/) {
my $device = $1;
- if ($self->{mdk}{$_} =~ /.*true.*/) {
- $self->{device} = $device;
- }
+ $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;
- return $self->{mdk}->{$key};
+ exists $self->{mdk}->{$key} or die "no $key field in $file";
+ $self->{mdk}->{$key};
}
sub get_from_known_dev {
@@ -32,5 +45,6 @@ sub get_from_known_dev {
my $arg = shift;
my $device = $self->{device};
- return $self->{mdk}{$device.$arg};
+ exists $self->{mdk}{$device.$arg} or die "no $arg for $device in $file";
+ $self->{mdk}{$device.$arg};
}