Created
September 7, 2012 11:46
-
-
Save myhd/3665486 to your computer and use it in GitHub Desktop.
Script to connect to an AFP server when iTunes is running
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# This script will connect to an AFP server when iTunes is running | |
# 2012-09-07 | |
HOST="hostname" # AFP server, e.g. server.local or 192.168.1.94 or… | |
USER="your_user_name" # for connection to AFP server | |
PASS="your_password" # for connection to AFP server | |
VOLUMENAME="your_volume_name" # name of volume to be mounted, typically username on AFP server. | |
# No need to configure below ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
while : | |
do | |
if [[ $(ps axo pid,command | grep "/Applications/[i]Tunes.app/Contents/MacOS/iTunes ") ]]; then | |
if [ ! -d "/Volumes/${VOLUMENAME}" ]; then # iTunes runs, Server not mounted | |
echo "iTunes runs, now mounting ${VOLUMENAME}..." | |
mkdir "/Volumes/${VOLUMENAME}" | |
mount_afp afp://${USER}:${PASS}@${HOST}/${VOLUMENAME} "/Volumes/${VOLUMENAME}" | |
fi | |
fi | |
sleep 2 | |
done # start over |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment