Posted on 01-28-2015 01:01 PM
So we're in a situation where we need to setup a headless mac mini in a hospital environment that triggers an email to myself whenever a device is connected via USB so that I can remotely restore a backup to the iOS devices via configurator...does anyone know what such a script would look like? I have no clue where to even start.
Posted on 01-28-2015 01:16 PM
I'm thinking that if you create a LaunchDaemon to listen to the /Volumes/ folder, then run a script to perform: [code]diskutil info UNTITLED/ | awk '/Protocol: / {print $2}'[/code] If the result is "USB", then send an email. Should be plenty of bash/python examples to send emails... and Lingon can help with the "Listen" part for /Volumes/
- Justin
Posted on 01-28-2015 01:29 PM
The problem with that is that iOS devices don't show up in Volumes. Im not sure where they would show up as connected devices.
Posted on 01-28-2015 01:47 PM
usbmuxd handles iOS communication directly, it never actually mounts as a connected device.
Posted on 01-28-2015 03:41 PM
Not sure if there is a possible trigger for it, but (assuming it's an iPad) you can use:
system_profiler SPUSBDataType | grep -c iPad
The number returned would be the number of iPads connected to the USB bus.
If there isn't a reliable monitoring method you could have the script run on a regular schedule (something like every 15 minutes).
Regarding the email part, you could use sendMail, details on this are available here: http://www.amsys.co.uk/2014/blog/get-sendemail-working-yosemite-and-mavericks/#.VMlzFV6sVDw.
Alternatively you could see if you could leverage a smart group with Casper's built-in email notification system. You might need to write the value using the API though.