aboutsummaryrefslogtreecommitdiffstats
path: root/packages/lcdproc
diff options
context:
space:
mode:
authorSeth Mos <seth.mos@xs4all.nl>2008-01-26 22:39:13 +0000
committerSeth Mos <seth.mos@xs4all.nl>2008-01-26 22:39:13 +0000
commit98d4d81b10af8922515d6b5dd136eaad4881b23b (patch)
tree5895efbb102225f84755b04a71e0b2ba9f771b63 /packages/lcdproc
parenta7808d5e212e22bb39b9461f901a7cff42ad2598 (diff)
downloadpfsense-packages-98d4d81b10af8922515d6b5dd136eaad4881b23b.tar.gz
pfsense-packages-98d4d81b10af8922515d6b5dd136eaad4881b23b.tar.bz2
pfsense-packages-98d4d81b10af8922515d6b5dd136eaad4881b23b.zip
Update LCDproc package.
- After installing and selecting some screens this should display something. - PHP lcdproc client not yet finished. Using included lcdproc client for now.
Diffstat (limited to 'packages/lcdproc')
-rw-r--r--packages/lcdproc/lcdproc.inc66
-rw-r--r--packages/lcdproc/lcdproc.xml20
-rw-r--r--packages/lcdproc/lcdproc_client.php54
-rw-r--r--packages/lcdproc/lcdproc_screens.xml56
4 files changed, 159 insertions, 37 deletions
diff --git a/packages/lcdproc/lcdproc.inc b/packages/lcdproc/lcdproc.inc
index d6c3d530..adf3f931 100644
--- a/packages/lcdproc/lcdproc.inc
+++ b/packages/lcdproc/lcdproc.inc
@@ -32,7 +32,7 @@
/* LCDproc */
define('LCDPROC_RCFILE', '/usr/local/etc/rc.d/lcdproc.sh');
- define('LCDPROC_CLIENT', '/tmp/lcdprocc.sh');
+ define('LCDPROC_CLIENT', '/tmp/lcdclient.sh');
define('LCDPROC_CONFIG','/usr/local/etc/LCDd.conf');
define('LCDPROC_HOST','localhost');
define('LCDPROC_PORT','13666');
@@ -61,6 +61,17 @@
fclose($handle);
}
+ function lcdproc_write_script($file, $text) {
+ $handle = fopen($file, 'wx');
+ if(!$handle) {
+ lcdproc_warn("Could not open {$file} for writing.");
+ exit;
+ }
+ fwrite($handle, $text);
+ fclose($handle);
+ chmod($file, 0755);
+ }
+
function before_form_lcdproc($pkg) {
global $config;
@@ -69,6 +80,14 @@
config_unlock();
}
+ function before_form_lcdproc_screens($pkg) {
+ global $config;
+
+ config_lock();
+
+ config_unlock();
+ }
+
function validate_form_lcdproc($post, $input_errors) {
if($post['comport']) {
switch($post['comport']) {
@@ -90,14 +109,22 @@
}
}
}
+ function validate_form_lcdproc_screens($post, $input_errors) {
+ // No validation required ?!
+ }
+ function sync_package_lcdproc_screens() {
+ sync_package_lcdproc();
+ }
function sync_package_lcdproc() {
+ global $g;
global $config;
global $input_errors;
config_lock();
$lcdproc_config = $config['installedpackages']['lcdproc']['config'][0];
+ $lcdproc_screens_config = $config['installedpackages']['lcdprocscreens']['config'][0];
/* since config is written before this file invoked we don't need to read post data */
if($lcdproc_config['enable'] && ($lcdproc_config['comport'] != "none")) {
@@ -124,11 +151,11 @@
$config_text .= "ReportToSyslog=yes\n";
$config_text .= "WaitTime=5\n";
$config_text .= "User=nobody\n";
- $config_text .= "ServerScreen=0\n";
+ $config_text .= "ServerScreen=no\n";
$config_text .= "Foreground=no\n";
$config_text .= "DriverPath=/usr/local/lib/lcdproc/\n";
$config_text .= "GoodBye=\"Thanks for using\"\n";
- $config_text .= "GoodBye=\" {$g['product']} \"\n";
+ $config_text .= "GoodBye=\" {$g['product_name']} \"\n";
/* FIXME: Specific to the pyramid project */
$config_text .= "ToggleRotateKey=Enter\n";
$config_text .= "PrevScreenKey=Left\n";
@@ -217,13 +244,35 @@
}
/* generate rc file start and stop */
+ $options = "";
+ foreach($lcdproc_screens_config as $name => $screen) {
+ if($screen == "on") {
+ switch($name) {
+ case "scr_cpu":
+ $options .= "P ";
+ break;
+ case "scr_time":
+ $options .= "O ";
+ break;
+ case "scr_load":
+ $options .= "L ";
+ break;
+ case "scr_uptime":
+ $options .= "U ";
+ break;
+ }
+ }
+ }
$client_script = <<<EOD
#!/bin/sh
+# script starts a lcd client and always keeps it active.
counter=1
-while [ "$counter" -ne 0 ]
+while [ "\$counter" -ne 0 ]
do
- /usr/local/bin/php -f /usr/local/pkg/lcdproc_client.php
+ # start the lcd client, lcdproc client for now until PHP client is finished
+ /usr/local/bin/lcdproc -f O P L U
+ #/usr/local/bin/php -f /usr/local/pkg/lcdproc_client.php
sleep 10
done
@@ -234,11 +283,11 @@ EOD;
if [ `pgrep LCDd | wc -l` != 0 ]; then
/usr/bin/killall LCDd
- /usr/bin/killall lcdprocc.sh
+ /usr/bin/killall lcdclient.sh
while [ `pgrep LCDd | wc -l` != 0 ]; do
sleep 1
done
- while [ `pgrep lcdprocc.sh | wc -l` != 0 ]; do
+ while [ `pgrep lcdclient.sh | wc -l` != 0 ]; do
sleep 1
done
fi
@@ -246,10 +295,11 @@ fi
EOD;
$start = $stop ."\n";
$start .= "\t/usr/local/sbin/LCDd -c ". LCDPROC_CONFIG ."\n";
+ $start .= "\t". LCDPROC_CLIENT ." &\n";
/* write out the configuration */
conf_mount_rw();
- lcdproc_write_config(LCDPROC_CLIENT, $client_script);
+ lcdproc_write_script(LCDPROC_CLIENT, $client_script);
lcdproc_write_config(LCDPROC_CONFIG, $config_text);
write_rcfile(array(
'file' => 'lcdproc.sh',
diff --git a/packages/lcdproc/lcdproc.xml b/packages/lcdproc/lcdproc.xml
index 34dc7fa4..e87ad03d 100644
--- a/packages/lcdproc/lcdproc.xml
+++ b/packages/lcdproc/lcdproc.xml
@@ -2,9 +2,20 @@
<packagegui>
<title>Services: LCDproc</title>
<name>lcdproc</name>
- <version>0.5.2_1-p2</version>
+ <version>0.5.2_1-p3</version>
<savetext>Save</savetext>
<include_file>/usr/local/pkg/lcdproc.inc</include_file>
+ <tabs>
+ <tab>
+ <text>Server</text>
+ <url>/pkg_edit.php?xml=lcdproc.xml&amp;id=0</url>
+ <active/>
+ </tab>
+ <tab>
+ <text>Screens</text>
+ <url>/pkg_edit.php?xml=lcdproc_screens.xml&amp;id=0</url>
+ </tab>
+ </tabs>
<menu>
<name>LCDproc</name>
<tooltiptext>Set LCDproc settings such as display driver and com port</tooltiptext>
@@ -26,13 +37,6 @@
<rcfile>lcdproc.sh</rcfile>
<executable>lcdproc</executable>
</service>
- <tabs>
- <tab>
- <text>LCDproc Settings</text>
- <url>/pkg_edit.php?xml=lcdproc.xml&amp;id=0</url>
- <active/>
- </tab>
- </tabs>
<fields>
<field>
<fielddescr>Enable LCDproc</fielddescr>
diff --git a/packages/lcdproc/lcdproc_client.php b/packages/lcdproc/lcdproc_client.php
index ea9d8c97..a07b62ce 100644
--- a/packages/lcdproc/lcdproc_client.php
+++ b/packages/lcdproc/lcdproc_client.php
@@ -27,8 +27,8 @@
POSSIBILITY OF SUCH DAMAGE.
*/
- require_once("config.inc");
- require_once("functions.inc");
+ // require_once("config.inc");
+ // require_once("functions.inc");
require_once("/usr/local/pkg/lcdproc.inc");
/* Define functions */
@@ -39,34 +39,46 @@
}
foreach($lcd_cmds as $lcd_cmd) {
$cmd_output = "";
- fwrite($lcd, $lcd_cmd);
- $cmd_output .= fgets($lcd, 128);
- lcdproc_notice("LCDd output for cmd $lcd_cmd is: $cmd_output");
- sleep(1);
+ if(! fwrite($lcd, "$lcd_cmd\n")) {
+ lcdproc_warn("Connection to LCDd process lost $errstr ($errno)");
+ die();
+ }
+ $cmd_output = fgets($lcd, 4096);
+ if(preg_match("/^huh?/", $cmd_output)) {
+ lcdproc_notice("LCDd output: \"$cmd_output\". Executed \"$lcd_cmd\"");
+ }
+ // sleep(1);
}
}
function loop_status($lcd) {
+ global $g;
+ global $config;
/* keep a counter to see how many times we can loop */
- $i = 0;
- while(1) {
- $time = time();
+ $i = 1;
+ while($i) {
+ $time = date ("l dS of F Y h:i:s A");
$lcd_cmds = array();
- $lcd_cmds[] = "client_set -name \"Parenttest\"\n";
- $lcd_cmds[] = "screen_add status\n";
- $lcd_cmds[] = "screen_set status -heartbeat off\n";
- $lcd_cmds[] = "widget_add status title title\n";
- $lcd_cmds[] = "widget_add status date scroller\n";
- $lcd_cmds[] = "widget_set status title $i\n";
- $lcd_cmds[] = "widget_set status date left right h 1 $time\n";
+ $lcd_cmds[] = "widget_set welcome_scr title_wdgt \"$i test \"";
+ // $lcd_cmds[] = "widget_set welcome_scr text_wdgt 1 1 \"$time test\"";
+ $lcd_cmds[] = "widget_set welcome_scr text_wdgt 1 2 20 2 h 4 \"$i $time test\"";
+ // $lcd_cmds[] = "output on 1 \"";
send_lcd_commands($lcd, $lcd_cmds);
+ sleep(10);
$i++;
}
}
- function send_hello($lcd) {
+ function build_interface($lcd) {
$lcd_cmds = array();
- $lcd_cmds[] = "hello\n";
+ $lcd_cmds[] = "hello";
+ $lcd_cmds[] = "client_set name pfSense";
+ $lcd_cmds[] = "screen_add welcome_scr";
+ $lcd_cmds[] = "screen_set welcome_scr heartbeat off";
+ // $lcd_cmds[] = "screen_set welcome_scr duration 32";
+ $lcd_cmds[] = "screen_set welcome_scr name welcome";
+ $lcd_cmds[] = "widget_add welcome_scr title_wdgt title";
+ $lcd_cmds[] = "widget_add welcome_scr text_wdgt scroller";
send_lcd_commands($lcd, $lcd_cmds);
}
@@ -75,10 +87,10 @@
if (!$lcd) {
lcdproc_warn("Failed to connect to LCDd process $errstr ($errno)");
} else {
- send_hello($lcd);
+ build_interface($lcd);
loop_status($lcd);
/* loop exited? Close fd and wait for the script to kick in again */
- sleep(1);
+ // sleep(1);
+ fclose($lcd);
}
- fclose($lcd);
?>
diff --git a/packages/lcdproc/lcdproc_screens.xml b/packages/lcdproc/lcdproc_screens.xml
new file mode 100644
index 00000000..9c44852d
--- /dev/null
+++ b/packages/lcdproc/lcdproc_screens.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<packagegui>
+ <title>Services: LCDproc: Screens</title>
+ <name>lcdproc_screens</name>
+ <version>0.5.2_1-p3</version>
+ <savetext>Save</savetext>
+ <include_file>/usr/local/pkg/lcdproc.inc</include_file>
+ <tabs>
+ <tab>
+ <text>Server</text>
+ <url>/pkg_edit.php?xml=lcdproc.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Screens</text>
+ <url>/pkg_edit.php?xml=lcdproc_screens.xml&amp;id=0</url>
+ <active/>
+ </tab>
+ </tabs>
+ <menu>
+ <name>LCDproc</name>
+ <tooltiptext>Set LCDproc settings such as display driver and com port</tooltiptext>
+ <section>Services</section>
+ <url>/pkg_edit.php?xml=lcdproc.xml&amp;id=0</url>
+ </menu>
+ <fields>
+ <field>
+ <fielddescr>Enable CPU</fielddescr>
+ <fieldname>scr_cpu</fieldname>
+ <type>checkbox</type>
+ </field>
+ <field>
+ <fielddescr>Enable Load</fielddescr>
+ <fieldname>scr_load</fieldname>
+ <type>checkbox</type>
+ </field>
+ <field>
+ <fielddescr>Enable Time</fielddescr>
+ <fieldname>scr_time</fieldname>
+ <type>checkbox</type>
+ </field>
+ <field>
+ <fielddescr>Enable Uptime</fielddescr>
+ <fieldname>scr_uptime</fieldname>
+ <type>checkbox</type>
+ </field>
+ </fields>
+ <custom_php_command_before_form>
+ before_form_lcdproc_screens(&amp;$pkg);
+ </custom_php_command_before_form>
+ <custom_php_validation_command>
+ validate_form_lcdproc_screens($_POST, &amp;$input_errors);
+ </custom_php_validation_command>
+ <custom_php_resync_config_command>
+ sync_package_lcdproc_screens();
+ </custom_php_resync_config_command>
+</packagegui>