Skip to content

Instantly share code, notes, and snippets.

@outsidecontext
Last active December 15, 2015 16:03
Show Gist options
  • Select an option

  • Save outsidecontext/c08739f42e60da469984 to your computer and use it in GitHub Desktop.

Select an option

Save outsidecontext/c08739f42e60da469984 to your computer and use it in GitHub Desktop.
#!/bin/bash
# mounts a volume over afp and syncs from local to mount
# reads in computer, username and password as args
# change {SYNC_FROM} and {SYNC_TO}
while echo $1 | grep -q ^-; do
eval $( echo $1 | sed 's/^-//' )=$2
shift
shift
done
echo computer = $computer
echo user = $user
echo pass = $pass
#change to working directory
dir=${0%/*}
if [ -d "$dir" ]; then
cd "$dir"
fi
name=FANSHEN
mount_point=/Volumes/$name
syncfrom={SYNC_FROM}
syncto=/Volumes/$name/{SYNC_TO}
# remote mount address
mount_address=afp://$user:$pass@$computer.local/$computer
if [ "$test" != "$mount_point" ]
then
mkdir $mount_point
echo "mounting $mount_point"
mount_afp -i $mount_address $mount_point
else
echo "$mount_point is already mounted"
fi
mkdir $syncto
rsync --verbose --progress --stats --compress --recursive --times --perms --links --delete --exclude "*.xml" $syncfrom $syncto
umount $mount_point
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment