Posted on 05-15-2024 08:26 PM
So, here's a thing:
Have you ever wished your users didn't try to use Migration Assistant? Maybe you have something better (Alectrona Migrator, Druva - that's what I used to use & it was the best...)
But, maybe, you just want to stop them. Yes, you can use Restricted Software. But, maybe, for some reason, the internet has led you here & you don't use Jamf, or, you don't want to use Restricted Software. Ta da.
#!/bin/sh
# write out blocking script
/bin/cat << 'EOF' > /opt/blk.migr.asst.sh
#!/bin/sh
if /usr/bin/pgrep -ail 'Migration Assistant'
then
/usr/bin/osascript -e "display dialog \"Migration Assistant is blocked on this computer. Please contact your administrator for help.\" buttons {\"OK\"} default button 1 with title \"Migration Assistant Blocked\" with icon file \"System:Library:CoreServices:CoreTypes.bundle:Contents:Resources:AlertStopIcon.icns\""
/usr/bin/pkill -ail 'Migration Assistant'
fi
EOF
/bin/chmod 755 /opt/blk.migr.asst.sh
/usr/sbin/chown 0:0 /opt/blk.migr.asst.sh
# write out launch daemon
/bin/cat << 'EOF' > /Library/LaunchDaemons/com.blk.migr.asst.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.blk.migr.asst</string>
<key>ProgramArguments</key>
<array>
<string>/bin/sh</string>
<string>/opt/blk.migr.asst.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
</dict>
</plist>
EOF
/bin/chmod 644 /Library/LaunchDaemons/com.blk.migr.asst.plist
/usr/sbin/chown 0:0 /Library/LaunchDaemons/com.blk.migr.asst.plist
/usr/bin/plutil -convert binary1 /Library/LaunchDaemons/com.blk.migr.asst.plist
# start launch daemon
/bin/launchctl bootstrap system /Library/LaunchDaemons/com.blk.migr.asst.plist
Posted on 05-16-2024 06:14 AM
I am both fascinated by this workflow, and feel I just watched an oxiclean commercial all at the same time.
05-16-2024 08:13 AM - edited 05-17-2024 09:36 AM
I had to look up oxiclean, rofl.
"Aaand just when you thought those dirty restricted items were taking toooo lonnng to update,
we created a powerful launchdaemon, which is loaded via bootstrap,
all before the exit of our oxidizing scriiiiiippptttt."
I think this is cool, thanks for sharing your work. Kudos