Skip to content

Commit

Permalink
Update nems-info to detect SCSI dev
Browse files Browse the repository at this point in the history
  • Loading branch information
NEMS Linux committed Sep 6, 2019
1 parent 6a0b26d commit 169867d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
4 changes: 2 additions & 2 deletions info.sh
Expand Up @@ -196,11 +196,11 @@ elif [[ $COMMAND == "rootfulldev" ]]; then
/bin/mount | /bin/sed -n 's|^/dev/\(.*\) on / .*|\1|p'

elif [[ $COMMAND == "rootdev" ]]; then
# output json response of detected wifi networks
# Root device name of the / filesystem (eg., sda or mmcblk0)
/usr/local/share/nems/nems-scripts/info2.sh 8

elif [[ $COMMAND == "rootpart" ]]; then
# output json response of detected wifi networks
# Root partition number of the / filesystem (eg., 1)
/usr/local/share/nems/nems-scripts/info2.sh 9

elif [[ $COMMAND == "wifi" ]]; then
Expand Down
20 changes: 18 additions & 2 deletions info2.sh
Expand Up @@ -112,9 +112,17 @@ switch($argv[1]) {
break;

case 8: // root device
// $fulldev=shell_exec("df /root | awk '/^\/dev/ {print $1}'");
$fulldev=trim(shell_exec("/usr/local/bin/nems-info rootfulldev"));
$tmp = explode('p',$fulldev);
if (!is_array($tmp) || !isset($tmp[1])) {
// Check if is SCSI
preg_match_all('!\d+!', $fulldev, $numbers);
if (is_array($numbers) && isset($numbers[0][0])) {
$tmp = array();
$tmp[0] = preg_replace('/' . $numbers[0][0] . '$/', '', $fulldev);
$tmp[1] = $numbers[0][0];
}
}
if (is_array($tmp)) {
end($tmp);
$lastkey = key($tmp);
Expand All @@ -130,9 +138,17 @@ switch($argv[1]) {
break;

case 9: // root partition on root device
// $fulldev=shell_exec("df /root | awk '/^\/dev/ {print $1}'");
$fulldev=trim(shell_exec("/usr/local/bin/nems-info rootfulldev"));
$tmp = explode('p',$fulldev);
if (!is_array($tmp) || !isset($tmp[1])) {
// Check if is SCSI
preg_match_all('!\d+!', $fulldev, $numbers);
if (is_array($numbers) && isset($numbers[0][0])) {
$tmp = array();
$tmp[0] = preg_replace('/' . $numbers[0][0] . '$/', '', $fulldev);
$tmp[1] = $numbers[0][0];
}
}
if (is_array($tmp)) {
end($tmp);
$partkey = key($tmp);
Expand Down

0 comments on commit 169867d

Please sign in to comment.