mirror of
				https://github.com/Ylianst/MeshCentral.git
				synced 2025-03-09 15:40:18 +00:00 
			
		
		
		
	fix mac volume detection for older os
Signed-off-by: si458 <simonsmith5521@gmail.com>
This commit is contained in:
		
							parent
							
								
									be3e333b40
								
							
						
					
					
						commit
						23ee76e26a
					
				
					 1 changed files with 23 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -717,7 +717,29 @@ function macos_identifiers()
 | 
			
		|||
    child.stdout.str = ''; child.stdout.on('data', dataHandler);
 | 
			
		||||
    child.stdin.write('df -aHY | awk \'NR>1 {printf "{\\"size\\":\\"%s\\",\\"used\\":\\"%s\\",\\"available\\":\\"%s\\",\\"mount_point\\":\\"%s\\",\\"type\\":\\"%s\\"},", $3, $4, $5, $10, $2}\' | sed \'$ s/,$//\' | awk \'BEGIN {printf "["} {printf "%s", $0} END {printf "]"}\'\nexit\n');
 | 
			
		||||
    child.waitExit();
 | 
			
		||||
    try { ret.darwin.volumes = JSON.parse(child.stdout.str.trim()); } catch (xx) { }
 | 
			
		||||
    try {
 | 
			
		||||
        ret.darwin.volumes = JSON.parse(child.stdout.str.trim());
 | 
			
		||||
        for (var index = 0; index < ret.darwin.volumes.length; index++) {
 | 
			
		||||
            if (ret.darwin.volumes[index].type == 'auto_home'){
 | 
			
		||||
                ret.darwin.volumes.splice(index,1);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if (ret.darwin.volumes.length == 0) { // not sonima OS so dont show type for now
 | 
			
		||||
            child = require('child_process').execFile('/bin/sh', ['sh']);
 | 
			
		||||
            child.stdout.str = ''; child.stdout.on('data', dataHandler);
 | 
			
		||||
            child.stdin.write('df -aH | awk \'NR>1 {printf "{\\"size\\":\\"%s\\",\\"used\\":\\"%s\\",\\"available\\":\\"%s\\",\\"mount_point\\":\\"%s\\"},", $2, $3, $4, $9}\' | sed \'$ s/,$//\' | awk \'BEGIN {printf "["} {printf "%s", $0} END {printf "]"}\'\nexit\n');
 | 
			
		||||
            child.waitExit();
 | 
			
		||||
            try {
 | 
			
		||||
                ret.darwin.volumes = JSON.parse(child.stdout.str.trim());
 | 
			
		||||
                for (var index = 0; index < ret.darwin.volumes.length; index++) {
 | 
			
		||||
                    sendConsoleText(ret.darwin.volumes[index].size);
 | 
			
		||||
                    if (ret.darwin.volumes[index].size == 'auto_home'){
 | 
			
		||||
                        ret.darwin.volumes.splice(index,1);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            } catch (xx) { }
 | 
			
		||||
        }
 | 
			
		||||
    } catch (xx) { }
 | 
			
		||||
    child = null;
 | 
			
		||||
 | 
			
		||||
    // MacOS Last Boot Up Time
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue