Last active
October 24, 2020 03:08
-
-
Save joshbeard/6073933 to your computer and use it in GitHub Desktop.
Bash script to mount a TimeMachine sparsebundle on a file server.
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/bash | |
HOST="mynas" | |
SHARE="my_home" | |
UNAME="jdoe" | |
PROTO="smb" | |
BUNDLE="TimeMachine/mycomputer.sparsebundle" | |
# mount_smbfs doesn't seem to work with passwords that have special characters | |
#printf "Mounting on ${HOST}...\n" | |
#expect <<EOF | |
#spawn mount_smbfs //${UNAME}@${HOST}/${SHARE} ${POINT} | |
#expect "Password for ${HOST}:" | |
#send "${PASS}\r" | |
#wait | |
#EOF | |
open ${PROTO}://${UNAME}@${HOST}/${SHARE} | |
i=0 | |
while [ $i -lt 60 ]; do | |
if mount | grep -q "//${UNAME}@${HOST}/${SHARE}"; then | |
mpoint=$(mount|grep "//${UNAME}@${HOST}/${SHARE}"|awk '{print $3}') | |
printf "Attaching ${BUNDLE}...\n" | |
if [ -e "${mpoint}/${BUNDLE}" ]; then | |
hdiutil attach "${mpoint}/${BUNDLE}" | |
break | |
fi | |
else | |
sleep 1 | |
((i++)) | |
fi | |
done | |
printf "Done.\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment