Last active
December 15, 2015 16:03
-
-
Save outsidecontext/c08739f42e60da469984 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/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