Created
November 26, 2012 17:43
-
-
Save bobmurder/4149586 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
#!/usr/bin/env bash | |
# | |
# single step iTunes external drive ejection | |
disk="/dev/disk2" | |
music_path=/Volumes/media/music | |
itunes_pid=$(pgrep "^itunes$") | |
itunes_status=$(lsof -p "$itunes_pid" | grep "$music_path") | |
# kill iTunes if has an open filehandle to external drive | |
if [[ -n "$itunes_status" ]]; then | |
pkill -sighup "$itunes_pid" | |
fi | |
diskutil eject "$disk" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment