Skip to content

Commit

Permalink
Update the postinstall script for the Spotlight plugin to work proper…
Browse files Browse the repository at this point in the history
…ly when installing for a single user.
  • Loading branch information
shysaur committed Jan 21, 2019
1 parent 45b694b commit f04a485
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions WindowsAppsImporter/PackageResources/Scripts/postinstall
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
#!/bin/bash -x
whoami
macosv=($(sw_vers -productVersion | sed 's/\./ /g'))
echo macos version ${macosv[*]}
if [[ ${macosv[1]} -gt 12 ]]; then
com='/usr/bin/mdutil -r '
run_as_root=1
else
com='/usr/bin/mdimport -d3 -r '
fi;
su $USER -c "${com}$2/Library/Spotlight/WindowsAppsImporter.mdimporter; echo returned \$?";
run_as_root=0
fi
if [[ ( "$EUID" -eq 0 ) && ( "$run_as_root" -eq 0 ) ]]; then
su $USER -c "${com}$2/Library/Spotlight/WindowsAppsImporter.mdimporter; echo returned \$?";
else
${com}$2/Library/Spotlight/WindowsAppsImporter.mdimporter
echo returned $?;
fi
exit 0

0 comments on commit f04a485

Please sign in to comment.