wok-current rev 1910
tazndis, update rcS.conf and load ndiswrapper module.
author | Eric Joseph-Alexandre <erjo@slitaz.org> |
---|---|
date | Mon Dec 22 00:46:23 2008 +0100 (2008-12-22) |
parents | 0f29c565427b |
children | 28c442083d0a |
files | tazndis/stuff/tazndis |
line diff
1.1 --- a/tazndis/stuff/tazndis Sun Dec 21 17:32:59 2008 +0000 1.2 +++ b/tazndis/stuff/tazndis Mon Dec 22 00:46:23 2008 +0100 1.3 @@ -44,6 +44,9 @@ 1.4 "\.([[:xdigit:]]+)\.conf"; 1.5 my $re_dev_conf = "$re_dev_id:$re_dev_id\.([[:xdigit:]]+)\.conf"; 1.6 1.7 +my $rcs_config = "/etc/rcS.conf"; 1.8 +$rcs_config_change = 1; 1.9 + 1.10 # fixup list for parameters. 1.11 my %param_fixlist = ("EnableRadio|0" => "1", 1.12 "IBSSGMode|0" => "2", 1.13 @@ -99,9 +102,8 @@ 1.14 #* Replaced File.pm 1.15 1.16 sub basename(@_){ 1.17 - $var = $_[0]; 1.18 - $var =~ s#.*/(.*)$#$1#; 1.19 - return $var; 1.20 + ($a = shift) =~ s#.*/(.*)$#$1#; 1.21 + return $a; 1.22 } 1.23 1.24 1.25 @@ -205,6 +207,36 @@ 1.26 return $res; 1.27 } 1.28 1.29 +sub set_rcs_config { 1.30 + # Add ndiswrapper to LOAD_MODULES if needed. 1.31 + open (RCS_CONF, "< $rcs_config") or die "couldn't open $rcs_config:$!"; 1.32 + open (RCS_CONF1, "> $rcs_config.tmp") or die "couldn't open $rcs_config.tmp for writting:$!"; 1.33 + LINE: while(<RCS_CONF>){ 1.34 + if(/^LOAD_MODULES/){ 1.35 + if (!/^LOAD_MODULES=.*ndiswrapper/){ 1.36 + print "Add ndiswrapper to module list...\n"; 1.37 + $_ =~ s/(.*)\"$/$1 ndiswrapper\"/; 1.38 + $rcs_config_change = 0; 1.39 + } 1.40 + } 1.41 + chomp; 1.42 + print RCS_CONF1 "$_\n"; 1.43 + } 1.44 + close RCS_CONF, RCS_CONF1; 1.45 + 1.46 + if($rcs_config_change == 0){ 1.47 + rename "$rcs_config.tmp","$rcs_config" or die "couldn't update $rcs_config: $!"; 1.48 + } else { 1.49 + unlink "$rcs_config.tmp"; 1.50 + } 1.51 + 1.52 +} 1.53 + 1.54 +sub load_ndiswrapper { 1.55 + open (LSMOD, " lsmod |") or die "couldn't get loaded module list: $!"; 1.56 + `modprobe ndiswrapper` unless (/^ndiswrapper/); 1.57 +} 1.58 + 1.59 sub install { 1.60 my $inf = shift; 1.61 chomp($inf); 1.62 @@ -231,8 +263,11 @@ 1.63 parse_mfr(); 1.64 copy_file(basename($inf), basename($inf)); 1.65 create_fuzzy_conf($driver_name); 1.66 - print "Install done. " 1.67 - ."You may add ndiswrapper in LOAD_MODULES to launch your network driver at boot time.\n"; 1.68 + 1.69 + #Update LOAD_MODULES and load ndiswrapper. 1.70 + set_rcs_config(); 1.71 + load_ndiswrapper(); 1.72 + 1.73 1.74 return 0; 1.75 } 1.76 @@ -818,13 +853,12 @@ 1.77 1.78 sub list_drivers { 1.79 my $cards = get_cards(); 1.80 - 1.81 open(LS, "/bin/ls -1 $confdir|") or die "couldn't open $confdir: $!"; 1.82 while (my $driver = <LS>) { 1.83 - chomp($driver); 1.84 - if (-e "$confdir/$driver") { 1.85 - printf "%s : %s\n", $driver, install_status($cards, $driver); 1.86 - } 1.87 + chomp($driver); 1.88 + if (-e "$confdir/$driver") { 1.89 + printf "%s : %s\n", $driver, install_status($cards, $driver); 1.90 + } 1.91 } 1.92 close(LS); 1.93 return 0;