aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshevabam <shevabam@users.noreply.github.com>2017-03-23 10:14:41 +0100
committerGitHub <noreply@github.com>2017-03-23 10:14:41 +0100
commit4142d5f19904c5f00bb11a9ba8746068a9169b4f (patch)
tree52e684676245330c21f50e098d245fadda49e6d8
parent4ce411b34eb9a2bbeaef23f5bf7cf33b49fce85f (diff)
parent5ebb86e446b4cd858395b54f15028ab592e223a7 (diff)
Merge pull request #48 from Nicolas01/DontRemoveSpacesInMountPoints
Don't remove spaces in mount points
-rw-r--r--libs/disk.php6
1 files changed, 4 insertions, 2 deletions
diff --git a/libs/disk.php b/libs/disk.php
index 80fedc7..6367114 100644
--- a/libs/disk.php
+++ b/libs/disk.php
@@ -4,7 +4,9 @@ $Config = new Config();
$datas = array();
-if (!(exec('/bin/df -T -P | sed -e \'s/[ \t]//\' | awk -v c=`/bin/df -T | grep -bo "Type" | awk -F: \'{print $2}\'` \'{print substr($0,c);}\' | tail -n +2 | awk \'{print $1","$2","$3","$4","$5","$6","$7}\'', $df)))
+# if there are more than 7 awk's colums it means the mount point name contains spaces
+# so consider the first colums as a unique colum and the last 6 as real colums
+if (!(exec('/bin/df -T -P | tail -n +2 | awk \'{ if (NF > 7) { for (i=1; i<NF-6; i++) { printf("%s ", $i); } for (i=NF-6; i<NF; i++) { printf("%s,", $i); } print $NF; } else { print $1","$2","$3","$4","$5","$6","$7; } }\'', $df)))
{
$datas[] = array(
'total' => 'N.A',
@@ -52,4 +54,4 @@ else
}
-echo json_encode($datas); \ No newline at end of file
+echo json_encode($datas);