This commit is contained in:
2019-04-09 01:13:49 -07:00
parent 01d7489c05
commit 9884d19108
6 changed files with 171 additions and 290 deletions

View File

@@ -3,7 +3,7 @@
// Yuba
// //
//////////////////////////////////////////
$version = "0.7.9";
$version = "0.7.9.3";
ini_set('memory_limit', '4096M');
date_default_timezone_set("America/Los_Angeles");
@@ -18,6 +18,8 @@ $wopt_noprofile = 0;
$wopt_steps = 10;
$wopt_currstep = 1;
$parser = new plistParser();
$p = unserialize(file_get_contents("prefs.php"));
// Path & application variables
@@ -32,7 +34,7 @@ if (!is_dir($zpath) | !is_dir($bdest)) { echo "Filepath error"; die; }
// Check for bundle
if ($zpath == "/") { $blabel = "root"; } else { $blabel = preg_replace("/[^A-Za-z0-9\.]/", "_", basename($zpath)); }
if (is_writable($zpath)) { echo "Warning: source is writeable"; }
if (is_writable($zpath)) { echo "Warning: source is writeable\n"; }
$bpath = chop($bdest,"/")."/".substr(crc32($zpath),0,3)."_".$blabel.".bundle";
if (!is_dir($bpath)) { mkdir($bpath); }
@@ -97,17 +99,6 @@ echo msg($banner."\n".str_repeat("-", strlen($banner)));
echo msg("Gathering system info...");
$host = gethostname();
$disks = shell_exec("diskutil list -plist 2>&1");
$df = shell_exec("df 2>&1");
$df_volume = shell_exec("df ".escapeshellarg($zpath)." | tail -n 1 | rev | cut -d' ' -f1 | rev");
$df_device = shell_exec("df ".escapeshellarg($zpath)." | tail -n 1 | cut -d' ' -f1");
$mdutil = shell_exec("mdutil -s ".$df_volume);
if (strpos($mdutil,"disabled")) {
echo msg("Warning: spotlight indexing is disabled");
$p['spotlight'] = false;
}
if (substr($zpath, 0, 9) != "/Volumes/") {
$zbase = "/";
} else {
@@ -115,14 +106,36 @@ if (substr($zpath, 0, 9) != "/Volumes/") {
$zbase = "/Volumes/".$zparts[2];
}
$hdiutil = shell_exec("hdiutil info -plist 2>&1");
$host = gethostname();
$disks = shell_exec("diskutil list -plist 2>&1");
$diskutil = shell_exec("diskutil info -plist ".$zbase." 2>&1");
$diskutil_parsed = $parser->parseString(utf8_for_xml($diskutil));
//print_r($diskutil_parsed);
$vdisks = shell_exec("hdiutil info -plist 2>&1");
$vdisks_parsed = $parser->parseString(utf8_for_xml($vdisks));
//print_r($vdisks_parsed);
$df = shell_exec("df 2>&1");
// old method, new method is to parse plist
//$df_volume = trim(shell_exec("df ".escapeshellarg($zpath)." | tail -n 1 | rev | cut -d' ' -f1 | rev"));
//$df_device = trim(shell_exec("df ".escapeshellarg($zpath)." | tail -n 1 | cut -d' ' -f1"));
$df_volume = $diskutil_parsed['MountPoint'];
$df_device = "/dev/".$diskutil_parsed['ParentWholeDisk'];
$mdutil = shell_exec("mdutil -s ".$df_volume);
if (strpos($mdutil,"disabled")) {
echo msg("Warning: spotlight indexing is disabled");
$p['spotlight'] = false;
}
/////////////////////////////////////////////////////////////////////////////////////////////
// rewrite below to use diskutil info -plist
//
//
//
$diskutil = shell_exec("diskutil info ".$zbase." 2>&1");
$olddiskutil = shell_exec("diskutil info ".$zbase." 2>&1");
$getdetail = array( "Volume Name",
"Protocol",
"Volume UUID",
@@ -132,7 +145,7 @@ $getdetail = array( "Volume Name",
"Level Type"
);
foreach ($getdetail as $detail) {
preg_match("/(".$detail.":)(.*)(\n)/",$diskutil,$matches);
preg_match("/(".$detail.":)(.*)(\n)/",$olddiskutil,$matches);
if (isset($matches[2])) {
if (substr($detail, -5, 5) == "Space") {
$pieces = explode(" ", trim($matches[2]));
@@ -162,9 +175,22 @@ if ($zpath == "/") {
//
/////////////////////////////////////////////////////////////////////////////////////////////
if ($type == "Disk image") {
$hdiutil = shell_exec("hdiutil imageinfo -plist ".$df_device." 2>&1");
foreach ($vdisks_parsed['images'] as $id => $disk) {
if ($disk['system-entities'][0]['dev-entry'] == $df_device) {
$image_file = $disk['image-path'];
}
}
} else {
$hdiutil = false;
$image_file = false;
}
if ($wopt_noprofile) {
$profile = "disabled";
} else {
echo msg("system_profiler");
$profile = shell_exec("system_profiler SPHardwareDataType SPStorageDataType SPThunderboltDataType SPUSBDataType 2>&1");
}
$qlmanage = shell_exec("qlmanage -m 2>&1");
@@ -203,13 +229,15 @@ $dbo->exec("CREATE TABLE _skim (
details TEXT,
qlmanage TEXT,
sysvers TEXT,
diskutil TEXT,
hdiutil TEXT,
disks TEXT,
df TEXT,
df_device TEXT,
df_volume TEXT,
mdutil TEXT,
diskutil TEXT,
vdisks TEXT,
hdiutil TEXT,
image_file TEXT,
df TEXT,
df_device TEXT,
df_volume TEXT,
mdutil TEXT,
profile TEXT,
status TEXT
)");
@@ -252,7 +280,7 @@ $dbo->exec("CREATE TABLE files (
contents_filename TEXT
)");
$stmt = $dbo->prepare("INSERT INTO _skim VALUES (:version, :opts, :host, :uid, :zpath, :bpath, :type, :passed_file, :passed_dir, :passed_link, :passed_total, :nodescended, :ignored, :dupes, :details, :qlmanage, :sysvers, :diskutil, :hdiutil, :disks, :df, :df_device, :df_volume, :mdutil, :profile, :status)");
$stmt = $dbo->prepare("INSERT INTO _skim VALUES (:version, :opts, :host, :uid, :zpath, :bpath, :type, :passed_file, :passed_dir, :passed_link, :passed_total, :nodescended, :ignored, :dupes, :details, :qlmanage, :sysvers, :disks, :diskutil, :vdisks, :hdiutil, :image_file, :df, :df_device, :df_volume, :mdutil, :profile, :status)");
$stmt->BindValue(":version",$version);
$stmt->BindValue(":opts",serialize($p));
$stmt->BindValue(":host",$host);
@@ -263,9 +291,11 @@ $stmt->BindValue(":type",$type);
$stmt->BindValue(":details",$dstring);
$stmt->BindValue(":qlmanage",$qlmanage);
$stmt->BindValue(":sysvers",$sysvers);
$stmt->BindValue(":diskutil",$diskutil);
$stmt->BindValue(":hdiutil",$hdiutil);
$stmt->BindValue(":disks",$disks);
$stmt->BindValue(":diskutil",$diskutil);
$stmt->BindValue(":vdisks",$vdisks);
$stmt->BindValue(":hdiutil",$hdiutil);
$stmt->BindValue(":image_file",$image_file);
$stmt->BindValue(":df",$df);
$stmt->BindValue(":df_device",$df_device);
$stmt->BindValue(":df_volume",$df_volume);
@@ -480,6 +510,9 @@ foreach ($family as $key => $item) {
echo ProgressBar::finish();
// create an index for family db
$dbo->exec("CREATE INDEX family_index ON family (pid)");
unset($dx, $dxo, $dupes);
// stats
@@ -781,7 +814,6 @@ if ($p['spotlight']) {
$mdls = shell_exec("mdls -plist - ".$shellpath." 2>&1");
if (substr_count(@$mdls,"\n") > 1) {
$parser = new plistParser();
$spotlight = $parser->parseString(utf8_for_xml($mdls));
} else {
$spotlight = array();
@@ -939,7 +971,7 @@ foreach ($files as $splFileInfo) {
$stmt->BindValue(":gfi_type",$writegfitype);
$stmt->BindValue(":gfi_attr",@$gfi['attributes']);
$stmt->BindValue(":gfi_created",strtotime($gfi['created']));
$stmt->BindValue(":gfi_created",strtotime(@$gfi['created']));
// ------------------------------------------------ //
@@ -1091,7 +1123,7 @@ while ($row_a = $loop->fetch()) {
$m['m']['SkimTrackCount'] = @count($decoded['File']['track']);
@foreach ($decoded['File']['track'] as $track) {
foreach (@$decoded['File']['track'] as $track) {
if (!@$m['m']['SkimDims'] && @$track['Width'] && @$track['Height']) {
$m['m']['SkimDims'] = sanitize($track['Width'],"i").$delimiter.sanitize($track['Height'],"i");
}
@@ -1174,7 +1206,8 @@ if ($p['rsync_dest']) {
echo ProgressBar::finish();
}
echo msg("Finished in ".$seconds." seconds");
$done = "Finished ".$zpath." in ".$seconds." seconds";
echo msg($done); ncenter($done);
unset($dbo, $dbp, $files, $family, $fx);