Created
July 5, 2016 16:27
-
-
Save jfonte/2f85d5745a5d6065efd576d86e4282ae to your computer and use it in GitHub Desktop.
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 | |
# sleepwatcher script to dismount ext. drives on wake https://www.kodiakskorner.com/log/258 | |
# checks if data & bak volumes are mounted, and if so dismounts | |
if [[ $(mount | awk '$3 == "/Volumes/bak" {print $3}') != "" ]]; then | |
diskutil umount bak | |
fi | |
sleep 3 | |
if [[ $(mount | awk '$3 == "/Volumes/data" {print $3}') != "" ]]; then | |
diskutil umount data | |
fi | |
sleep 3 | |
# tries to eject drive and displays error if in use | |
if ! diskutil eject bak ; then | |
osascript -e 'tell app "System Events" to display dialog "ext drive in use"' | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment