diff options
Diffstat (limited to 'config')
-rw-r--r-- | config/gwled/gwled.inc | 70 | ||||
-rw-r--r-- | config/gwled/gwled.php | 28 | ||||
-rw-r--r-- | config/gwled/gwled.xml | 46 |
3 files changed, 118 insertions, 26 deletions
diff --git a/config/gwled/gwled.inc b/config/gwled/gwled.inc index dad6fe69..9917208b 100644 --- a/config/gwled/gwled.inc +++ b/config/gwled/gwled.inc @@ -1,17 +1,42 @@ <?php -require_once("functions.inc"); +/* + gwled.inc + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2011 Jim Pingle + Copyright (C) 2015 ESF, LLC + All rights reserved. -function gwled_running () { - return ((int)exec('pgrep -f gwled | wc -l') > 0); -} + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +require_once("functions.inc"); 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(); + /* Kill all instances of gwled */ + if (is_process_running("gwled")) { + mwexec("/bin/pkill -9 -f gwled"); } gwled_start(); } @@ -19,29 +44,27 @@ 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"); } } -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']) && + if (($post['gw_led2']) && ($post['gw_led3']) && (($post['enable_led2']) && ($post['enable_led3'])) && - ($post['gw_led2'] == $post['gw_led3'])) + ($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 +72,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 +82,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"); + } } ?> 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 <?php +/* + gwled.php + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2011 Jim Pingle + Copyright (C) 2015 ESF, LLC + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ require_once("config.inc"); require_once("functions.inc"); require_once("gwled.inc"); 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 @@ <?xml version="1.0" encoding="utf-8" ?> <packagegui> + <copyright> + <![CDATA[ +/* $Id$ */ +/* ====================================================================================== */ +/* + gwled.xml + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2011-2013 Jim Pingle + Copyright (C) 2015 ESF, LLC + All rights reserved. +*/ +/* ====================================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ +/* ====================================================================================== */ + ]]> + </copyright> <title>Interfaces: Gateway Status LEDs</title> <name>gwled</name> - <version>20110810</version> + <version>0.2.2</version> <savetext>Save</savetext> <include_file>/usr/local/pkg/gwled.inc</include_file> <menu> @@ -14,13 +53,13 @@ <additional_files_needed> <item>https://packages.pfsense.org/packages/config/gwled/gwled.inc</item> <prefix>/usr/local/pkg/</prefix> - <chmod>0644</chmod> </additional_files_needed> <additional_files_needed> <prefix>/usr/local/bin/</prefix> <chmod>0755</chmod> <item>https://packages.pfsense.org/packages/config/gwled/gwled.php</item> </additional_files_needed> + <!-- TODO: Make the gwled.sh script really usable for start/stop/restart --> <service> <name>gwled</name> <rcfile>gwled.sh</rcfile> @@ -33,8 +72,7 @@ <fieldname>enable</fieldname> <type>checkbox</type> <enablefields>enable_led2,enable_led3,gw_led2,gw_led3</enablefields> - <description>if this is enabled, it will use LED #2 and #3 to - indicate gateway status with a peridic poll.</description> + <description>if this is enabled, it will use LED #2 and #3 to indicate gateway status with a peridic poll.</description> </field> <field> <fielddescr>Enable LED #2</fielddescr> |