Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

macdong

macrumors 6502
Original poster
Mar 25, 2003
349
0
Seattle, WA
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.
 

chown33

Moderator
Staff member
Aug 9, 2009
10,747
8,420
A sea of green
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
 

macdong

macrumors 6502
Original poster
Mar 25, 2003
349
0
Seattle, WA
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 running but failing within the shell script itself?

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.
 

macdong

macrumors 6502
Original poster
Mar 25, 2003
349
0
Seattle, WA
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

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.
 

chown33

Moderator
Staff member
Aug 9, 2009
10,747
8,420
A sea of green
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.

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?
 

Guiyon

macrumors 6502a
Mar 19, 2008
771
4
Cambridge, MA
Is is a bundle-style package or a flat package? IIRC, Apple limits the autorun scripts to 'preinstall' and 'postinstall' in a flat package.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.