PackageMaker Postflight Doesn't Run

Discussion in 'Mac Programming' started by macdong, Aug 30, 2010.

  1. macrumors 6502

    macdong

    Joined:
    Mar 25, 2003
    Location:
    Seattle, WA
    #1
    I have a package that installs an application and a plist for launch daemon. The installation works just fine, but the preflight/postflight scripts won't run. The script are named preflight and postflight, executable bit is set, just don't know what I missed. I am using PackageMaker 3.0.4 under OS X 10.6. The postflight script is as below:

    #!/bin/sh
    /bin/launchctl load /Library/LaunchDaemons/com.mycompany.myapp.plist
    exit 0

    Thanks for any help.
     
  2. macrumors 603

    Joined:
    Aug 9, 2009
    #2
    Obvious question: How do you know the postflight doesn't run?
    That is, what is your evidence that it doesn't run, as distinct from it running but failing within the shell script itself?

    Have you tried a diagnostic postflight (or preflight) script, such as:
    Code:
    #!/bin/bash
    echo "$@"
    exit 0
    
     
  3. thread starter macrumors 6502

    macdong

    Joined:
    Mar 25, 2003
    Location:
    Seattle, WA
    #3
    Well, i've verified that the script actually runs fine from Terminal, and I was watching the console for any log my app generates, and there is nothing. But you are right, I should put an echo in there to see if it's getting called and failed or not getting called at all.
     
  4. thread starter macrumors 6502

    macdong

    Joined:
    Mar 25, 2003
    Location:
    Seattle, WA
    #4
    Thanks for pointing out the obvious, the script does get called. But my problem still remains, if a different one. Why does the script work in Terminal, but not as a postflight script? It's a straight forward one-liner.
     
  5. macrumors 603

    Joined:
    Aug 9, 2009
    #5
    Once again, how do you know it doesn't work? What is your evidence?

    Does launchctl return a failure exit status? Is the launchd job notably absent when you check for it afterwards?

    What userid are you running the postflight script under? If it's root, then launchctl will target the init process (pid 1), not the current user's login process. If it's not root, then non-root users can't start or stop shared daemons.

    If you're checking with launchctl, what userid is it running as?
     
  6. macrumors 6502a

    Joined:
    Mar 19, 2008
    Location:
    North Shore, MA
    #6
    Is is a bundle-style package or a flat package? IIRC, Apple limits the autorun scripts to 'preinstall' and 'postinstall' in a flat package.
     

Share This Page