LaunchDaemon and startupitem

Joshua Root jmr at macports.org
Mon Jan 21 09:44:53 UTC 2019


On 2019-1-21 19:58 , Eric F (iEFdev) wrote:
> Thanks Josh! That looks interesting.
> 
> Yes, keep it as a file is prob the best, but if using puts, for the example.
> 
> Something like this then (based on the dbus example)?
> 
> set daemon_uniquename    org.macports.${name}
> 
> startupitem.type    launchd
> startupitem.create  no
> startupitems        name        dbus-system \
>                     location    LaunchDaemons \
>                     uniquename  ${daemon_uniquename} \
>                     plist       ${daemon_uniquename}.plist

Sure, that works. You don't have to use the 'startupitems' option unless
you have more than one startupitem. For a single one you could instead
set startupitem.name, startupitem.location, etc.

>     xinstall -d -m 0755 ${destroot}/Library/LaunchDaemons
>     ln -s ${prefix}/etc/LaunchDaemons/${daemon_uniquename}/${daemon_uniquename}.plist ${destroot}/Library/LaunchDaemons
> }

This check in dbus is important:

if {${startupitem.install} && [geteuid] == 0} {

You have to put the plist somewhere different if startupitem.install is
false.

> …where /“startupitem.create no”/ doesn't create anything, but the
> additional info makes it work within the system (ie. using port load)?
> Or did I misunderstand the usage?

Correct, 'startupitem.create no' means base will not create it, so you
can create it yourself. You then have to set startupitem.type because it
defaults to 'none' if one is not being created.

> If I want to add logs? I can just use
> “/${prefix}/var/log/${name}/${name}.log"?

That should be fine.

- Josh


More information about the macports-dev mailing list