diff options
author | jim-p <jim@pingle.org> | 2009-07-11 01:26:57 -0400 |
---|---|---|
committer | jim-p <jim@pingle.org> | 2009-07-11 01:26:57 -0400 |
commit | e968f5ee09483675c3fc73a9a34c1fbd06b1be54 (patch) | |
tree | 6e0eecd675722afb5c2ca60eae1b8d588328e038 /config/blinkled/blinkled.inc | |
parent | 6df4fc24f66bbfc9edef0ec3303b518b2eb12e61 (diff) | |
download | pfsense-packages-e968f5ee09483675c3fc73a9a34c1fbd06b1be54.tar.gz pfsense-packages-e968f5ee09483675c3fc73a9a34c1fbd06b1be54.tar.bz2 pfsense-packages-e968f5ee09483675c3fc73a9a34c1fbd06b1be54.zip |
Let's try a blinkled package. Also part of feature #17
Seemed like a good idea at the time.
Diffstat (limited to 'config/blinkled/blinkled.inc')
-rw-r--r-- | config/blinkled/blinkled.inc | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/config/blinkled/blinkled.inc b/config/blinkled/blinkled.inc new file mode 100644 index 00000000..25403232 --- /dev/null +++ b/config/blinkled/blinkled.inc @@ -0,0 +1,50 @@ +<?php +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(); + } + /* if blinkled not running start it */ + if(!blinkled_running()) { + blinkled_start(); + } +} + +function blinkled_launch($int, $led) { + mwexec("/usr/local/bin/blinkled -i " . escapeshellarg($int) . " -l /dev/led/led" . escapeshellarg($led)); +} + +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']) && + (($post['enable_led2']) && ($post['enable_led3'])) && + ($post['iface_led2'] == $post['iface_led3'])) + $input_errors[] = 'You cannot set two LEDs for a single interface. Please choose seperate interfaces.'; +} + +?> |