I've read through the man pages for plist and launchd.plist, as well as posts about using plist files to run scripts at login; but I can seem to get things working.
My script location and permissions:
sshfs_mounts.sh
:
ls -al Library/scripts/
-rwxr-xr-x 1 jason staff 288 May 10 17:06 sshfs_mounts.sh
cat Library/scripts/sshfs_mounts.sh
#!/bin/bash
#
## automounting of sshfs directories
mount_cosmic ()
{
/usr/local/bin/sshfs [email protected]:/media/NetworkShare/spacedock-1 /Users/jason/share;
}
mount |grep "/Users/jason/share/"
if [ $? == 1 ] && [ -d "/Users/jason/share" ] && [ $USER == "jason" ]; then
mount_cosmic
fi
EDITED FROM ORIGINAL POST:
If I run the script manually, it executes as expected. I can load the plist (launchctl load ~/Library/LaunchAgents/local.sshfs.plist
) and launch it (launchctl start ~/Library/LaunchAgents/local.sshfs
), but it does not run the script. In the logs (cat /var/log/system.log |grep local.sshfs
) I get:
May 11 09:30:26 rover com.apple.launchd.peruser.504[305] (local.sshfs.plist): Throttling respawn: Will start in 10 seconds
Here's my location and permissions for the plist file:
ls -al Library/LaunchAgents/local.sshfs.plist
-rw-r--r-- 1 jason staff 419 May 10 18:14 Library/LaunchAgents/local.sshfs_mounts.plist
And the file (EDITED after taking Gordon's advice^2):
<?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>KeepAlive</key>
<true/>
<key>Label</key>
<string>local.sshfs.plist</string>
<key>ProgramArguments</key>
<array>
<string>/bin/sh</string>
<string>/Users/jason/Library/scripts/sshfs_mounts.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StandardErrorPath</key>
<string>/tmp/sshfs_mounts.err</string>
<key>StandardOutPath</key>
<string>/tmp/sshfs_mounts.out</string>
</dict>
</plist>
Mahalo in advance.