A few things happened recently.. I was asked to prepare a number of iPads that would be shared amongst a number of users, so that each user would have a clean iPad, the so called cleaning needed to be quick and easy, so that a classroom teacher could do it at the end of class. I also needed to be certain the students would not accidently leave things behind.. like email accounts.. iTunes accounts.. or passcodes.. sounds like fun..
Then I saw a really cool podcast on different approaches to working with a fleet of mobile devices. There was some kind of tool mentioned that showed a way to lets call it re-image a mobile device in the same way you might re-image a lab computer. Perfect! I need this tool.. I made contact with the vendor and attempted to purchase for the organisation I work for.. Then I was told I can’t buy it.. It’s not available for purchase.
So feeling sorry for myself for a while – how am I going to get this project done.. I was reminded I had a software engineering degree.. Maybe I could re-invent the wheel. Let’s think about this.. in iTunes there is a handy feature to back up my iPhone or insert device here. I always make sure I back up the backups of my iPhone, which are available in ~/Library/Application Support/MobileSync/Backup
So I have a copy of what I want on each iPad, but damned if I know how to write a whole lot of files across to a USB device.. i can’t excactly go cat file > “Lisa’s iPad”, but iTunes does know how to do this….
Let’s try and figure out how iTunes is doing this.. Open Activity Monitor and display the processes hierarchically.. this will let us see all the processes started by iTunes, and you got it… Choose the option to restore my iPhone/iPad/insert device….
Very briefly another process appears.. but doesn’t stay visible long enough for me to grab a sample or click the button in Activity Monitor to grab the open files listing to know where its hiding. So I have a pretty good idea of what the process might be called.. but where does it live?
My good friend Terminal and lsof – an awesome tool to give you a list of the open files at a point in time. So let’s restore my iPad again and have terminal ready to press enter on lsof. On the second try I pressed enter fast enough to get a massive long listing of open files (hint close everything else on your computer to make this list shorter.. lol).
Eventually I find a very long path hidden in the /System directory with the same name as our mystery iTunes process…
Bring back terminal!
cd to the directory we just found and let’s try running the command, and we get the super friendly output:
AppleMobileBackup[9149:903] ERROR: No action specified on command-line
crap.. what now.. there is no man page.. hmm time to start guessing..
part of the output included this:
Now to start playing…. game on! I’ll re-invent the wheel yet.. and if I do it my way.. it’s going to have awesome rims!