diff options
author | Scott Ullrich <sullrich@gmail.com> | 2012-01-05 15:43:54 -0500 |
---|---|---|
committer | Scott Ullrich <sullrich@gmail.com> | 2012-01-05 15:43:54 -0500 |
commit | 3bd8b80e8c141174f62e93a8d7096d6bb96d4871 (patch) | |
tree | efbec99e3aa360def405134890c2c413fefbea5c /config/nut | |
parent | 3274287a8240426e788e93228a7608a67ecbcb50 (diff) | |
download | pfsense-packages-3bd8b80e8c141174f62e93a8d7096d6bb96d4871.tar.gz pfsense-packages-3bd8b80e8c141174f62e93a8d7096d6bb96d4871.tar.bz2 pfsense-packages-3bd8b80e8c141174f62e93a8d7096d6bb96d4871.zip |
Improve device handling a bit for Nut package
Diffstat (limited to 'config/nut')
-rw-r--r-- | config/nut/nut.inc | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/config/nut/nut.inc b/config/nut/nut.inc index 6b7b02ac..28ff3999 100644 --- a/config/nut/nut.inc +++ b/config/nut/nut.inc @@ -94,18 +94,26 @@ function before_form_nut($pkg) { /* return available serial ports */ - $handle = popen('dmesg | grep \'^sio[0-9]: type\'','r'); - $read = fread($handle, 2096); - pclose($handle); - /* explode at the newlines */ - $read = explode("\n",$read); - - /* parse resulting text */ - foreach($read as $line) { - if($line!= '') { - $names[] = 'ttyd'.$line{3}.' (COM'.($line{3}+1).')'; - $values[] = '/dev/ttyd'.$line{3}; + $serial_types = array("sio", "cua", "tty"); + $ignore_files = array(".lock", ".init"); + + foreach($serial_types as $st) { + $devices = glob("/dev/{$st}*"); + foreach($devices as $line) { + if($line != '') { + $ignore = false; + foreach($ignore_files as $if) { + if(strstr($line, $if)) { + $ignore = true; + continue; + } + } + if($ignore == false) { + $names[] = str_replace("/dev/", "", $line); + $values[] = $line; + } + } } } |