Skip to content

Instantly share code, notes, and snippets.

@hfike
Created February 26, 2014 17:42
Show Gist options
  • Save hfike/9234530 to your computer and use it in GitHub Desktop.
Save hfike/9234530 to your computer and use it in GitHub Desktop.
#!/bin/bash
# From Allister, modified by Harry Fike 9-27-13
# Will install the trust profile, even though it claims it won't
# This script will apply all CONFIGURATION/enrollment (not trust) profiles in the 'profiles' folder as if it's a payload-free package
# ASSUMPTIONS:
# 1. All .mobileconfig Payload Scope's are system and NOT TRUST PROFILES
# 2. Installation is by user with elevated privileges (admin/sudo is fine)
# Version 0.1
set -x
SCRIPT_DIR="$1/Contents/Resources"
OURLOG="$3/private/var/log/profileAdHocApply.log"
PROFILESDIR="$3/var/db/ConfigurationProfiles"
declare -x profiles="/usr/bin/profiles"
declare -x ditto="/usr/bin/ditto"
# Simple exit handler
die(){
echo "$1 Failed."
exit 1
}
# Sanity checks
# Check running as root
if [ ! $EUID -eq 0 ] ; then
die "Root"
fi
# Check running on booted volume
if [ "$3" != "/" ] ; then
for PROFILE in $SCRIPT_DIR/profiles/*.mobileconfig ; do
echo "Applying Profile: $PROFILE" >> "$OURLOG"
$profiles -IvF "$PROFILE" >> "$OURLOG" ||
die "$PROFILE"
done
else
/bin/mkdir -p "$PROFILESDIR/Setup" || return 1
$ditto $SCRIPT_DIR/profiles/ "$PROFILESDIR/Setup"
/usr/sbin/chown -R root:wheel "$PROFILESDIR/Setup"
/bin/chmod -R 755 "$PROFILESDIR/Setup"
/bin/rm "$PROFILESDIR/Setup/.profileSetupDone"
fi
exit 0
@arubdesu
Copy link

https://gist.github.com/hfike/9234530#file-gistfile1-txt-L30 My bad, the logic is wrong on that line...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment