macports-users Digest, Vol 122, Issue 2

James Linder jam at tigger.ws
Mon Oct 3 03:30:32 CEST 2016


> On 3 Oct 2016, at 3:00 AM, macports-users-request at lists.macosforge.org wrote:
> 
>> Over the years I?ve seen many clever people here, perchance one of them will cast an eye and say THERE . . .
>> 
>> I?m trying to run a rc.local at start up
>> I created a launchdaemon
>> 
>> haycorn:jam root# cat /Library/LaunchDaemons/local.startup.plist
>> <?xml version="1.0" encoding="UTF-8"?>
>> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
>> <plist version="1.0">
>> <dict>
>>   <key>Label</key>             <string>local.startup</string>
>>   <key>Disabled</key>          <false/>
>>   <key>RunAtLoad</key>         <true/>
>>   <key>KeepAlive</key>         <false/>
>>   <key>LaunchOnlyOnce</key>    <true/>
>>   <key>ProgramArguments</key>
>>     <array>
>>      	<string>/bin/bash</string>
>>      	<string>-c</string>
>>       <string>/etc/rc.local</string>
>>     </array>
>> </dict>
>> </plist>
>> 
>> It does not run. Following the launchd.info->troubleshooting www everything does run without complaint. 
>> (Im creating a ramdisk, but what ever is in rc.local)
>> haycorn:jam root# ls -l /etc/rc.local
>> -rwxr-xr-x  1 root  wheel  108  2 Oct 09:58 /etc/rc.local
>> haycorn:jam root# cat /etc/rc.local
>> #!/bin/bash
>> 
>> DISK_ID=$(hdiutil attach -nomount ram://204800)
>> diskutil erasevolume HFS+ "ramdisk" ${DISK_ID}
>> 
>> I?ve tried specifing <key>Program</key> and 644 permissions on rc.local
> 
> [Try again using the righ email.]
> 
> I?m no expect, but I don?t think you need the ?-c? parameter.  You already have a reference to a file.
> 
> You may also want to add keys to direct stdout and stderr to a file.  Ala:
> 
> <key>StandardOutPath</key>
> <string>/tmp/test.stdout</string>
> <key>StandardErrorPath</key>
> <string>/tmp/test.stderr</string>
> 
> I think the following web site is pretty good at explaining how to use launchd plists:
> 
> http://launchd.info
> 
> You can also check ?man launchd.plist? for a reference.

Craig thanks. I’ve been using the site (http://launchd.info), but it mentions not the -w flag Brandon spoke of.
The stdout keys don’t help, the launchd works perfectly if you run it (the -c flag: I agree but in desperation I tried).
My single issue is that *this* launchd does not run at boot time (where stdout is not shown). It runs correctly later and Brandon speculated subsystems are not ready yet so I did this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>             <string>local.startup</string>
    <key>Disabled</key>          <false/>
    <key>RunAtLoad</key>         <true/>
    <key>LaunchOnlyOnce</key>    <true/>
    <key>ProgramArguments</key>
      <array>
        <string>/etc/rc.local</string>
      </array>
    <key>KeepAlive</key>
    <dict>
        <key>SuccessfulExit</key>
        <false/>
    </dict>
</dict>
</plist>

It still works, but not at boot time.
Brandon you said that you had several boot launchd plists. May I see one please?
James


More information about the macports-users mailing list