Skip to content

Instantly share code, notes, and snippets.

@peterkelm
Created May 19, 2020 20:23
Show Gist options
  • Save peterkelm/ffc2a29853d55ea45b80f621bc819d06 to your computer and use it in GitHub Desktop.
Save peterkelm/ffc2a29853d55ea45b80f621bc819d06 to your computer and use it in GitHub Desktop.
Want to know which pkgs files are referenced in which plists in a munki repository? Great, this script is for you!
#!/bin/bash
##########################################################################
#
# (c) 2020 KelmMoyles / Peter Kelm <info@kelmmoyles.com>
# All rights reserved
#
# Want to know which pkgs files are referenced in which plists?
# Great, this script is for you!
#
# Note that this does not show orphan plist files
# (which would be a simple comparison against 'ls <path_to_munki_repo>/pkginfo')!
#
# Output:
# 1) Lines that do not start with "<path_to_munki_repo>/pkgsinfo"
# indicate that that pkg isn't referenced in any plist file
# 2) Duplicate references of the same plist should typically not occur
# (except e.g. if you use the pkg name somewhere in a comment inside the plist)
#
##########################################################################
if [ "$#" -ne 1 ]; then
echo "usage: scrape-repo.sh <path_to_munki_repo>"
exit 0
fi
ls -1 "${1}/pkgs" | while read pkgs;
do
echo `grep --include=\*.plist -rnw "${1}/pkgsinfo" -e "${pkgs}"` "${pkgs}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment