-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_munki_single_item_install_manifests.sh
53 lines (33 loc) · 1.56 KB
/
create_munki_single_item_install_manifests.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
# create_munki_single_item_install_manifests.sh
# create single item manifests from all Munki items that are not update_for
echo "CREATING SINGLE-ITEM INSTALL MANIFESTS FOR MUNKI..."
munkiRepoDir="/path/to/munki/repo"
scanDir="$munkiRepoDir/pkgsinfo"
dirToCreateManifests="$HOME/Desktop/munki_single_item_install_manifests"
addCatalog=REQUIRED_CATALOG_NAME
mkdir -p -m 0777 "$dirToCreateManifests"
IFS=$'\n'
getPkgsInfoFiles=$(find "$scanDir" -type f) # use additional egrep -v (|) here to skip unwanted items
echo "COLLECTING MUNKI-ITEM-NAMES..."
getMunkiItemNames=$(for item in $getPkgsInfoFiles; do if defaults read "$item" update_for >/dev/null 2>&1 ; then continue; fi; defaults read "$item" name 2>/dev/null; done | sort -u )
for munkiItem in $getMunkiItemNames
do
echo "PRODESSING MUNKI-ITEM: $munkiItem"
if ! defaults read "$dirToCreateManifests/$munkiItem" managed_installs 2>/dev/null | grep -q -w -o "$munkiItem"
then
defaults write "$dirToCreateManifests/$munkiItem" managed_installs -array-add "$munkiItem"
fi
# add a catalog if needed
if ! defaults read "$dirToCreateManifests/$munkiItem" catalogs 2>/dev/null | grep -q -w -o "$addCatalog"
then
defaults write "$dirToCreateManifests/$munkiItem" catalogs -array-add "$addCatalog"
fi
plutil -convert xml1 "$dirToCreateManifests/$munkiItem.plist"
# needed if pkginfo needs no .plist ending
# mv "$dirToCreateManifests/$munkiItem.plist" "$dirToCreateManifests/$munkiItem"
done
# ensure that all users can at least read the results
chmod -R a+rX "$dirToCreateManifests"
echo "ALL DONE."
exit 0