aboutsummaryrefslogtreecommitdiffstats
path: root/config/blinkled
diff options
context:
space:
mode:
authordoktornotor <notordoktor@gmail.com>2015-08-03 15:53:42 +0200
committerdoktornotor <notordoktor@gmail.com>2015-08-03 15:53:42 +0200
commit581ccf33fef3565fa2b111de2814d6d978fc628f (patch)
treea2c4951013f778b84812bd5ebec532ed248fabe5 /config/blinkled
parent67c43e72d5db6a76bcec6c12be80ea2a07102215 (diff)
downloadpfsense-packages-581ccf33fef3565fa2b111de2814d6d978fc628f.tar.gz
pfsense-packages-581ccf33fef3565fa2b111de2814d6d978fc628f.tar.bz2
pfsense-packages-581ccf33fef3565fa2b111de2814d6d978fc628f.zip
blinkled - code style fixes, add copyright headers
(Resubmit of #921.) - Code style fixes - Improve service description. - Remove blinkled_stop() function, used just once -> pointless. - Use is_process_running()
Diffstat (limited to 'config/blinkled')
-rw-r--r--config/blinkled/blinkled.inc61
1 files changed, 43 insertions, 18 deletions
diff --git a/config/blinkled/blinkled.inc b/config/blinkled/blinkled.inc
index ffbc79b2..ef2b6db8 100644
--- a/config/blinkled/blinkled.inc
+++ b/config/blinkled/blinkled.inc
@@ -1,20 +1,45 @@
<?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_running () {
- return ((int)exec('pgrep blinkled | wc -l') > 0);
-}
-
function sync_package_blinkled() {
global $config;
$blinkled_config = $config['installedpackages']['blinkled']['config'][0];
- /* kill all instances of blinkled */
- if(blinkled_running()) {
- blinkled_stop();
+ /* Kill all instances of blinkled */
+ if (is_process_running("blinkled")) {
+ mwexec("/usr/bin/killall -9 blinkled");
}
- /* if blinkled not running start it */
- if(!blinkled_running()) {
+ /* If blinkled is not running, start it */
+ if (!is_process_running("blinkled")) {
blinkled_start();
}
}
@@ -26,25 +51,25 @@ function blinkled_launch($int, $led) {
function blinkled_start() {
global $config;
$blinkled_config = $config['installedpackages']['blinkled']['config'][0];
- if (!($blinkled_config['enable']))
+ if (!($blinkled_config['enable'])) {
return;
+ }
- if (($blinkled_config['enable_led2']) && ($blinkled_config['iface_led2']))
+ 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']))
+ }
+ 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.';
+ }
}
?>