Posted on 06-09-2015 01:12 PM
Is there a way to call a script after a configuration profile has ran? I need to delete an old mobileconfig that was installed before JSS was installed, but only after the new profile is in place.
Thanks.
Posted on 06-09-2015 01:42 PM
You could create an extension attribute to see if the config is installed, then create a smart group from that and remove the old one. It may not be instantaneous, but it is an option.
Posted on 06-09-2015 02:33 PM
Another option is to just have a script that runs periodically and queries the profiles and deletes the old if the new one exists.
I wrote a script to find old WiFi profiles, might be helpful for ides. I changes WIFI_PROFILE_NAME in the awk statement form pur organisation specfic name.
#!/bin/bash
#Global Variable
STALE_DATE="2015-01-19"
STALE_DATE=$(echo $STALE_DATE | sed 's/[^0-9]*//g')
WIFI_PROFILES=$(Profiles -Lv | awk '/attribute: name:/ && / WIFI_PROFILE_NAME/,/attribute: profileIdentifier:/' | awk '/attribute: profileIdentifier:/ {print $4}')
for WIFI_PROFILE in $WIFI_PROFILES
do
echo Profile: $WIFI_PROFILE
WIFI_DATE=$(Profiles -Lv | sort -r | awk '/attribute: profileIdentifier: '$WIFI_PROFILE'/,/attribute: installationDate:/' | awk '/attribute: installationDate:/ {print $4}')
echo Install: $WIFI_DATE
WIFI_DATE=$(echo $WIFI_DATE | sed 's/[^0-9]*//g')
if [ $WIFI_DATE -lt $STALE_DATE ]
then
echo The profile "$WIFI_PROFILE" is STALE
echo Attempting to remove stale profile
profiles -R -p "$WIFI_PROFILE"
else
echo The profile "$WIFI_PROFILE" is CURRENT
fi
done
exit 0
Posted on 06-09-2015 02:35 PM
Just a code sample not a solution to your actual problem of course :) but a launchAgent/Daemon that looked for both profiles, deleted the one you wanted then disabled itself might work.