Correct problems with using Keychain for backup drive credentials
This commit is contained in:
+7
-9
@@ -1,21 +1,19 @@
|
||||
#!/bin/bash
|
||||
#!/bin/bash -x
|
||||
|
||||
function die {
|
||||
echo $*; exit 1
|
||||
}
|
||||
LOCAL_MOUNT="$HOME/.backup-drive"
|
||||
|
||||
HOST=$(security find-generic-password -a $USER -s backup-host -w)
|
||||
SHARE=$(security find-generic-password -a $USER -s backup-share -w)
|
||||
USERNAME=$(security find-generic-password -a $USER -s backup-username -w)
|
||||
PASSWORD=$(security find-generic-password -a $USER -s backup-password -w)
|
||||
DRIVE="afp://$USERNAME:$PASSWORD@$HOST/$SHARE"
|
||||
DRIVE=$(cat ~/.backup-cred)
|
||||
|
||||
if ! mount | grep -q "$HOME/$LOCAL_MOUNT"; then
|
||||
[[ "$DRIVE" == "" ]] && die "[$(date)] Could not find ~/.backup-cred"
|
||||
|
||||
if ! mount | grep -q "$LOCAL_MOUNT"; then
|
||||
if [[ -e "$LOCAL_MOUNT" ]]; then
|
||||
rm -rf "$LOCAL_MOUNT" || die "Could not mount to $LOCAL_MOUNT"
|
||||
rmdir "$LOCAL_MOUNT" >/dev/null &2>1 || die "[$(date)] Could not mount to $LOCAL_MOUNT"
|
||||
fi
|
||||
mkdir -p "$LOCAL_MOUNT"
|
||||
mount -t afp "$DRIVE" "$LOCAL_MOUNT" || die "Could not mount from $DRIVE"
|
||||
mount -t afp "$DRIVE" "$LOCAL_MOUNT" || die "[$(date)] Could not mount backup drive"
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user