ShellScripts

Latest

  • Maniacally cuckoo for Mountain Lion: App Store checker shell script

    by 
    Erica Sadun
    Erica Sadun
    07.24.2012

    In the spirit of Tim Cook's maniacal excitement about upcoming Apple products, I bring to you the shell script you can run repeatedly from the command line to check the App Store to see if Mountain Lion is ready for purchase. This is what I used last year to check for Lion; it worked. This year, I update the search string to "Mountain Lion" instead. As presented, it employs a 10-minute time-out, so you can run a repeat command with it. #! /bin/csh curl -silent -A "iMacAppStore/1.0.1 (Macintosh; U; Intel Mac OS X 10.6.7; en) AppleWebKit/533.20.25" 'http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewMultiRoom?fcId=489264329&mt=12' | grep -i "mountain lion" > /dev/null if ($? == 0) then echo "Available" say "MOUNTAIN LION MAY BE AVAILABLE" else echo "Nada" endif sleep 600 Ready to improve the script? Have at it, campers! Update: Looks like the URL changed from last year. Updated via Mark (mcackay).

  • SDK devsugar: Re-signing applications

    by 
    Erica Sadun
    Erica Sadun
    02.09.2010

    TUAW's devsugar series helps introduce developers to tools and tricks that they might not yet be familiar with. Today's tip centers on signing already-compiled and already-signed applications with a new custom signature. A while back, I posted about a way to sign already-compiled applications with your personal credentials in order to better allow developer-to-developer distribution. By re-signing an application, it allows you to install it on any of the devices you have registered to your account at Apple without having to go through the fuss and bother of normal ad-hoc distribution. In addition, it makes it easier to develop applications on a contractor's machines, to ship them to a client, and then have them signed and shipped to App Store using the client's identity. A basic command-line solution is as follows. It calls codesign (found in /usr/bin) to sign the application, using the default keychain item that matches "iPhone Developer". It's a handy script, especially for informal beta distributions. #! /bin/bash export CODESIGN_ALLOCATE=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate codesign -f -s "iPhone Developer" $1 There are, however, several problems with this approach. First, it assumes you only want to sign with development (typically "Debug build") credentials. That's not going to work if you need to re-sign for distribution. (Solution? Change iPhone Developer to iPhone Distribution). Second, it assumes you only have one developer or distribution profile in your keychain. (Solution? Change iPhone Developer, for example, to iPhone Developer: Company Name to exactly match just one keychain entry.) Third, it assumes the person doing the re-signing knows how to use a command line. For that, the solution is a little more complicated. Recently, this topic came up on a developer e-mail list that I moderate: how do you make it easier for a non-technical client to re-sign an application, normally for distribution. As a solution, I put forth the proposal that one could embed the above shell script behavior into an AppleScript droplet. After consulting with a few colleagues, and gathering their requirements, I decided to give the project a try. I built an AppleScript application that signs any application dropped onto it. You can find a working copy of the application at my website. App Signer iterates through any apps dropped onto it, checks to ensure whether each file (or bundle, really) ends with an ".app" extension, and then attempts to sign those files using /usr/bin/codesign. Users can choose to sign with Developer credentials, Distribution credentials, or select Other to open a prompt and enter text for keychain disambiguation. (See the screen shot at the top of this post for an example of the disambiguation dialog.) The application displays results for each application, one at a time. Please note the following caveats: I make no attempt to guarantee that the app dropped onto this utility is actually an iPhone app (rather than, say a Macintosh application). When working with on-device keychains, the identity used to sign the application has to match the application id set forth in the Info.plist file for the application, otherwise keychain access will fail. This is a free application. It is offered under the BSD license. Use it at your own risk. Credit always appreciated. The open source github repository for App Signer can be found here. To create the application, open the AppleScript source in Script Editor and choose File > Save As > File Format: Application.