Last active
September 2, 2015 12:48
-
-
Save leeramsay/110babde61c87074c14e to your computer and use it in GitHub Desktop.
Bash script to parse installed Mac OS pkgs, and find any that have modified the default user template.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Find packages that have touched the default profile. | |
# Edit this to your org string for your packages. | |
# All your packages have a consistent org string, I hope! | |
# I'd suggest you pipe this script into more, or output to a text file for readability. | |
# EDIT ME | |
org="com.leeroy" | |
# User Template match | |
defprof="/System/Library/User Template" | |
# For packages that match our org string | |
for i in $(/usr/sbin/pkgutil --pkgs=^$org.*); do | |
# Look for the user template path in the bill of materials | |
if /usr/bin/grep -q "${defprof}" <<< $(/usr/sbin/pkgutil --lsbom "${i}"); then | |
# Formatting | |
echo -e '\n=======\n' "${i}" '\n=======\n' | |
# I couldn't remember how to store strings with newlines in variables in bash | |
# So I just ran an identical pkgutil command twice, oh the shame. | |
# I'm also only printing the relevant default profile parts of the package | |
# Remove the pipe into grep, if you want to see everything. | |
/usr/sbin/pkgutil --lsbom "${i}" | /usr/bin/grep "${defprof}" | |
fi | |
done | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment