summaryrefslogtreecommitdiffstats
path: root/perl-install/network/modem.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/network/modem.pm')
-rw-r--r--perl-install/network/modem.pm36
1 files changed, 32 insertions, 4 deletions
diff --git a/perl-install/network/modem.pm b/perl-install/network/modem.pm
index e790cf83c..18755d0cb 100644
--- a/perl-install/network/modem.pm
+++ b/perl-install/network/modem.pm
@@ -10,16 +10,30 @@ use network::tools;
sub first_modem {
my ($netc) = @_;
+ return "/mnt/root" if $::isInstall;
first(grep { $_->{device} =~ m!^/dev! } values %{$netc->{autodetect}{modem}});
}
+sub get_user_home() {
+ my $home;
+ if ($ENV{USER} ne "root") {
+ #- kdesu case
+ $home = (find { $_->[0] eq $ENV{USER} } list_passwd())->[7];
+ }
+ $home ||= $ENV{HOME}; #- consolehelper case
+ $home;
+}
sub ppp_read_conf {
my ($netcnx, $netc) = @_;
my $modem = $netcnx->{$netcnx->{type}} ||= {};
- $modem->{device} ||= first_modem($netc)->{device};
- my %l = getVarsFromSh("$::prefix/usr/share/config/kppprc");
- $l{Authentication} = 4 if !exists $l{Authentication};
+ if (my $detected_modem = first_modem($netc)) {
+ $modem->{device} ||= $detected_modem->{device};
+ }
+ $modem->{device} ||= '/dev/modem';
+ my %l = getVarsFromSh(get_user_home() . "/.kde/share/config/kppprc");
+ add2hash(\%l, getVarsFromSh("$::prefix/usr/share/config/kppprc"));
+ $l{Authentication} = 4 if $l{Authentication} !~ /\d/;
$modem->{$_} ||= $l{$_} foreach qw(Authentication Gateway IPAddr SubnetMask);
$modem->{connection} ||= $l{Name};
$modem->{domain} ||= $l{Domain};
@@ -30,6 +44,7 @@ sub ppp_read_conf {
}
foreach (cat_("/etc/sysconfig/network-scripts/ifcfg-ppp0")) {
/NAME=(['"]?)(.*)\1/ and $modem->{login} ||= $2;
+ /^METRIC=(.*)/ and $modem->{METRIC} = $1;
}
$modem->{login} ||= $l{Username};
my $secret = network::tools::read_secret_backend();
@@ -42,6 +57,8 @@ sub ppp_read_conf {
$modem->{auto_gateway} ||= defined $modem->{Gateway} && $modem->{Gateway} ne '0.0.0.0' ? N("Manual") : N("Automatic");
$modem->{auto_ip} ||= defined $modem->{IPAddr} && $modem->{IPAddr} ne '0.0.0.0' ? N("Manual") : N("Automatic");
$modem->{auto_dns} ||= $modem->{dns1} || $modem->{dns2} ? N("Manual") : N("Automatic");
+
+ $modem;
}
#-----modem conf
@@ -51,7 +68,16 @@ sub ppp_configure {
$in->do_pkgs->install('ppp') if !$::testing;
$in->do_pkgs->install('kdenetwork-kppp') if !$::testing && $in->do_pkgs->is_installed('kdebase');
- any::devfssymlinkf($modem, 'modem') if $modem->{device} ne "/dev/modem";
+ if ($modem->{device} ne "/dev/modem") {
+ my $dev = $modem->{device};
+ $dev =~ s!^/dev/!!;
+ any::devfssymlinkf({ device => $dev }, 'modem');
+ #- add a specific udev script in addition to the udev rules file
+ #- (ttySL0 is a symlink, udev won't be called when it's created)
+ my $udev_conf = "$::prefix/etc/udev/conf.d/modem.conf";
+ output_p($udev_conf, "ln -sf $dev /dev/modem\n");
+ chmod 0755, $udev_conf;
+ }
my %toreplace = map { $_ => $modem->{$_} } qw(Authentication AutoName connection dns1 dns2 domain IPAddr login passwd phone SubnetMask);
$toreplace{phone} =~ s/[a-zA-Z]//g;
@@ -76,6 +102,7 @@ sub ppp_configure {
}
$toreplace{Gateway} = $modem->{auto_gateway} eq N("Automatic") ? '0.0.0.0' : $modem->{Gateway};
+ $toreplace{METRIC} = defined($modem->{METRIC}) ? $modem->{METRIC} : network::tools::get_default_metric("modem");
#- build ifcfg-ppp0.
my $various = <<END;
@@ -102,6 +129,7 @@ DISCONNECTTIMEOUT="5"
RETRYTIMEOUT="60"
BOOTPROTO="none"
PEERDNS="$toreplace{peerdns}"
+METRIC=$toreplace{METRIC}
END
output("$::prefix/etc/sysconfig/network-scripts/ifcfg-ppp0",
$various,