diff options
author | Chris Buechler <cmb@pfsense.org> | 2015-08-06 23:49:37 -0500 |
---|---|---|
committer | Chris Buechler <cmb@pfsense.org> | 2015-08-06 23:49:37 -0500 |
commit | b9e71625272596e731c2e72f675d2c81691daa05 (patch) | |
tree | 0e8507678488a10e1050e3d3e6f0830dbd50151b | |
parent | a1936ac9b569a05cadc3f1d34004a2eb268ceb47 (diff) | |
parent | c8c5d80de864eb6012dc3d234176b1e7b11e79a5 (diff) | |
download | pfsense-packages-b9e71625272596e731c2e72f675d2c81691daa05.tar.gz pfsense-packages-b9e71625272596e731c2e72f675d2c81691daa05.tar.bz2 pfsense-packages-b9e71625272596e731c2e72f675d2c81691daa05.zip |
Merge pull request #948 from doktornotor/patch-8
-rw-r--r-- | config/blinkled8/blinkled.inc | 78 | ||||
-rw-r--r-- | config/blinkled8/blinkled.xml | 52 | ||||
-rw-r--r-- | pkg_config.10.xml | 2 |
3 files changed, 95 insertions, 37 deletions
diff --git a/config/blinkled8/blinkled.inc b/config/blinkled8/blinkled.inc index 6d0da039..6e76c157 100644 --- a/config/blinkled8/blinkled.inc +++ b/config/blinkled8/blinkled.inc @@ -1,4 +1,33 @@ <?php +/* + blinkled.inc + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2009 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"); function blinkled_rcfile() { @@ -28,53 +57,42 @@ EOD; conf_mount_ro(); } -function blinkled_running () { - return ((int)exec('pgrep blinkled | wc -l') > 0); -} function sync_package_blinkled() { global $config; + + blinkled_rcfile(); + $blinkled_config = $config['installedpackages']['blinkled']['config'][0]; - /* kill all instances of blinkled */ - if(blinkled_running()) { - blinkled_stop(); + /* If the service (being) disabled, stop it (if running) and do nothing else */ + if (!($blinkled_config['enable'])) { + if (is_process_running("blinkled")) { + stop_service("blinkled"); + } + return; } - /* if blinkled not running start it */ - if(!blinkled_running()) { - blinkled_start(); + /* Kill all instances of blinkled */ + if (is_process_running("blinkled")) { + stop_service("blinkled"); } - blinkled_rcfile(); + start_service("blinkled"); } function blinkled_launch($int, $led, $return = false) { $cmd = "/usr/local/bin/blinkled -i " . escapeshellarg($int) . " -l " . escapeshellarg("/dev/led/led{$led}"); - if ($return) + if ($return) { return $cmd; - else + } else { mwexec($cmd); -} - -function blinkled_start() { - global $config; - $blinkled_config = $config['installedpackages']['blinkled']['config'][0]; - if (!($blinkled_config['enable'])) - return; - - if (($blinkled_config['enable_led2']) && ($blinkled_config['iface_led2'])) - blinkled_launch(convert_friendly_interface_to_real_interface_name($blinkled_config['iface_led2']), 2); - if (($blinkled_config['enable_led3']) && ($blinkled_config['iface_led3'])) - blinkled_launch(convert_friendly_interface_to_real_interface_name($blinkled_config['iface_led3']), 3); -} - -function blinkled_stop() { - mwexec("/usr/bin/killall -9 blinkled"); + } } function validate_form_blinkled($post, &$input_errors) { /* Make sure both aren't using the same interface */ - if (($post['iface_led2']) && ($post['iface_led3']) && + if (($post['iface_led2']) && ($post['iface_led3']) && (($post['enable_led2']) && ($post['enable_led3'])) && - ($post['iface_led2'] == $post['iface_led3'])) + ($post['iface_led2'] == $post['iface_led3'])) { $input_errors[] = 'You cannot set two LEDs for a single interface. Please choose seperate interfaces.'; + } } ?> diff --git a/config/blinkled8/blinkled.xml b/config/blinkled8/blinkled.xml index ec70f392..2502f3ff 100644 --- a/config/blinkled8/blinkled.xml +++ b/config/blinkled8/blinkled.xml @@ -1,8 +1,49 @@ <?xml version="1.0" encoding="utf-8" ?> +<!DOCTYPE packagegui SYSTEM "../schema/packages.dtd"> +<?xml-stylesheet type="text/xsl" href="../xsl/package.xsl"?> <packagegui> + <copyright> + <![CDATA[ +/* $Id$ */ +/* ====================================================================================== */ +/* + blinkled.xml + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2009-2012 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: Assign LEDs</title> <name>blinkled</name> - <version>0.4.1</version> + <version>0.4.5</version> <savetext>Save</savetext> <include_file>/usr/local/pkg/blinkled.inc</include_file> <menu> @@ -14,13 +55,12 @@ <additional_files_needed> <item>https://packages.pfsense.org/packages/config/blinkled8/blinkled.inc</item> <prefix>/usr/local/pkg/</prefix> - <chmod>0755</chmod> </additional_files_needed> <service> <name>blinkled</name> <rcfile>blinkled.sh</rcfile> <executable>blinkled</executable> - <description>Blinks LEDs to indicate network activity</description> + <description>Network Activity LED Indicator Daemon</description> </service> <fields> <field> @@ -28,7 +68,7 @@ <fieldname>enable</fieldname> <type>checkbox</type> <enablefields>enable_led2,enable_led3,iface_led2,iface_led3</enablefields> - <description>if this is enabled, it will use LED #2 and #3 to + <description>If this is enabled, it will use LED #2 and #3 to indicate network activity. Be aware, however, that this will possibly consume some system resources in the process.</description> </field> @@ -41,7 +81,7 @@ <fielddescr>Interface For LED #2</fielddescr> <fieldname>iface_led2</fieldname> <type>interfaces_selection</type> - <description>Pick an interface to blink for activity on LED #2</description> + <description>Pick an interface to blink for activity on LED #2.</description> </field> <field> <fielddescr>Enable LED #3</fielddescr> @@ -52,7 +92,7 @@ <fielddescr>Interface For LED #3</fielddescr> <fieldname>iface_led3</fieldname> <type>interfaces_selection</type> - <description>Pick an interface to blink for activity on LED #3</description> + <description>Pick an interface to blink for activity on LED #3.</description> </field> </fields> <custom_php_validation_command> diff --git a/pkg_config.10.xml b/pkg_config.10.xml index 70b2284e..80eacba7 100644 --- a/pkg_config.10.xml +++ b/pkg_config.10.xml @@ -1191,7 +1191,7 @@ <name>blinkled</name> <descr>Allows you to use LEDs for network activity on supported platforms (ALIX, WRAP, Soekris, etc)</descr> <category>System</category> - <version>0.4.4</version> + <version>0.4.5</version> <status>Beta</status> <maintainer>jimp@pfsense.org</maintainer> <required_version>2.2</required_version> |