summaryrefslogtreecommitdiffstats
path: root/lib/network/rfswitch.pm
blob: f73f718e3b99c943a66811d56ac4c657697c1bcf (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
package network::rfswitch;

use strict;
use MDK::Common;
use lib qw(/usr/lib/libDrakX);   # helps perl_checker
use detect_devices;

my $conf_file = "/etc/modprobe.d/rfswitch.conf";

my @settings = (
  {
      match => sub {
          # CL56, with buggy BIOS
          detect_devices::dmidecode_category('BIOS')->{Vendor} eq 'COMPAL' &&
          detect_devices::dmidecode_category('System')->{'Product Name'} eq '<BAD INDEX>';
      },
      module => 'acerhk',
      options => 'usedritek=1 autowlan=1 force_series=290',
      install => 'echo 1 > /proc/driver/acerhk/wirelessled',
      remove => 'echo 0 > /proc/driver/acerhk/wirelessled',
  },
);

sub configure() {
    my $setting = find { $_->{match}->() } @settings;
    if ($setting) {
        output_p($::prefix . $conf_file,
                 join("\n",
                      if_($setting->{options}, "options $setting->{module} $setting->{options}"),
                      if_($setting->{install}, "install $setting->{module} /sbin/modprobe --first-time --ignore-install $setting->{module} && $setting->{install}"),
                      if_($setting->{remove}, "remove $setting->{module} $setting->{remove}; /sbin/modprobe -r --ignore-remove $setting->{module}"),
                      "",
                  ));
        require modules;
        modules::set_preload_modules('rfswitch', $setting->{module});
    }
}

1;