summaryrefslogtreecommitdiffstats
path: root/perl-install/network/modem.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2002-12-29 11:50:19 +0000
committerPascal Rigaux <pixel@mandriva.com>2002-12-29 11:50:19 +0000
commit838b9f0b8668a4c81c39c9ea9f777952f1b46a0a (patch)
tree6901501a44ee8e4e9fe03f106b3c7d2f8a7e40a4 /perl-install/network/modem.pm
parent4f39c8ec7dc57153ff67d77c8e497c5effa63770 (diff)
downloaddrakx-backup-do-not-use-838b9f0b8668a4c81c39c9ea9f777952f1b46a0a.tar
drakx-backup-do-not-use-838b9f0b8668a4c81c39c9ea9f777952f1b46a0a.tar.gz
drakx-backup-do-not-use-838b9f0b8668a4c81c39c9ea9f777952f1b46a0a.tar.bz2
drakx-backup-do-not-use-838b9f0b8668a4c81c39c9ea9f777952f1b46a0a.tar.xz
drakx-backup-do-not-use-838b9f0b8668a4c81c39c9ea9f777952f1b46a0a.zip
- move any::pppConfig() to network::modem::ppp_configure()
- move any::miscellaneousNetwork() to network::network::proxy_configure() (and uses the parameter instead of $::o->{miscellaneous}) - move network::network::miscellaneousNetwork() to network::network::miscellaneous_choose() (and do not export it) (and uses a parameter instead of $::o->{miscellaneous}) - move network::modem::pppConfig() to network::modem::ppp_choose() (and change parameter order, and drop unused parameter $intf) - do not export network::network::write_interface_conf() (since it is only used locally (?)) - cleanup network::network::write_interface_conf() (one still needs to pass $::o->{miscellaneous}{track_network_id} more cleanly, and use run_program::rooted when calling /sbin/ip)
Diffstat (limited to 'perl-install/network/modem.pm')
-rw-r--r--perl-install/network/modem.pm177
1 files changed, 169 insertions, 8 deletions
diff --git a/perl-install/network/modem.pm b/perl-install/network/modem.pm
index fd2f54c50..4a339565e 100644
--- a/perl-install/network/modem.pm
+++ b/perl-install/network/modem.pm
@@ -6,13 +6,9 @@ use modules;
use detect_devices;
use mouse;
use network::tools;
-use vars qw(@ISA @EXPORT);
use MDK::Common::Globals "network", qw($in $prefix);
use Data::Dumper;
-@ISA = qw(Exporter);
-@EXPORT = qw(pppConfig);
-
sub configure {
my ($netcnx, $mouse, $netc, $intf) = @_;
$netcnx->{type} = 'modem';
@@ -37,7 +33,7 @@ sub configure {
last;
}
}
- pppConfig($modem, $mouse, $netc, $intf) or return;
+ ppp_choose($netc, $modem, $mouse) or return;
write_cnx_script($netc, "modem",
q(
/sbin/route del default
@@ -49,8 +45,173 @@ killall pppd
1;
}
-sub pppConfig {
- my ($modem, $mouse, $netc, $_intf) = @_;
+#-----modem conf
+sub ppp_configure {
+ my ($in, $modem, $prefix) = @_;
+ $modem or return;
+
+ any::devfssymlinkf($modem, 'modem') if $modem->{device} ne "/dev/modem";
+ $in->do_pkgs->install('ppp') if !$::testing;
+
+ my %toreplace;
+ $toreplace{$_} = $modem->{$_} foreach qw(connection phone login passwd auth domain dns1 dns2);
+ $toreplace{kpppauth} = ${{ 'Script-based' => 0, 'PAP' => 1, 'Terminal-based' => 2, }}{$modem->{auth}};
+ $toreplace{kpppauth} = ${{ 'Script-based' => 0, 'PAP' => 1, 'Terminal-based' => 2, 'CHAP' => 3 }}{$modem->{auth}};
+ $toreplace{phone} =~ s/[a-zA-Z]//g;
+ $toreplace{dnsserver} = join ',', map { $modem->{$_} } "dns1", "dns2";
+ $toreplace{dnsserver} .= $toreplace{dnsserver} && ',';
+
+ #- using peerdns or dns1,dns2 avoid writing a /etc/resolv.conf file.
+ $toreplace{peerdns} = "yes";
+
+ $toreplace{connection} ||= 'DialupConnection';
+ $toreplace{domain} ||= 'localdomain';
+ $toreplace{intf} ||= 'ppp0';
+ $toreplace{papname} = ($modem->{auth} eq 'PAP' || $modem->{auth} eq 'CHAP') && $toreplace{login};
+
+ #- build ifcfg-ppp0.
+ my $various = <<END;
+DEVICE="$toreplace{intf}"
+ONBOOT="no"
+USERCTL="no"
+MODEMPORT="/dev/modem"
+LINESPEED="115200"
+PERSIST="yes"
+DEFABORT="yes"
+DEBUG="yes"
+INITSTRING="ATZ"
+DEFROUTE="yes"
+HARDFLOWCTL="yes"
+ESCAPECHARS="no"
+PPPOPTIONS=""
+PAPNAME="$toreplace{papname}"
+REMIP=""
+NETMASK=""
+IPADDR=""
+MRU=""
+MTU=""
+DISCONNECTTIMEOUT="5"
+RETRYTIMEOUT="60"
+BOOTPROTO="none"
+PEERDNS="$toreplace{peerdns}"
+END
+ output("$prefix/etc/sysconfig/network-scripts/ifcfg-ppp0",
+ $various,
+ map { qq(DNS$_=$toreplace{"dns$_"}\n) } grep { $toreplace{"dns$_"} } 1..2);
+
+ #- build chat-ppp0.
+ my @chat = <<END;
+'ABORT' 'BUSY'
+'ABORT' 'ERROR'
+'ABORT' 'NO CARRIER'
+'ABORT' 'NO DIALTONE'
+'ABORT' 'Invalid Login'
+'ABORT' 'Login incorrect'
+'' 'ATZ'
+END
+ if ($modem->{special_command}) {
+ push @chat, <<END;
+'OK' '$modem->{special_command}'
+END
+ }
+ push @chat, <<END;
+'OK' 'ATDT$toreplace{phone}'
+'CONNECT' ''
+END
+ if ($modem->{auth} eq 'Terminal-based' || $modem->{auth} eq 'Script-based') {
+ push @chat, <<END;
+'ogin:--ogin:' '$toreplace{login}'
+'ord:' '$toreplace{passwd}'
+END
+ }
+ push @chat, <<END;
+'TIMEOUT' '5'
+'~--' ''
+END
+ my $chat_file = "$prefix/etc/sysconfig/network-scripts/chat-ppp0";
+ output_with_perm($chat_file, 0600, @chat);
+
+ if ($modem->{auth} eq 'PAP' || $modem->{auth} eq 'CHAP') {
+ #- need to create a secrets file for the connection.
+ my $secrets = "$prefix/etc/ppp/" . lc($modem->{auth}) . "-secrets";
+ my @l = cat_($secrets);
+ my $replaced = 0;
+ do { $replaced ||= 1
+ if s/^\s*"?$toreplace{login}"?\s+ppp0\s+(\S+)/"$toreplace{login}" ppp0 "$toreplace{passwd}"/ } foreach @l;
+ if ($replaced) {
+ output($secrets, @l);
+ } else {
+ append_to_file($secrets, "$toreplace{login} ppp0 \"$toreplace{passwd}\"\n");
+ }
+ #- restore access right to secrets file, just in case.
+ chmod 0600, $secrets;
+ }
+
+ #- install kppprc file according to used configuration.
+ mkdir_p("$prefix/usr/share/config");
+
+ output("$prefix/usr/share/config/kppprc", c::to_utf8(<<END));
+# KDE Config File
+[Account0]
+ExDNSDisabled=0
+AutoName=0
+ScriptArguments=
+AccountingEnabled=0
+DialString=ATDT
+Phonenumber=$toreplace{phone}
+IPAddr=0.0.0.0
+Domain=$toreplace{domain}
+Name=$toreplace{connection}
+VolumeAccountingEnabled=0
+pppdArguments=
+Password=$toreplace{passwd}
+BeforeDisconnect=
+Command=
+ScriptCommands=
+Authentication=$toreplace{kpppauth}
+DNS=$toreplace{dnsserver}
+SubnetMask=0.0.0.0
+AccountingFile=
+DefaultRoute=1
+Username=$toreplace{login}
+Gateway=0.0.0.0
+StorePassword=1
+DisconnectCommand=
+[Modem]
+BusyWait=0
+Enter=CR
+FlowControl=CRTSCTS
+Volume=0
+Timeout=60
+UseCDLine=0
+UseLockFile=1
+Device=/dev/modem
+Speed=115200
+[Graph]
+InBytes=0,0,255
+Text=0,0,0
+Background=255,255,255
+Enabled=true
+OutBytes=255,0,0
+[General]
+QuitOnDisconnect=0
+ShowLogWindow=0
+DisconnectOnXServerExit=1
+DefaultAccount=$toreplace{connection}
+iconifyOnConnect=1
+Hint_QuickHelp=0
+AutomaticRedial=0
+PPPDebug=0
+NumberOfAccounts=1
+ShowClock=1
+DockIntoPanel=0
+pppdTimeout=30
+END
+ network::network::proxy_configure($::o->{miscellaneous});
+}
+
+sub ppp_choose {
+ my ($netc, $modem, $mouse) = @_;
$mouse ||= {};
$mouse->{device} ||= readlink "$prefix/dev/mouse";
@@ -76,7 +237,7 @@ sub pppConfig {
{ label => N("Second DNS Server (optional)"), val => \$modem->{dns2} },
]) or return;
$netc->{DOMAINNAME2} = $modem->{domain};
- any::pppConfig($in, $modem, $prefix);
+ ppp_configure($in, $modem, $prefix);
$netc->{$_} = 'ppp0' foreach 'NET_DEVICE', 'NET_INTERFACE';
1;
}