Install terminal-notifier
$ brew install terminal-notifier
Create Automator App which automatically mount afp volume
Automator enables a shell script to run silently.
Content of shell script
function mount_afp_volume()
{
host=HOSTNAME_OR_IPADDRESS
username=AFP_USERNAME
password=AFP_PASSWORD
mount_point=$1
if [ ! -d /Volumes/$mount_point ]
then
mkdir -p /Volumes/$mount_point
mount_afp afp://$username:$password@$host/$mount_point /Volumes/$mount_point
/usr/local/bin/terminal-notifier -title "Mount" -message "/Volumes/"$mount_point" is now mounted." -sound Submarine
fi
}
mount_afp_volume Data
mount_afp_volume TimeMachine
Install SleepWatcher
$ brew install SleepWatcher
==> Downloading http://www.bernhard-baehr.de/sleepwatcher_2.2.tgz
######################################################################## 100.0%
==> mv ../sleepwatcher.8 .
==> make install PREFIX=/usr/local/Cellar/sleepwatcher/2.2
.
.
.
$ /usr/local/sbin/sleepwatcher
$ sudo cp /usr/local/Cellar/sleepwatcher/2.2/de.bernhard-baehr.sleepwatcher-20compatibility.plist /Library/LaunchDaemons/de.bernhard-baehr.sleepwatcher.plist
$ launchctl load /Library/LaunchDaemons/de.bernhard-baehr.sleepwatcher.plist
$ cat /Library/LaunchDaemons/de.bernhard-baehr.sleepwatcher.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>de.bernhard-baehr.sleepwatcher</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/sbin/sleepwatcher</string>
<string>-V</string>
<string>-s /usr/local/etc/sleepwatcher/rc.sleep</string>
<string>-w /usr/local/etc/sleepwatcher/rc.wakeup</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
</dict>
</plist>
$ sudo cat >> /usr/local/etc/sleepwatcher/rc.wakeup << EOF
# Mount AFP Volume
sleep 5
open -a /Users/gumob/Applications/mount_all.app
EOF