Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Firebox LCD Driver for LCDProc

    Scheduled Pinned Locked Moved Hardware
    398 Posts 97 Posters 467.7k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • G
      g.jauch
      last edited by

      @stephenw10:

      Interestingly using the Shellcmd package to start the client and server outside of the package system the commands only get run once. It might be worth looking at how shellcmd is arranged to run only once.

      shellcmd add entries to /cf/conf/config.xml and does not use /usr/local/etc/rc.d/

      cu gunther

      1 Reply Last reply Reply Quote 0
      • stephenw10S
        stephenw10 Netgate Administrator
        last edited by

        Ah, yes of course.

        Steve

        1 Reply Last reply Reply Quote 0
        • G
          g.jauch
          last edited by

          Here's a new way to avoid the "restarts", multi-runs of /usr/local/etc/rc.d files at startup!

          At least the way I did it ;)

          Apr 20 21:05:23 pfSense php: rc.newwanip: pfSense package system has detected an ip change 192.168.178.45 ->  192.168.178.45 ... Restarting packages.
          

          Strange… why is the restart triggered ??? there is no change in my WAN IP address at all !

          So I looked inside the /etc/rc.newwanip script to see whats going on:

          if (!is_ipaddr($oldip) || $curwanip != $oldip || !is_ipaddrv4($config['interfaces'][$interface]['ipaddr']))
          

          If any of these 3 conditions are true then the restart_packages() gets triggered.

          The first 2 conditions are fine… it's the 3rd who triggers

          !is_ipaddrv4($config['interfaces'][$interface]['ipaddr'])
          

          If WAN configuration is set to DHCP then

          $config['interfaces'][$interface]['ipaddr']
          

          $config is set to dhcp, and so the is_ipaddrv4("dhcp") returns false, because dhcp is clearly not an IPV4 address.

          Till pfSense 2.0.3 this if-condition contained the first 2 conditions only!

          So finally I looked inside the /etc/inc/util.inc which contains the implementation of this is_ipaddrv4() function

          and added this code inside the function:

          if ( $ipaddr == "dhcp" )
          	return true;
          
          

          Now everything works fine… and you can leave the /usr/local/etc/rc.d/lcdproc.sh script as it is.

          cu Gunther

          1 Reply Last reply Reply Quote 0
          • A
            ArkAngel
            last edited by

            Hello,

            Thanks for doing all this debugging on the LCDproc-related problems (and globally all you did on the firebox-pfsense project). Your work is much appreciated!

            So finally I looked inside the /etc/inc/util.inc which contains the implementation of this is_ipaddrv4() function

            and added this code inside the function:

            Code: [Select]

            if ( $ipaddr == "dhcp" )
            return true;

            Now everything works fine… and you can leave the /usr/local/etc/rc.d/lcdproc.sh script as it is.

            Tried implementing this as you said, inside the is_ipaddrv4() function, but I don't know what I'm doing wrong, when I rebooted the firewall apinger was shown as not running and this is what I had in the logfiles:

            Apr 21 08:36:03 apinger: Starting Alarm Pinger, apinger(19845) 
            Apr 21 08:36:03 apinger: No usable targets found, exiting 
            
            

            Here's what the function looks like:

            /* returns true if $ipaddr is a valid dotted IPv4 address */
            function is_ipaddrv4($ipaddr) {
            	if ($ipaddr == "dhcp")
            		return true;
            
            	if (!is_string($ipaddr) || empty($ipaddr))
            		return false;
            
            	$ip_long = ip2long($ipaddr);
            	$ip_reverse = long2ip32($ip_long);
            
            	if ($ipaddr == $ip_reverse)
            		return true;
            	else
            		return false;
            }
            
            

            What I am doing wrong? If I remove the added lines and reboot, everything is back to normal.

            Thanks!

            ArkAngel

            1 Reply Last reply Reply Quote 0
            • stephenw10S
              stephenw10 Netgate Administrator
              last edited by

              Hmm, this is tricky to my head around. More coffee perhaps! (more likely less  :P)

              It seems odd that this check is for a valid IP address in the config. If it always failed on dhcp (and presumably, pppoe or any thing other than static) why does it eventually stop renewing the interfaces?
              Simply adding that line seems dangerous, though I have no actual code to point to to back that up.

              Steve

              1 Reply Last reply Reply Quote 0
              • G
                g.jauch
                last edited by

                @ArkAngel:

                What I am doing wrong? If I remove the added lines and reboot, everything is back to normal.

                Thanks!

                ArkAngel

                Please answer me 2 questions:
                1. What is the "Alarm Pinger"… is it a addon package ?
                2. What version of LCDProc-Dev & pfSense do you use ?

                I'll have a deeper look into it... tommorow ;)

                @stephenw10:

                Hmm, this is tricky to my head around. More coffee perhaps! (more likely less  :P)

                It seems odd that this check is for a valid IP address in the config. If it always failed on dhcp (and presumably, pppoe or any thing other than static) why does it eventually stop renewing the interfaces?

                • That is indeed a good question… why is this not turning into an endless loop ?
                • I'll also take a look what pfSense 2.0.3 carries in the "$config['interfaces'][$interface]['ipaddr']" Array, I'm pretty sure it's the real IP address that you receive from your DHCP server instead of the word "dhcp".

                I asume that after the restart… pfSense versions > 2.0.3 return also the real IP inside that "$config array"... otherwise you would get that mentioned "endless loop" !

                @stephenw10:

                Simply adding that line seems dangerous, though I have no actual code to point to to back that up.

                yes it is !

                Another approch could be to touch a file if "pfsense" does that restart and check inside the scripts under /usr/local/etc/rc.d/ if that file is there and if so simply exit and do nothing!

                cu gunther

                1 Reply Last reply Reply Quote 0
                • A
                  ArkAngel
                  last edited by

                  Please answer me 2 questions:
                  1. What is the "Alarm Pinger"… is it a addon package ?
                  2. What version of LCDProc-Dev & pfSense do you use ?

                  I'll have a deeper look into it... tommorow ;)

                  1. Sorry I didn't noticed where this apinger came from. It is described as "Gateway Monitoring Daemon". The only packages I run is LCDProc-Dev and phpSysInfo.
                  2. LCDProc-Dev-0.5.6 pkg v. 0.9.7 (lightly modded, as per what I've found in the forum), pfSense 2.1.2-RELEASE (i386)

                  Fresh installation from a few days ago.

                  Thanks
                  ArkAngel

                  1 Reply Last reply Reply Quote 0
                  • G
                    g.jauch
                    last edited by

                    Hi,

                    1.st I should not post nore asume anything on a late evening !
                    2.nd I should read my previous postings again !

                    @ArkAngel:

                    Please answer me 2 questions:
                    1. What is the "Alarm Pinger"… is it a addon package ?
                    2. What version of LCDProc-Dev & pfSense do you use ?

                    I'll have a deeper look into it... tommorow ;)

                    1. Sorry I didn't noticed where this apinger came from. It is described as "Gateway Monitoring Daemon". The only packages I run is LCDProc-Dev and phpSysInfo.
                    2. LCDProc-Dev-0.5.6 pkg v. 0.9.7 (lightly modded, as per what I've found in the forum), pfSense 2.1.2-RELEASE (i386)

                    Fresh installation from a few days ago.

                    Thanks
                    ArkAngel

                    1. Ok, thanks for the info… I'm pretty new to pfSense!
                    2. that is the same setup I have

                    OK… here I go again!

                    @g.jauch:

                    Till pfSense 2.0.3 this if-condition contained the first 2 conditions only!

                    So finally I looked inside the /etc/inc/util.inc which contains the implementation of this is_ipaddrv4() function

                    and added this code inside the function:

                    if ( $ipaddr == "dhcp" )
                    	return true;
                    
                    

                    That was not the best idea… especially if you read the first sentence again!
                    stephenw10 also replied "It seems odd that this check is for a valid IP address in the config".
                    This check for a valid IPV4 address should be inside the function that is called after you hit the SAVE-Button inside the webconfigurator!

                    So leaf the /etc/inc/util.inc untouched… and instead of this if-statement inside the /etc/rc.newwanip

                    if (!is_ipaddr($oldip) || $curwanip != $oldip || !is_ipaddrv4($config['interfaces'][$interface]['ipaddr']))
                    

                    get rid of the 3.rd / is_ipaddrv4 condition and try this:

                    if (!is_ipaddr($oldip) || $curwanip != $oldip )
                    

                    That should be a better/saver solution, with less side-effects !

                    If your Alarm Pinger still won't work with that new code… then probably there is something wrong/incompatible with your mentioned other "slightly mods".

                    I'll take a deeper look into the rest this afternoon:

                    cu gunther

                    1 Reply Last reply Reply Quote 0
                    • G
                      g.jauch
                      last edited by

                      I think the coder of this function made a mistake inside the /etc/rc.newwanip

                      if (!is_ipaddr($oldip) || $curwanip != $oldip || !is_ipaddrv4($config['interfaces'][$interface]['ipaddr']))
                      

                      Probably he wanted to check the $curwanip to be IPV4 conform ( that make more sense ).
                      So right now I use this code, everthing else untouched, all is fine the LCD "is working" after the startup and there shouldn't be any harmful side-effects if you use this code!

                      if (!is_ipaddr($oldip) || $curwanip != $oldip || !is_ipaddrv4($curwanip)
                      

                      The script & the whole process itself is fine with the WAN settings! pfSense get all necessary informations from the DHCP and configures the WAN interface.

                      Apr 22 17:23:26 	php: rc.newwanip: rc.newwanip: Informational is starting sk0.
                      Apr 22 17:23:26 	php: rc.newwanip: rc.newwanip: on (IP address: 192.168.178.45) (interface: wan) (real interface: sk0).
                      Apr 22 17:23:26 	php: rc.newwanip: ,,1,dhcp, // thats my debug output of the if() false, false, true !
                      Apr 22 17:23:27 	php: rc.newwanip: ROUTING: setting default route to 192.168.178.1
                      Apr 22 17:23:28 	php: rc.bootup: ROUTING: setting default route to 192.168.178.1
                      Apr 22 17:23:29 	check_reload_status: Updating all dyndns
                      Apr 22 17:23:32 	php: rc.newwanip: Resyncing OpenVPN instances for interface WAN.
                      Apr 22 17:23:32 	php: rc.newwanip: Creating rrd update script
                      Apr 22 17:23:33 	php: rc.bootup: Creating rrd update script
                      Apr 22 17:23:33 	syslogd: exiting on signal 15
                      Apr 22 17:23:33 	syslogd: kernel boot file is /boot/kernel/kernel
                      
                      Apr 22 17:23:34 	php: rc.start_packages: Restarting/Starting all packages.
                      Apr 22 17:23:34 	php: rc.newwanip: pfSense package system has detected an ip change 192.168.178.45 -> 192.168.178.45 ... Restarting packages.
                      

                      Everything else inside the rc.newwanip script is fine so pfSense continues to start up… but because of the "dhcp" string the restart is triggered once! But it shouldn't do that... because everything is fine!

                      cu Gunther

                      1 Reply Last reply Reply Quote 0
                      • A
                        ArkAngel
                        last edited by

                        @g.jauch:

                        I think the coder of this function made a mistake inside the rc.newwanip

                        if (!is_ipaddr($oldip) || $curwanip != $oldip || !is_ipaddrv4($config['interfaces'][$interface]['ipaddr']))
                        

                        Probably he wanted to check the $curwanip to be IPV4 conform ( that make more sense ).
                        So right now I use this code, everthing else untouched, all is fine and there shouldn't be any harmful side-effects!

                        if (!is_ipaddr($oldip) || $curwanip != $oldip || !is_ipaddrv4($curwanip)
                        

                        The script & the whole process itself is fine with the WAN settings! pfSense get all necessary informations from the DHCP and configures the WAN interface.

                        Works fine for me! apinger is happily working and LCDProc-Dev seems to automatically work at startup, instead of having to restart it after each reboot!

                        Thanks a lot!

                        ArkAngel

                        1 Reply Last reply Reply Quote 0
                        • G
                          g.jauch
                          last edited by

                          @ArkAngel:

                          Works fine for me! apinger is happily working and LCDProc-Dev seems to automatically work at startup, instead of having to restart it after each reboot!

                          Thanks a lot!

                          ArkAngel

                          No problem… it's obvious that something is wrong in the code so I'm pretty sure that this "glitch" will be fixed in future pfSense versions.

                          LCDProc-Dev seems to be worst affected by the double start of all scripts under /usr/local/etc/rc.d

                          cu gunther

                          1 Reply Last reply Reply Quote 0
                          • stephenw10S
                            stephenw10 Netgate Administrator
                            last edited by

                            Interesting I'll have to give this a shot. I still expect the php client to be killed eventaually when it hits the time limit on php processes. That could be worked around by using the Service Watchdog package to monitor it.

                            Really there are many packages that have no need to be restarted due to an IP change. It seems to me there should be a configuration option to choose if your package is restarted or not. Obviously something for the devs.

                            Steve

                            1 Reply Last reply Reply Quote 0
                            • P
                              phil.davis
                              last edited by

                              Really there are many packages that have no need to be restarted due to an IP change. It seems to me there should be a configuration option to choose if your package is restarted or not. Obviously something for the devs.

                              Redmine issue raised: https://redmine.pfsense.org/issues/3623
                              Please read and comment there.
                              I have thought about this in the past also. In my first thoughts, it seems easiest to just pass an extra parameter in addition to "restart", to indicate the restart type/reason. Then each package can be modified to react differently to the parameter if it cares. All the existing packages that need to restart all the time anyway will not need any modification ("a good thing").

                              As the Greek philosopher Isosceles used to say, "There are 3 sides to every triangle."
                              If I helped you, then help someone else - buy someone a gift from the INF catalog http://secure.inf.org/gifts/usd/

                              1 Reply Last reply Reply Quote 0
                              • G
                                g.jauch
                                last edited by

                                Of course it is always better if pfSense itself would inform the scripts under /usr/local/etc/rc.d for what reason they are called instead of the following "workaround".

                                Hi,

                                a simple approach to notice if a restart of packages occured could be realized like so:

                                1. The restart itself is initiated via a function inside /etc/inc/util.inc called send_event(). This function open a socket to a daemon and send "commands" to him.
                                In our case the command "service reload packages"

                                2. We can intercept/modify this send_event() function to see if a successfull restart of the packages has been triggered and touch an "event file" to indicate this.

                                3. Now we can check at the beginning of the scripts under /usr/local/etc/rc.d if the "event file" exists and act to it if needed.

                                4. At the end we need a "delete script" under /usr/local/etc/rc.d that runs after all other scripts and deletes our "event file" to reset our mechanism back to null

                                Let's start:

                                That is the original send_event() function of pfSense 2.1.2

                                function send_event($cmd) {
                                	global $g;
                                
                                	if(!isset($g['event_address']))
                                		$g['event_address'] = "unix:///var/run/check_reload_status";
                                
                                	$try = 0;
                                	while ($try < 3) {
                                		$fd = @fsockopen($g['event_address']);
                                		if ($fd) {
                                			fwrite($fd, $cmd);
                                			$resp = fread($fd, 4096);
                                			if ($resp != "OK\n")
                                				log_error("send_event: sent {$cmd} got {$resp}");
                                			fclose($fd);
                                			$try = 3;
                                		} else if (!is_process_running("check_reload_status"))
                                			mwexec_bg("/usr/bin/nice -n20 /usr/local/sbin/check_reload_status");
                                		$try++;
                                	}
                                }
                                
                                

                                here is the modified on:

                                function send_event($cmd) {
                                	global $g;
                                
                                	if(!isset($g['event_address']))
                                		$g['event_address'] = "unix:///var/run/check_reload_status";
                                
                                	$try = 0;
                                	while ($try < 3) {
                                		$fd = @fsockopen($g['event_address']);
                                		if ($fd) {
                                			fwrite($fd, $cmd);
                                			$resp = fread($fd, 4096);
                                			if ($resp != "OK\n")
                                			{
                                				log_error("send_event: sent {$cmd} got {$resp}");
                                			}
                                			else
                                			{
                                				if ( $cmd == "service reload packages" )
                                					mwexec_bg("/usr/bin/touch /tmp/service_reload_packages_running.txt");
                                			}
                                			fclose($fd);
                                			$try = 3;
                                		} else if (!is_process_running("check_reload_status"))
                                			mwexec_bg("/usr/bin/nice -n20 /usr/local/sbin/check_reload_status");
                                		$try++;
                                	}
                                }
                                
                                

                                The modification in detail:

                                
                                if ($resp != "OK\n")
                                {
                                	log_error("send_event: sent {$cmd} got {$resp}");
                                }
                                else
                                {
                                	if ( $cmd == "service reload packages" )
                                	mwexec_bg("/usr/bin/touch /tmp/service_reload_packages_running.txt");
                                }
                                

                                If the response from the daemon was "OK" ( that means that the transmitted command was successfully executed ) we check if that command was "service reload packages" and touch an "event file" under /tmp called service_reload_packages_running.txt

                                At the beginning of the scripts under /usr/local/etc/rc.d we can now simply check if this "event file" exist and exit/ignore the restart

                                if [ -f /tmp/service_reload_packages_running.txt ];then
                                    exit
                                fi
                                

                                Our delete script simply deletes the "event file"

                                if [ -f /tmp/service_reload_packages_running.txt ];then
                                    rm /tmp/service_reload_packages_running.txt
                                fi
                                

                                We call it zzz_delete.sh to make sure it's called at the end/lastly and put it under /usr/local/etc/rc.d

                                cu gunther

                                1 Reply Last reply Reply Quote 0
                                • stephenw10S
                                  stephenw10 Netgate Administrator
                                  last edited by

                                  Looks rational.
                                  It's somewhat outside the scope of this thread though.  ;)  I suggest you add your thoughts to Phil's feature request on Redmine. That way it will get some eyes-on from the dev team.

                                  Steve

                                  1 Reply Last reply Reply Quote 0
                                  • stephenw10S
                                    stephenw10 Netgate Administrator
                                    last edited by

                                    In case any of you are still looking at this. CMB recently found a bug in rc.renewwanip which seems relevant:
                                    https://forum.pfsense.org/index.php?topic=76735.msg421118#msg421118

                                    Steve

                                    1 Reply Last reply Reply Quote 0
                                    • C
                                      Cino
                                      last edited by

                                      i will have to try this… anytime apinger kicked in that an interface was down for a second, i would have to restart LCD-Proc manually

                                      1 Reply Last reply Reply Quote 0
                                      • T
                                        TieT
                                        last edited by

                                        LCDProc isn't working on pFsense 2.2

                                        1 Reply Last reply Reply Quote 0
                                        • stephenw10S
                                          stephenw10 Netgate Administrator
                                          last edited by

                                          Yeah there's a bug in the PBI for LCDproc-dev that makes it fail to find the conf file. It works fine if you use almost anything but the default meathod to start it.  ::) Altrernatively you can copy the LCDd.conf file from /usr/local/etc and put it in /usr/pbi/lcdproc-i386/local/etc and it will work. See:
                                          https://forum.pfsense.org/index.php?topic=83747.0

                                          Steve

                                          1 Reply Last reply Reply Quote 0
                                          • U
                                            unknown001
                                            last edited by

                                            Man, this version 2.2 is giving a lot of issues for firebox. I no longer can install LCDproc-dev in system packages on webgui. Anyone have the below issue? I'm just encountering issue after issue. Something about "No digital signature!".  By the way the LCDproc packages installs without any issue.

                                            Beginning package installation for LCDproc-dev .
                                            Downloading package configuration file... done.
                                            Saving updated package information... done.
                                            Downloading LCDproc-dev and its dependencies... 
                                            Checking for package installation... 
                                             Downloading https://files.pfsense.org/packages/10/All/lcdproc-0.5.6-i386.pbi ...  (extracting)
                                             ERROR: No digital signature! If you are *SURE* you trust this PBI, re-install with --no-checksig option.
                                            of lcdproc-0.5.6-i386 failed!
                                            
                                            Installation aborted.Removing package...
                                            Starting package deletion for lcdproc-0.5.6-i386...done.
                                            Removing LCDproc-dev components...
                                            Tabs items... done.
                                            Menu items... done.
                                            Services... done.
                                            Loading package instructions...
                                            Removing package instructions...done.
                                            Auxiliary files... done.
                                            Package XML... done.
                                            Configuration... done.
                                            done.
                                            Failed to install package.
                                            
                                            Installation halted.
                                            
                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post
                                            Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.