Firebox LCD Driver for LCDProc
-
It should not be a driver problem.
Indeed it should not yet it seems to be.
My only thoughts on that were that the sdeclcd driver somehow had a delay in initialising the hardware such that it is unable to start/stop in the required time when multiple restarts are called at boot. That might also explain why the driver seems to work better on the X-Core box which has a slower CPU. However no amount of adding or removing delays from the start script seemed to really solve the problem.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.
Steve
-
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
-
Ah, yes of course.
Steve
-
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
-
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
-
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
-
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 ;)
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" !
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
-
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 -
Hi,
1.st I should not post nore asume anything on a late evening !
2.nd I should read my previous postings again !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
ArkAngel1. Ok, thanks for the info… I'm pretty new to pfSense!
2. that is the same setup I haveOK… here I go again!
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
-
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
-
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
-
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
-
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
-
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"). -
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
-
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
-
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#msg421118Steve
-
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
-
LCDProc isn't working on pFsense 2.2
-
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.0Steve