summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Vignaud <tvignaud@mandriva.org>2003-11-26 16:39:04 +0000
committerThierry Vignaud <tvignaud@mandriva.org>2003-11-26 16:39:04 +0000
commit777a698b8d7898e7bd10d2dc86ea0b3e34b5748b (patch)
tree5d05570aa0f617e691c9f298eb85fb0ff46d29ca
parent77ea812854ab27b687953ca7f329222211ba18bd (diff)
downloaddrakx-777a698b8d7898e7bd10d2dc86ea0b3e34b5748b.tar
drakx-777a698b8d7898e7bd10d2dc86ea0b3e34b5748b.tar.gz
drakx-777a698b8d7898e7bd10d2dc86ea0b3e34b5748b.tar.bz2
drakx-777a698b8d7898e7bd10d2dc86ea0b3e34b5748b.tar.xz
drakx-777a698b8d7898e7bd10d2dc86ea0b3e34b5748b.zip
- configure properly usb & serial connected mge devices
- use perl-Libconf to shrink down the code size and better respect the user config file (keep important comments and the like - thx dam's for his support)
-rwxr-xr-xperl-install/standalone/drakups66
1 files changed, 17 insertions, 49 deletions
diff --git a/perl-install/standalone/drakups b/perl-install/standalone/drakups
index bb65aae02..08a3008c6 100755
--- a/perl-install/standalone/drakups
+++ b/perl-install/standalone/drakups
@@ -4,63 +4,31 @@ use strict;
use lib qw(/usr/lib/libDrakX);
use common;
use detect_devices;
-
-#------------------------------------------------------------------
-# to be moved in MDK::Common as a generalisation of (read|update)_gnomekderc
-# once cooker is unfrozen and major releases are allowed again.
-#
-# but there's a "bug" that prevent factorization: current
-# (read|update)_gnomekderc keep comments ... and minimize intrusions
-
-sub read_all_gnomekderc {
- my ($file) = @_;
- my (@a, %h);
- my ($section, @section);
- foreach (MDK::Common::File::cat_($file)) {
- s/#.*//;
- if (/^\s*\[(.*)\]/) {
- # remove all "if $section" tests if options out of sections is needed
- push @a, [ $section, [ @section ] ] if $section;
- $section = $1;
- $h{$section} = { };
- @section = ();
- } elsif (/^\s*(.*?)=(.*)/) {
- push @section, $1;
- $h{$section}{$1} = $2;
- }
- }
- push @a, [ $section, [ @section ] ] if $section;
- \@a, \%h;
-}
-
-# lost comment but keep sections & options order:
-sub update_all_gnomekderc {
- my ($file, $list, $hvalues) = @_;
- output($file, map {
- my ($section, $items) = @$_;
- "\n[$section]\n", map { $_ . "=" . $hvalues->{$section}{$_} . "\n" } @$items;
- } @$list);
-}
-#------------------------------------------------------------------
+use Libconf qw(:functions);
+use Libconf::Glueconf::Ups;
#------------------------------------------------------------------
# UPS autoconfig:
my $file = "/etc/ups/ups.conf";
-my ($sections, $sec_contents) = read_all_gnomekderc($file);
-my @ups_devices = sort values %$sec_contents;
+my $struct = Libconf::Glueconf::Ups->new('ups.conf'); #Libconf::Glueconf::ups->new($file, 'ups', '');
+
+detect_devices::probeSerialDevices();
foreach my $ups_device (detect_devices::getUPS()) {
- my $str = $ups_device->{description};
- if (!find { $str eq $_->{port} } @ups_devices) {
- $str =~ s/ /_/g;
- push @$sections, [ $str, [ qw(driver port) ] ];
- $sec_contents->{$str} = {
- port => $ups_device->{bus} eq 'USB' ? "/dev/usb/hid/hiddev0" : $ups_device->{device},
- driver => $ups_device->{bus} eq 'USB' ? "hidups" : "",
- };
+ my $str = $ups_device->{name} || $ups_device->{DESCRIPTION};
+
+ if (!exists $struct->{$str}) {
+ $struct->{$str}{port} = $ups_device->{port} || $ups_device->{DEVICE};
+ $struct->{$str}{driver} = $ups_device->{driver};
}
}
-update_all_gnomekderc($file, $sections, $sec_contents);
+$struct->writeConf($file);
+
+my $drivers_table = glob("/usr/share/doc/nut-*/docs/driver.list");
+
+# driver list from nutupsdrv(8)
+my @drivers = qw(apcsmart bcmxcp belkin bestferrups801-807 bestfortress bestuferrups bestups cyberpower dummycons etapro everups fentonups genericups hidups hp isbmex liebert masterguard mge-shut mge-utalk microdowell newapc oneac powercom powernet sec sms snmp-ups tripplite tripplitesu victronups);
+