Feoggou
Feoggou

Reputation: 149

Using scripts in PackageMaker (Mac OS X)

I'm trying to build an install package on Mac for my application(s) (there are two .app-s). One of them is a GUI and the other is an agent (service). The install package must run a script (that's the only way I know it can be done) at the end of the installation, so that the agent would be installed as an agent. There is also a .plist file that is installed in /Library/LaunchAgents, but that's what PackageMaker does automatically (ie without the need of a script).

The problem is that... I can't make the script run. I get "Installation failed" at the end. I don't know what the problem is. Can somebody please help?

A few more details:

with the following contents (without quotes):

"#!/bin/sh

sudo launchctl load /Library/LaunchAgents/com.MyCompany.MyService.plist"

(note that com.Mycompany.MyService.plist is already there - it puts it there on install).

P.S. In some of my attempts to make it work, PackageMaker crushed.

Can anybody PLEASE help?

Upvotes: 2

Views: 2151

Answers (2)

Aleksandr Kravets
Aleksandr Kravets

Reputation: 5947

I had such experience myself. And here's what i've found out. In order for installation to succeed your sript must explicitly return 0(i.e. 'success'). If result of commands in your script is not 0 and you aren't calling

exit 0

as last script sentense, your install will tell you it failed.

If you don't use script's return value and you are sure scrpit works correct - just add 'exit 0' at the last line of script.

Upvotes: 0

Laurent Etiemble
Laurent Etiemble

Reputation: 27929

You can look at the installation log.

When the Installer application is running, go to the Window menu and select Installation Log. This will open a separate log window. In this window, select Display All from the combo box. You will be able to see why your script is failing.

Upvotes: 2

Related Questions