Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ This script is based upon the Demonstration Setup Guide for Munki, AutoPKG, and

###Changelog

**NEW in 0.5.1 **

• Adoption of main branch changes for Munki2

**NEW in 0.5.0 beta**

• Installs Munki2 instead of Munki
• Also installs the munkireport-php plist as part of site_default

**NEW in 0.4.1:**

• Munki install code now based on Choices XML and is version independent.
Expand Down
50 changes: 30 additions & 20 deletions munkiinabox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Munki In A Box
# By Tom Bridge, Technolutionary LLC

# Version: 0.4.0
# Version: 0.6.0 - Munki 2 Edition

# This software carries no guarantees, warranties or other assurances that it works. It may wreck your entire environment. That would be bad, mmkay. Backup, test in a VM, and bug report.

Expand All @@ -13,7 +13,7 @@

# This script is based upon the Demonstration Setup Guide for Munki, AutoPKG, and other sources. My sincerest thanks to Greg Neagle, Tim Sutton, Allister Banks, Rich Trouton, Charles Edge, Hannes Juutilainen, Sean Kaiser, Peter Bukowinski and numerous others who have helped me assemble this script.

# Pre-Reqs for this script: 10.8/Server 2 or 10.9/Server 3. Web Services should be turned on.
# Pre-Reqs for this script: 10.8/Server 2 or 10.9/Server 3. Web Services should be turned on and PHP should be enabled.

# Establish our Basic Variables:

Expand Down Expand Up @@ -67,9 +67,8 @@ if

[[ ! -f $MUNKILOC/munkiimport ]]; then
${LOGGER} "Installing Munki Tools Because They Aren't Present"
curl -L https://munkibuilds.org/munkitools-latest.dmg -o $REPOLOC/munkitools.dmg
hdiutil attach $REPOLOC/munkitools.dmg -nobrowse -mountpoint /Volumes/munkitools

curl -L https://munkibuilds.org/munkitools2-latest.pkg -o $REPOLOC/munkitools2.pkg

# Write a Choices XML file for the Munki package. Thanks Rich and Greg!

/bin/cat > "/tmp/com.github.munki-in-a-box.munkiinstall.xml" << 'MUNKICHOICESDONE'
Expand Down Expand Up @@ -112,8 +111,8 @@ if
</plist>
MUNKICHOICESDONE

/usr/sbin/installer -dumplog -verbose -applyChoiceChangesXML /tmp/com.github.munki-in-a-box.munkiinstall.xml -pkg "$(/usr/bin/find /Volumes/munkitools -maxdepth 1 \( -iname \*\.pkg -o -iname \*\.mpkg \))" -target "/"

/usr/sbin/installer -dumplog -verbose -applyChoiceChangesXML /tmp/com.github.munki-in-a-box.munkiinstall.xml -pkg $REPOLOC/munkitools2.pkg -target "/"
${LOGGER} "Installed Munki Admin and Munki Core packages"
echo "Installed Munki packages"

Expand Down Expand Up @@ -173,7 +172,7 @@ mkdir ${REPONAME}/pkgs
mkdir ${REPONAME}/pkgsinfo

chmod -R a+rX ${REPONAME}
chown -R :admin ${REPONAME}
chown -R :wheel ${REPONAME}

${LOGGER} "Repo Created"
echo "Repo Created"
Expand All @@ -197,7 +196,7 @@ mkdir -p /tmp/ClientInstaller/Library/Preferences/
HOSTNAME=`/bin/hostname`
${DEFAULTS} write /tmp/ClientInstaller/Library/Preferences/ManagedInstalls.plist SoftwareRepoURL "http://$HOSTNAME/${REPONAME}"

/usr/bin/pkgbuild --identifier com.munkibox.client.pkg --root /tmp/ClientInstaller ClientInstaller.pkg
/usr/bin/pkgbuild --identifier com.munkiinabox.client.pkg --root /tmp/ClientInstaller ClientInstaller.pkg

${LOGGER} "Client install pkg created."
echo "Client install pkg is created. It's in the base of the repo."
Expand Down Expand Up @@ -295,14 +294,14 @@ done

cd ${REPOLOC}
git clone https://github.com/seankaiser/automation-scripts.git
mv automation-scripts/autopkg/autopkg-wrapper.sh ${SCRIPTDIR}
mv automation-scripts/autopkg/com.example.autopkg-wrapper.plist /Library/LaunchDaemons/${AUTOPKGORGNAME}.autopkg-wrapper.plist

cd ${SCRIPTDIR}

cd ./automation-scripts/autopkg/
sed -i.orig "s|>autopkg|>${ADMINUSERNAME}|" com.example.autopkg-wrapper.plist
sed -i.orig2 "s|com.example.autopkg-wrapper|${AUTOPKGORGNAME}.autopkg-wrapper|" com.example.autopkg-wrapper.plist
sed -i.orig "s|AdobeFlashPlayer.munki|${AUTOPKGRUN}|" autopkg-wrapper.sh
sed -i.orig2 "s|you@yourdomain.net|${AUTOPKGEMAIL}|" autopkg-wrapper.sh
sed -i.orig3 "s|user=[\"]autopkg[\"]|user=\"${ADMINUSERNAME}\"|" autopkg-wrapper.sh
mv autopkg-wrapper.sh ${SCRIPTDIR}
mv com.example.autopkg-wrapper.plist /Library/LaunchDaemons/${AUTOPKGORGNAME}.autopkg-wrapper.plist

launchctl load /Library/LaunchDaemons/${AUTOPKGORGNAME}.autopkg-wrapper.plist

Expand All @@ -312,11 +311,12 @@ launchctl load /Library/LaunchDaemons/${AUTOPKGORGNAME}.autopkg-wrapper.plist

####

curl -L https://github.com/hjuutilainen/munkiadmin/releases/download/v0.3.0/MunkiAdmin-0.3.0.dmg -o $REPOLOC/munkiadmin.dmg
hdiutil attach $REPOLOC/munkiadmin.dmg -nobrowse
cd /Volumes/MunkiAdmin-0.3.0/
cp -R /Volumes/MunkiAdmin-0.3.0/MunkiAdmin.app /Applications/Utilities
hdiutil detach /Volumes/MunkiAdmin-0.3.0 -force
cd ${REPOLOC}
VERS=`curl https://github.com/hjuutilainen/munkiadmin/releases/latest | cut -c 93-97` ; curl -L https://github.com/hjuutilainen/munkiadmin/releases/download/v$VERS/munkiadmin-$VERS.dmg -o $REPOLOC/munkiadmin.dmg
TMPMOUNT2=`/usr/bin/mktemp -d /tmp/munkiadmin.XXXX`
hdiutil attach $REPOLOC/munkiadmin.dmg -mountpoint "$TMPMOUNT2" -nobrowse
cp -R $TMPMOUNT2/MunkiAdmin.app /Applications/Utilities
hdiutil detach "$TMPMOUNT2" -force

####

Expand Down Expand Up @@ -345,7 +345,17 @@ echo "short_open_tag = On" >> ${PHPROOT}/php.ini
echo "\$auth_config['root'] = '\$P\$BSQDsvw8vyCZxzlPaEiXNoP6CIlwzt/';" >> munkireport-php/config.php

# This creates a user "root" with password "root"
# Now to download the pkgsinfo file into the right place and add it to the catalogs and site_default manifest:

echo "Downloading the MunkiReport Info"

curl -L http://$HOSTNAME/munkireport-php/index.php?/install/plist -o ${REPODIR}/pkgsinfo/MunkiReport.plist

echo "Downloaded the MunkiReport Info, Now Rebuilding Catalogs"

/usr/local/munki/makecatalogs

${MANU} add-pkg munkireport --manifest site_default

####

Expand All @@ -354,7 +364,7 @@ echo "\$auth_config['root'] = '\$P\$BSQDsvw8vyCZxzlPaEiXNoP6CIlwzt/';" >> munkir
####

rm $REPOLOC/autopkg-latest1.pkg
rm $REPOLOC/munkitools.dmg
rm $REPOLOC/munkitools2.pkg
rm $REPOLOC/munkiadmin.dmg

${LOGGER} "I put my toys away!"
Expand Down