mountUnmountGoogleDrive_alkos.sh 1.1 KB

123456789101112131415161718192021222324252627
  1. #!/usr/bin/env bash
  2. gdrive_name="GoogleDrive_alkos"
  3. gdrive_path="$HOME/GoogleDrive_alkos/"
  4. gdrive_statusfile_path="$HOME/.myScripts/GoogleDriveStatus_alkos.txt"
  5. is_mounted=$(mount | grep "$gdrive_name")
  6. if [[ "$is_mounted" ]]; then # if mounted
  7. notify-send -i dialog-information -t 3000 "$gdrive_name" "is already mounted. Try to unmount"
  8. # fusermount -u $HOME/GoogleDrive_alkos/
  9. fusermount -u "$gdrive_path" 2> "$gdrive_statusfile_path" 1> "$gdrive_statusfile_path" # try to unmount GoogleDrive
  10. result_unmount=$(cat "$gdrive_statusfile_path" | cut -d":" -f3)
  11. if [[ -z "$result_unmount" ]]; then
  12. notify-send -i dialog-information -t 3000 "$gdrive_name" "unmounted successfully"
  13. else
  14. notify-send -i dialog-information -t 3000 "$gdrive_name" "Can't unmount: $result_unmount"
  15. fi
  16. else # if not mounted
  17. google-drive-ocamlfuse -label alkos "$gdrive_path" # try to mount GoogleDrive
  18. if [[ "$?" == 0 ]]; then
  19. notify-send -i dialog-information -t 3000 "$gdrive_name" "mounted successfully"
  20. else
  21. notify-send -i dialog-information -t 3000 "Error" "Failed to mount $gdrive_name"
  22. fi
  23. fi