summaryrefslogtreecommitdiffstats
path: root/perl-install/any.pm
diff options
context:
space:
mode:
authordamien <damien@mandriva.com>2000-08-29 17:06:05 +0000
committerdamien <damien@mandriva.com>2000-08-29 17:06:05 +0000
commit3161708c83a46d247c81b7681fd6a64f3c4a1310 (patch)
tree7240b96b265f51d3c93ca60fbe4d94214d13d162 /perl-install/any.pm
parentf2ef37015a716cf8feeb66f6e7505915ce30a27a (diff)
downloaddrakx-3161708c83a46d247c81b7681fd6a64f3c4a1310.tar
drakx-3161708c83a46d247c81b7681fd6a64f3c4a1310.tar.gz
drakx-3161708c83a46d247c81b7681fd6a64f3c4a1310.tar.bz2
drakx-3161708c83a46d247c81b7681fd6a64f3c4a1310.tar.xz
drakx-3161708c83a46d247c81b7681fd6a64f3c4a1310.zip
see changelog.
Diffstat (limited to 'perl-install/any.pm')
-rw-r--r--perl-install/any.pm119
1 files changed, 119 insertions, 0 deletions
diff --git a/perl-install/any.pm b/perl-install/any.pm
index 7be45a54b..60bec7159 100644
--- a/perl-install/any.pm
+++ b/perl-install/any.pm
@@ -281,5 +281,124 @@ sub inspect {
$h;
}
+#-----modem conf
+sub pppConfig {
+ my ($o) = @_;
+ $o->{modem} or return;
+
+ symlinkf($o->{modem}{device}, "$o->{prefix}/dev/modem") or log::l("creation of $o->{prefix}/dev/modem failed");
+ $::isStandalone ? `urpmi --auto ppp` : $o->pkg_install("ppp") unless $::testing;
+
+ my %toreplace;
+ $toreplace{$_} = $o->{modem}{$_} foreach qw(connection phone login passwd auth domain dns1 dns2);
+ $toreplace{kpppauth} = ${{ 'Script-based' => 0, 'PAP' => 1, 'Terminal-based' => 2, 'CHAP' => 3, }}{$o->{modem}{auth}};
+ $toreplace{phone} =~ s/\D//g;
+ $toreplace{dnsserver} = join ',', map { $o->{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} = $o->{modem}{auth} eq 'PAP' && $toreplace{login};
+
+ #- build ifcfg-ppp0.
+ my $ifcfg = "$o->{prefix}/etc/sysconfig/network-scripts/ifcfg-ppp0";
+ local *IFCFG; open IFCFG, ">$ifcfg" or die "Can't open $ifcfg";
+ print IFCFG <<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
+ foreach (1..2) {
+ if ($toreplace{"dns$_"}) {
+ print IFCFG <<END;
+DNS$_=$toreplace{"dns$_"}
+END
+ }
+ }
+ close IFCFG;
+
+ #- build chat-ppp0.
+ my $chat = "$o->{prefix}/etc/sysconfig/network-scripts/chat-ppp0";
+ local *CHAT; open CHAT, ">$chat" or die "Can't open $chat";
+ print CHAT <<END;
+'ABORT' 'BUSY'
+'ABORT' 'ERROR'
+'ABORT' 'NO CARRIER'
+'ABORT' 'NO DIALTONE'
+'ABORT' 'Invalid Login'
+'ABORT' 'Login incorrect'
+'' 'ATZ'
+'OK' 'ATDT$toreplace{phone}'
+'CONNECT' ''
+END
+ if ($o->{modem}{auth} eq 'Terminal-based' || $o->{modem}{auth} eq 'Script-based') {
+ print CHAT <<END;
+'ogin:' '$toreplace{login}'
+'ord:' '$toreplace{passwd}'
+END
+ }
+ print CHAT <<END;
+'TIMEOUT' '5'
+'~--' ''
+END
+ close CHAT;
+
+ if ($o->{modem}{auth} eq 'PAP') {
+ #- need to create a secrets file for the connection.
+ my $secrets = "$o->{prefix}/etc/ppp/" . lc($o->{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) {
+ local *F;
+ open F, ">$secrets" or die "Can't open $secrets: $!";
+ print F @l;
+ } else {
+ local *F;
+ open F, ">>$secrets" or die "Can't open $secrets: $!";
+ print F "$toreplace{login} ppp0 \"$toreplace{passwd}\"\n";
+ }
+ #- restore access right to secrets file, just in case.
+ chmod 0600, $secrets;
+ } #- CHAP is not supported by initscripts, need patching before doing more on that here!
+
+ #-install_any::template2userfile($o->{prefix}, "$ENV{SHARE_PATH}/kppprc.in", ".kde/share/config/kppprc", 1, %toreplace);
+ commands::mkdir_("-p", "$o->{prefix}/usr/share/config");
+ template2file("$ENV{SHARE_PATH}/kppprc.in", "$o->{prefix}/usr/share/config/kppprc", %toreplace);
+
+ miscellaneousNetwork($o);
+}
+
+sub miscellaneousNetwork {
+ my ($o) = @_;
+ setVarsInSh ("$o->{prefix}/etc/profile.d/proxy.sh", $o->{miscellaneous}, qw(http_proxy ftp_proxy));
+ setVarsInCsh("$o->{prefix}/etc/profile.d/proxy.csh", $o->{miscellaneous}, qw(http_proxy ftp_proxy));
+}
+
1;