Skip to content

Latest commit

 

History

History
executable file
·
172 lines (115 loc) · 4.15 KB

INSTALL-GDrive.md

File metadata and controls

executable file
·
172 lines (115 loc) · 4.15 KB

FUSE filesystem over Google Drive

Complete guide to go to hell and back. © @Lion 🔉

Install google-drive-ocamlfuse on Debian Jessie and later.

Preinstall

Source: https://github.com/astrada/google-drive-ocamlfuse/wiki/How-to-install-from-source-on-Debian-Jessie

su
apt-get install software-properties-common sudo ssh
exit

Continue with sudo:

sudo apt-get install opam ocaml make fuse camlp4-extra build-essential pkg-config

Fuse

Create fuse group (if not already present):

sudo groupadd fuse

Debian has a special user group to allow fuse access. Log out, and log back in after this to make change effective:

Replace *username* with your real username

sudo usermod -a -G fuse *username*
sudo chown root:fuse /dev/fuse
sudo chmod 660 /dev/fuse

Install packages

opam init
opam update
opam install depext
eval `opam config env`
opam depext google-drive-ocamlfuse
opam install google-drive-ocamlfuse
. /home/*username*/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true

Reboot

Yes, do it.

sudo reboot

Authorize your account

Source: https://github.com/astrada/google-drive-ocamlfuse/wiki/Headless-Usage-&-Authorization

  • Sign in to your Google account and create a project: https://console.cloud.google.com/
  • Click "API Manager" then "Library" in the left-hand pane (will take you to https://console.cloud.google.com/apis/library). Click on "Drive API", then "ENABLE API".
  • Click "Credentials" in the left hand pane, then click on the button "Create Credentials" (OAuth client ID)
    • Choose "Other"
    • Choose any product name, e.g "My OCAMLDrive".
    • Click "Create". You will get a Client ID, a Client Secret.
  • Authorization: Back in your headless server, run google-drive-ocamlfuse for the first time. I used labels (in this document, I use the label "me") because I plan on using multiple accounts. However you can also run it without the -label parameter and it will use a default name for the label called "default". You will need the Client ID and secret you got from google above.

From version 0.5.3, you should use the -headless option:

Replace *yourClientID* and *yourSecret* with your real credentials

google-drive-ocamlfuse -headless -label me -id *yourClientID*.apps.googleusercontent.com -secret *yourSecret* 

Example output:

Please, open the following URL in a web browser: https://accounts.google.com/o/oauth2/auth?client_id=##yourClientID##.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&response_type=code&access_type=offline&approval_prompt=force
Then, you should open the URL above in a graphical web browser, get the verification code from Google and put it here:
Please enter the verification code: 

That's it. You should be ready to mount.

Replace *username* with your real username

mkdir /home/*username*/gdrive

Try mount:

google-drive-ocamlfuse -label me /home/*username*/gdrive

Mount on startup using systemd

You need mount script and service configuration

Mount script

Source/tips: https://linuxconfig.org/how-to-automatically-execute-shell-script-at-startup-boot-on-systemd-linux

cd /usr/local/bin
nano mount-gdrive.sh

Type script content:

Replace *username* with your real username

#!/bin/sh

su *username* -l -c "google-drive-ocamlfuse -label me /home/*username*/gdrive"

Fix permission:

chmod 755 mount-gdrive.sh

Systemd service

Go to systemd directory:

cd /etc/systemd/system
nano gdrive.service

Type in file content:

[Unit]
After=networking.service

[Service]
ExecStart=/usr/local/bin/mount-gdrive.sh

[Install]
WantedBy=default.target

Configure service:

chmod 664 /etc/systemd/system/gdrive.service
systemctl daemon-reload
systemctl enable gdrive.service

Testing before reboot [optional]

Test your configuration:

systemctl start gdrive.service

GG WP 🎮 👏 :feelsgood: 😈 ☕