Skip to content

Instantly share code, notes, and snippets.

@jaknz
Created August 18, 2015 23:30
Show Gist options
  • Save jaknz/649fb245e1cf9ce943ce to your computer and use it in GitHub Desktop.
Save jaknz/649fb245e1cf9ce943ce to your computer and use it in GitHub Desktop.
#!/bin/bash
# Change these to match your environment.
MANIFEST="standard"
REPONAME="munki_repo"
HOSTNAME="192.168.0.1"
USERNAME=$(who -m | awk {'print $1'})
if
[[ $EUID -ne 0 ]]; then
echo "This script must run as root. Please enter your password if required."
sudo $0
else
rm -rf /tmp/ClientInstaller/Library/Preferences/
mkdir -p /tmp/ClientInstaller/Library/Preferences/
/usr/bin/defaults write /tmp/ClientInstaller/Library/Preferences/ManagedInstalls.plist SoftwareRepoURL "http://$HOSTNAME/${REPONAME}"
/usr/bin/defaults write /tmp/ClientInstaller/Library/Preferences/ManagedInstalls.plist ClientIdentifier "$MANIFEST"
/bin/chmod ug+rwX,o+rX-w /tmp/ClientInstaller/Library/Preferences/ManagedInstalls.plist
mkdir -p /tmp/ClientInstaller/Users/Shared/
chmod -R a+rwxt /tmp/ClientInstaller/Users/
touch /tmp/ClientInstaller/Users/Shared/.com.googlecode.munki.checkandinstallatstartup
rm -f ~/Desktop/"ClientInstaller_$MANIFEST".pkg
/usr/bin/pkgbuild --identifier nz.co.tts.munki."$MANIFEST" --root /tmp/ClientInstaller ~/Desktop/"ClientInstaller_$MANIFEST".pkg
/usr/sbin/chown -R $USERNAME ~/Desktop/"ClientInstaller_$MANIFEST".pkg
rm -rf /tmp/ClientInstaller
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment