25 Aralık 2014 Perşembe

Google Drive mount GUI for linux

Google did not develop a good client for its "Google Drive" thats for sure.
I tried several solutions like grive and so on. Grive has its own problems which is not the subject of this post. So I decided to use google-drive-ocamlfuse.
I wtrote a small script using YAD which is basically Zenity on steroids.

Before we can use this GUI kinda script we need to setup google-drive-ocamlfuse. Off we go...

Install google-drive-ocamlfuse for debian derivatives

Open a terminal as your current user (not root) and begin typing:

sudo add-apt-repository ppa:alessandro-strada/ppasudo 
apt-get update 
sudo apt-get install google-drive-ocamlfuse 
google-drive-ocamlfuse

This should open a tab in your default web browser, asking to allow google-drive-ocamlfuse to access your Google Drive. Click "Allow", wait a few seconds for google-drive-ocamlfuse to retrieve the authorization code and you're done.

Actual information can be found here on webupd8.org

Install google-drive-ocamlfuse for suse derivatives

This is working for Suse 13.1, I didnt try other versions but they should work as well.

Open a terminal as your current user (not root) and begin typing:

For suse I started yast out and I created the repository called OPAM with the specific URL "http://download.opensuse.org/repositories/home:/eclipseagent:/opam/openSUSE_13.1/"







And then in terminal
zypper in yad ocaml-findlib gcc ncurses-devel ocaml-ocamldoc libcurl-devel sqlite3-devel ocaml-camlp4-devel fuse-devel zlib-devel
wget http://www.ocamlpro.com/pub/opam_installer.shchmod +x opam_installer.shsh ./opam_installer.sh /usr/local/bin

This will take a while and after it is finisned it will ask you to enter
`opam config env`
command in terminal so do that.

Next you have to initialize opam and install google-drive-ocamlfuse
opam initopam install google-drive-ocamlfuse
So now you have all the packages you need to have.
google-drive-ocamlfuse
This should open a tab in your default web browser, asking to allow google-drive-ocamlfuse to access your Google Drive. Click "Allow", wait a few seconds for google-drive-ocamlfuse to retrieve the authorization code and you're done.

for suse you can use the links below for more information

What does this script do ?

This script provides a mount GUI for google drive. It creates a directory called "googledrive" in your user $HOME and mounts your google drive account to this place. If it is already mounted only MOUNT button is shown and vise versa.

IMPORTANT
All the files are LIVE files so use extreme caution while deleting and updating files because these are the ACTUAL FILES IN YOUR GOOGLE DRIVE. If you delete a file by accident then "say hello to my little friend" or "say goodbye to your file" if you don't have a backup. Always backup. So this is said and done you can not hold me responsible of anything deleted. You have been warned !

Save the below script as gdrive.sh in /usr/bin or whereever you like and "chmod +x gdrive.sh" to make it executable. Now make a shorcut or link in your menu or taskbar of desktop to it.

#!/bin/bash
# google-drive-ocamlfuse mounter HUI
# Cihan Ispanoglu @ 2014

GDRIVE_FOLDER="$HOME/googledrive"
if [ ! -d "$GDRIVE_FOLDER" ]; then
  mkdir -p "$GDRIVE_FOLDER"
fi

YAD=`which yad`
YADKEY=$RANDOM

TITLE=" Google Drive Mount GUI"
HEIGHT=200
WIDTH=400

CURSTATE=""
RET=""
CMD=""

function mount_gdrive()
{

  if grep -qs "google-drive-ocamlfuse" /proc/mounts; then
    CURSTATE="Current State\tAlready mounted\n`grep 'google-drive-ocamlfuse' /proc/mounts | awk '{print $1 ,"\011", $2}' `"
  else
    CURSTATE="Current State\tNot Mounted"
  fi

  $YAD --plug=$YADKEY --tabnum=1 --text "Google Drive" --text "$CURSTATE\n\nMOUNT\tmounts google drive \nUMOUNT\tunmounts google drive" &> res1 &

  if grep -qs "google-drive-ocamlfuse" /proc/mounts; then
    ACTION=`$YAD --center --title "${TITLE}"  --text "$CURSTATE\n\nMOUNT\tmounts google drive \nUMOUNT\tunmounts google drive" --height=$HEIGHT --width=$WIDTH --button="UMOUNT:101" --button="gtk-cancel:1"`
  else
    ACTION=`$YAD --center --title "${TITLE}"  --text "$CURSTATE\n\nMOUNT\tmounts google drive \nUMOUNT\tunmounts google drive" --height=$HEIGHT --width=$WIDTH --button="MOUNT:100" --button="gtk-cancel:1"`
  fi

  RET=$?
  [[ $RET -eq 1 ]] && exit 0

  case $RET in
      100) sleep 1
           google-drive-ocamlfuse $GDRIVE_FOLDER
           sleep 1
           xdg-open $GDRIVE_FOLDER;;           
      101) sleep 1
           fusermount -u $GDRIVE_FOLDER;;
      *) exit 1 ;;        
  esac
}

mount_gdrive
exit

Screenshots of google drive mount GUI for linux





Note: I did not write the "Backup / Policy" and actually took it out now because suse YAD dont have --notebook :) Coming soon...

Thanks for reading.

1 yorum: