LaunchDaemon and startupitem
Eric F (iEFdev)
eric at iefdev.se
Mon Jan 21 08:58:10 UTC 2019
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
post-destroot {
xinstall -d -m 0755 ${destroot}${prefix}/etc/LaunchDaemons/${daemon_uniquename}
set plist [open "${destroot}${prefix}/etc/LaunchDaemons/${daemon_uniquename}/${daemon_uniquename}.plist" w 0644]
puts ${plist} "<?xml version='1.0' encoding='UTF-8'?>"
puts ${plist} "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\""
puts ${plist} "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">"
puts ${plist} "<plist version='1.0'>"
puts ${plist} "<dict>"
puts ${plist} " <key>Label</key>"
puts ${plist} " <string>${daemon_uniquename}</string>"
puts ${plist} " <key>ProgramArguments</key>"
puts ${plist} " <array>"
puts ${plist} " <string>${prefix}/sbin/${name}</string>"
puts ${plist} " </array>"
puts ${plist} " <key>StartCalendarInterval</key>"
puts ${plist} " <dict>"
puts ${plist} " <key>Day</key>"
puts ${plist} " <integer>20</integer>"
puts ${plist} " <key>Hour</key>"
puts ${plist} " <integer>10</integer>"
puts ${plist} " <key>Minute</key>"
puts ${plist} " <integer>10</integer>"
puts ${plist} " </dict>"
puts ${plist} "</dict>"
puts ${plist} "</plist>"
close ${plist}
xinstall -d -m 0755 ${destroot}/Library/LaunchDaemons
ln -s ${prefix}/etc/LaunchDaemons/${daemon_uniquename}/${daemon_uniquename}.plist ${destroot}/Library/LaunchDaemons
}
…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?
If I want to add logs? I can just use “/${prefix}/var/log/${name}/${name}.log"?
· Eric
On 1/21/19 7:59 , Joshua Root wrote:
> The startupitem.* options don't offer a lot of the options of launchd.
> If you need something like StartCalendarInterval, the best way is
> probably to create the plist and put it in the port's files directory.
> You then have to install it in the right place and set a couple options
> so 'port load' will find it.
>
> See the dbus port for an example of this. It actually installs 2 plists,
> one LaunchDaemon and one LaunchAgent. The former is generated in the
> Portfile with puts, I think because some of the content varies depending
> on OS version. The latter is from the dbus distfile.
>
> - Josh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macports.org/pipermail/macports-dev/attachments/20190121/97162274/attachment-0001.html>
More information about the macports-dev
mailing list