From c7617a58ce0bd1728b6cddaebb95e623fe3d10b6 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sat, 1 Aug 2015 10:47:39 +0200 Subject: gwled - code style fixes, add copyright headers --- config/gwled/gwled.inc | 64 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 49 insertions(+), 15 deletions(-) diff --git a/config/gwled/gwled.inc b/config/gwled/gwled.inc index dad6fe69..ce6f23d9 100644 --- a/config/gwled/gwled.inc +++ b/config/gwled/gwled.inc @@ -1,16 +1,45 @@ 0); + return ((int)exec('/bin/pgrep -f gwled | /usr/bin/wc -l') > 0); } function sync_package_gwled() { global $config; $gwled_config = $config['installedpackages']['gwled']['config'][0]; led_normalize(); - /* kill all instances of gwled */ - if(gwled_running()) { + /* Kill all instances of gwled */ + if (gwled_running()) { gwled_stop(); } gwled_start(); @@ -19,14 +48,15 @@ function sync_package_gwled() { function gwled_start() { global $config; $gwled_config = $config['installedpackages']['gwled']['config'][0]; - if (!($gwled_config['enable'])) + if (!($gwled_config['enable'])) { return; + } // How often to run the check, in seconds. $interval = 15; - if (($gwled_config['enable_led2']) && ($gwled_config['gw_led2']) - || ($gwled_config['enable_led3']) && ($gwled_config['gw_led3'])) { + if (($gwled_config['enable_led2']) && ($gwled_config['gw_led2']) || + ($gwled_config['enable_led3']) && ($gwled_config['gw_led3'])) { mwexec("/usr/local/bin/minicron {$interval} /var/run/gwled.pid /usr/local/bin/gwled.php"); mwexec_bg("/usr/local/bin/gwled.php"); } @@ -38,10 +68,11 @@ function gwled_stop() { function validate_form_gwled($post, &$input_errors) { /* Make sure both aren't using the same interface */ - if (($post['gw_led2']) && ($post['gw_led3']) && + if (($post['gw_led2']) && ($post['gw_led3']) && (($post['enable_led2']) && ($post['enable_led3'])) && - ($post['gw_led2'] == $post['gw_led3'])) - $input_errors[] = 'You cannot set two LEDs for a single gateway. Please choose seperate interfaces.'; + ($post['gw_led2'] == $post['gw_led3'])) { + $input_errors[] = 'You cannot set two LEDs for a single gateway. Please choose seperate interfaces.'; + } } function gwled_get_gateways() { @@ -49,7 +80,7 @@ function gwled_get_gateways() { foreach ($gateways as $gateway) { $tmp["name"] = "{$gateway['name']} (Monitor: {$gateway['monitor']})"; - $tmp["value"] = $gateway['name']; + $tmp["value"] = $gateway['name']; $gws[] = $tmp; } return $gws; @@ -59,18 +90,21 @@ function gwled_set_status($gateway, $led) { $a_gateways = return_gateways_array(); $gateways_status = array(); $gateways_status = return_gateways_status(true); + if ($gateways_status[$gateway]) { $status = $gateways_status[$gateway]['status']; - if (stristr($status, "down")) + if (stristr($status, "down")) { led_blink($led, "veryfast"); - elseif (stristr($status, "loss")) + } elseif (stristr($status, "loss")) { led_blink($led, "fast"); - elseif (stristr($status, "delay")) + } elseif (stristr($status, "delay")) { led_blink($led, "medium"); - elseif ($status == "none") + } elseif ($status == "none") { led_on($led); - } else + } + } else { led_blink($led, "veryfast"); + } } ?> -- cgit v1.2.3 From 78120ea373fe37309fbd8229dd04ad4d93936890 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sat, 1 Aug 2015 10:49:46 +0200 Subject: gwled - code style fixes, add copyright headers --- config/gwled/gwled.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/config/gwled/gwled.php b/config/gwled/gwled.php index efcb73dd..bddf41eb 100644 --- a/config/gwled/gwled.php +++ b/config/gwled/gwled.php @@ -1,5 +1,33 @@ #!/usr/local/bin/php -q Date: Sat, 1 Aug 2015 10:50:56 +0200 Subject: gwled - code style fixes, add copyright headers --- config/gwled/gwled.xml | 46 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/config/gwled/gwled.xml b/config/gwled/gwled.xml index 015ab3bb..5d2a047e 100644 --- a/config/gwled/gwled.xml +++ b/config/gwled/gwled.xml @@ -1,8 +1,47 @@ + + + Interfaces: Gateway Status LEDs gwled - 20110810 + 0.2.2 Save /usr/local/pkg/gwled.inc @@ -14,13 +53,13 @@ https://packages.pfsense.org/packages/config/gwled/gwled.inc /usr/local/pkg/ - 0644 /usr/local/bin/ 0755 https://packages.pfsense.org/packages/config/gwled/gwled.php + gwled gwled.sh @@ -33,8 +72,7 @@ enable checkbox enable_led2,enable_led3,gw_led2,gw_led3 - if this is enabled, it will use LED #2 and #3 to - indicate gateway status with a peridic poll. + if this is enabled, it will use LED #2 and #3 to indicate gateway status with a peridic poll. Enable LED #2 -- cgit v1.2.3 From 7e4dde28a2a9202e2ecd49c7d2171a9f6a9dc3b4 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sat, 1 Aug 2015 10:51:41 +0200 Subject: Bump gwled package version --- pkg_config.10.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg_config.10.xml b/pkg_config.10.xml index 480d4fef..9362740f 100644 --- a/pkg_config.10.xml +++ b/pkg_config.10.xml @@ -1210,7 +1210,7 @@ gwled Allows you to use LEDs for gateway status on supported platforms (ALIX, WRAP, Soekris, etc) System - 0.2.1 + 0.2.2 Beta jimp@pfsense.org sysutils -- cgit v1.2.3 From 991f3d0f5edb2dec1ea69b28da406e0108365177 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Mon, 3 Aug 2015 16:08:41 +0200 Subject: gwled.inc - use is_process_running() and nuke pointless functions --- config/gwled/gwled.inc | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/config/gwled/gwled.inc b/config/gwled/gwled.inc index ce6f23d9..ff62e562 100644 --- a/config/gwled/gwled.inc +++ b/config/gwled/gwled.inc @@ -30,17 +30,13 @@ require_once("functions.inc"); -function gwled_running () { - return ((int)exec('/bin/pgrep -f gwled | /usr/bin/wc -l') > 0); -} - function sync_package_gwled() { global $config; $gwled_config = $config['installedpackages']['gwled']['config'][0]; led_normalize(); /* Kill all instances of gwled */ - if (gwled_running()) { - gwled_stop(); + if (is_process_running("gwled")) { + mwexec("/bin/pkill -9 -f gwled"); } gwled_start(); } @@ -62,10 +58,6 @@ function gwled_start() { } } -function gwled_stop() { - exec("/bin/pkill -9 -f gwled"); -} - function validate_form_gwled($post, &$input_errors) { /* Make sure both aren't using the same interface */ if (($post['gw_led2']) && ($post['gw_led3']) && -- cgit v1.2.3 From fd02e694fe92b75fec6744cedd36c4b773568d7c Mon Sep 17 00:00:00 2001 From: doktornotor Date: Mon, 3 Aug 2015 16:24:31 +0200 Subject: gwled.inc - fix indentation --- config/gwled/gwled.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/gwled/gwled.inc b/config/gwled/gwled.inc index ff62e562..9917208b 100644 --- a/config/gwled/gwled.inc +++ b/config/gwled/gwled.inc @@ -63,7 +63,7 @@ function validate_form_gwled($post, &$input_errors) { if (($post['gw_led2']) && ($post['gw_led3']) && (($post['enable_led2']) && ($post['enable_led3'])) && ($post['gw_led2'] == $post['gw_led3'])) { - $input_errors[] = 'You cannot set two LEDs for a single gateway. Please choose seperate interfaces.'; + $input_errors[] = 'You cannot set two LEDs for a single gateway. Please choose seperate interfaces.'; } } -- cgit v1.2.3