summaryrefslogtreecommitdiffstats
path: root/perl-install/standalone/drakups
blob: 47539278ed043368d4be440ddb4459f34790eace (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
#!/usr/bin/perl

use strict;
use lib qw(/usr/lib/libDrakX);
use common;
use detect_devices;
use Libconf qw(:functions);
use Libconf::Glueconf::Ups;

#------------------------------------------------------------------
# UPS autoconfig:

my $file = "/etc/ups/ups.conf";

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->{name} || $ups_device->{DESCRIPTION};
    $str =~ s/ /_/g;

    if (!exists $struct->{$str}) { 
	    $struct->{$str}{port} = $ups_device->{port} || $ups_device->{DEVICE};
	    $struct->{$str}{driver} = $ups_device->{driver};
    }
}

$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);