]> git.ipfire.org Git - people/ms/ipfire-2.x.git/commitdiff
network-functions.pl: Read PPP settings globally
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 23 Mar 2024 15:51:27 +0000 (16:51 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 27 Apr 2024 17:35:36 +0000 (19:35 +0200)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
config/cfgroot/header.pl
config/cfgroot/network-functions.pl

index ca4484756e96f5d84099e3e023c2410b8b5bd337..68c3cb8387f25a1eace4a9e34df81dade58651fe 100644 (file)
@@ -88,7 +88,6 @@ END
 my %menuhash = ();
 my $menu = \%menuhash;
 %settings = ();
-%pppsettings = ();
 my @URI = split('\?', $ENV{'REQUEST_URI'});
 
 ### Make sure this is an SSL request
@@ -100,7 +99,6 @@ if ($ENV{'SERVER_ADDR'} && $ENV{'HTTPS'} ne 'on') {
 
 ### Initialize environment
 &General::readhash("${swroot}/main/settings", \%settings);
-&General::readhash("${swroot}/ppp/settings", \%pppsettings);
 $hostname = $settings{'HOSTNAME'};
 $hostnameintitle = 0;
 
@@ -438,7 +436,7 @@ sub genmenu {
         $menu->{'01.system'}{'subMenu'}->{'21.wlan'}{'enabled'} = 1;
     }
 
-    if ( $Network::ethernet{'RED_TYPE'} eq "PPPOE" && $pppsettings{'MONPORT'} ne "" ) {
+    if ( $Network::ethernet{'RED_TYPE'} eq "PPPOE" && $Network::ppp{'MONPORT'} ne "" ) {
         $menu->{'02.status'}{'subMenu'}->{'74.modem-status'}{'enabled'} = 1;
     }
 
@@ -610,15 +608,11 @@ sub cleanhtml {
 
 sub connectionstatus
 {
-    my %pppsettings = ();
     my $iface='';
 
-    $pppsettings{'PROFILENAME'} = 'None';
-    &General::readhash("${General::swroot}/ppp/settings", \%pppsettings);
-
     my $profileused='';
     unless ($Network::ethernet{'RED_TYPE'} =~ /^(DHCP|STATIC)$/) {
-       $profileused="- $pppsettings{'PROFILENAME'}";
+               $profileused="- $Network::ppp{'PROFILENAME'}";
     }
 
     my ($timestr, $connstate);
@@ -629,9 +623,9 @@ sub connectionstatus
                        $timestr = &General::age("${General::swroot}/red/active");
                        $connstate = "<span>$Lang::tr{'connected'} - (<span>$timestr</span>) $profileused</span>";
                } else {
-                 if ((open(KEEPCONNECTED, "</var/ipfire/red/keepconnected") == false) && ($pppsettings{'RECONNECTION'} eq "persistent")) {
+                 if ((open(KEEPCONNECTED, "</var/ipfire/red/keepconnected") == false) && ($Network::ppp{'RECONNECTION'} eq "persistent")) {
                                $connstate = "<span>$Lang::tr{'connection closed'} $profileused</span>";
-      } elsif (($pppsettings{'RECONNECTION'} eq "dialondemand") && ( -e "${General::swroot}/red/dial-on-demand")) {
+      } elsif (($Network::ppp{'RECONNECTION'} eq "dialondemand") && ( -e "${General::swroot}/red/dial-on-demand")) {
                                $connstate = "<span>$Lang::tr{'dod waiting'} $profileused</span>";
                        } else {
                                $connstate = "<span>$Lang::tr{'connecting'} $profileused</span>" if (system("ps -ef | grep -q '[p]ppd'"));
index 221239e5c963651af8d3b2190f14f6a13353ec4b..5b35114aa0a40728cee255a9b5840e820a2000de 100644 (file)
@@ -28,10 +28,12 @@ require "/var/ipfire/general-functions.pl";
 use experimental 'smartmatch';
 use Socket;
 
-# System ethernet configuration
 our %ethernet = ();
+our %ppp = ();
 
+# Read configuration files
 &General::readhash("${General::swroot}/ethernet/settings", \%ethernet);
+&General::readhash("${General::swroot}/ppp/settings", \%ppp);
 
 # List of all possible network zones that can be configured
 our @known_network_zones = ("red", "green", "orange", "blue");