Last active
July 11, 2017 07:08
-
-
Save 607011/6df0ae004c79108b273274cc528b14f9 to your computer and use it in GitHub Desktop.
Get a password from the macOS key chain
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 | |
SRCDIR=$HOME/PUT_SOURCE_DIRECTORY_HERE | |
DSTDIR=$HOME/PUT_DESTINATION_DIRECTORY_HERE | |
REMOTE_SHARE=PUT_SERVER_NAME_HERE/PUT_NAME_OF_SHARE_HERE | |
KEYCHAIN_SERVICE_TOKEN=CHANGE_TO_NAME_OF_SERVICE_AS_STORED_IN_KEYCHAIN | |
USERNAME=ola | |
PASSWORD=$(security find-generic-password -s $KEYCHAIN_SERVICE_TOKEN -w) | |
if [ ! -d "$DSTDIR" ]; then | |
mkdir -p $DSTDIR | |
fi | |
if ! mount | fgrep "on $DSTDIR" > /dev/null; then | |
mount_smbfs -s //$USERNAME:$PASSWORD@$REMOTESHARE $DSTDIR | |
fi | |
rsync --exclude .git --exclude .DS_Store -vrlptgoD $SRCDIR $DSTDIR | |
umount $DSTDIR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment