2

Following is my sample.sh in /usr/local/bin/

#!/bin/sh
mkdir -p /Volumes/folder
mount -t afp -o rw afp://user:password@server_name/folder_name /Volumes/folder

Following is my com.apple.sample.plist in /Library/LaunchAgents/

 ?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>com.apple.sample</string>
        <key>ProgramArguments</key>
        <array>
    <string>/usr/local/bin/sample.sh</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
</dict>
</plist>

Where as when I am able to run sample.sh independently and is working fine.

Also I have tried using launchd.conf as

mkdir -p /Volumes/folder
mount -t afp -o rw afp://user:password@server_name/shared_folder /Volumes/folder

Still not working.

Tanmay
  • 121

1 Answers1

0

/Library/LaunchAgents/ are tied to individual users where as /Library/LaunchDaemons/ are tied to the machine as a whole. After the system is booted and the kernel is running, property list files found in /Library/LaunchDaemons/ are loaded first as these are system-level daemon.

I tried to put my com.apple.sample.plist in /Library/LaunchDaemons/ and it worked. Mounting was successful.

But it worked 8 times out of 10. It failed 2 times.

Tanmay
  • 121