Why doesn't Google use OCaml

Mount Google Drive as a drive on the Banana Pi

If you store your data on the Google Drive cloud storage, you may want to access your data easily and transparently without performing a complete synchronization beforehand. Especially on the Banana Pi or Raspberry Pi, the storage space can quickly run out.

In this blog entry I will describe how to integrate a Google Drive storage in the Banana Pi as a drive with the help of the program "google-drive-ocamlfuse". For “non-ARM” architectures, there are ready-made Debian packages that can be easily installed using the package manager. For ARM processors such as the Banana Pi, the corresponding packages must first be compiled and installed manually.

Compile and Install:

Fortunately, there is a ready-made bash script that summarizes the individual steps and automatically runs them one after the other. I recommend running the script as "root" and then copying the finished packages into the appropriate user home directory. This saves you from having to abort the script due to possible authorization problems.

Approximately 400 MB of storage space is also required. Either you still have enough space on your SD card or you adapt the path of the variable "OPAMDIR" in the script so that it points to an external storage medium.
It should be noted that the "$ {HOME}" entries in the script are set to the parent path of "OPAMDIR". For example, if the path of "OPAMDIR" is "/ media / usb / opam", all "$ {HOME}" entries should be replaced by "/ media / usb".

Here is the script:

#! / bin / bash
OPAMDIR = $ {HOME} / opam
DRIVECFG = ~ / .gdfuse / default / config

sudo apt-get -y –force-yes install ocaml ocaml-findlib sqlite3 camlidl m4 libcurl4-gnutls-dev libfuse-dev libsqlite3-dev camlp4-extra fuse b $
cd $ HOME
git clone https://github.com/OCamlPro/opam
cd $ OPAMDIR
./configure && make && sudo make install
cd $ HOME
opam init –yes && opam –switch = 4.01.0dev + trunk –yes
echo "eval \` opam config env \ `" >> ~ / .bashrc
opam install google-drive-ocamlfuse –yes
sudo usermod -a -G fuse $ USER
newgrp fuse
sudo chmod a + rw / dev / fuse
sudo mkdir -p / mnt / drive
sudo chown $ USER.fuse / mnt / drive
sudo sed -i’s / \ # user_allow / user_allow / g ‘/etc/fuse.conf #allows other users to allow_other \ users

You simply copy the above lines into a file (e.g. "installgoogleocaml") and do it with the command "chmod + x installgoogleocaml“Executable. The script is then started with "./installgoogleocaml„.

The script downloads a number of files and then compiles them. The whole thing can take a while!

After the script is finished, the file "google-drive-ocamlfuse" should be located in the directory "$ OPAMDIR / opam / system / bin", depending on the path. If you want, you can now move the entire “opam” folder to another location, for example to your home directory.

Configure and integrate

Next we have to configure “google-drive-ocamlfuse”. To do this, we start the program with the following command:

$ opam / system / bin / google-drive-ocamlfuse / mnt / drive

If you are working in a graphical environment, a browser window will open in which you can allow “google-drive-ocamlfuse” to access your Google Drive account. Of course, this access should be allowed.
In this way, the access rights are assigned via the OAuth2 procedure and the Google Drive account is integrated under the specified mount directory “/ mnt / drive”.
The ID and the “secret cookie” are stored in the configuration file “~ / .gdfuse / default / config” so that you do not have to allow access again when you re-integrate.

If you don't have a graphical environment on the Banana Pi to confirm access, the whole thing is a bit more complex.
First of all, it is necessary to create OAuth2 access data in his Google account. You should use the "old" developer console from Google for the following steps. To do this, simply click on “Cancel” in the first point when calling up the URL. The steps can be carried out on any client with a graphical user interface:

  • Go to https://code.google.com/apis/console/ and create a new API project.
  • Click on "Services" on the left
  • Set the "Drive API" item to "On"
  • Click on "API Access" on the left
  • Click on "Create another Client-ID ..." in the main area
  • Select "Installed Application" and click the "Other" type

The lines “Client ID” and “Client secret” are now displayed. These are the lines that we need to call "google-drive-ocamlfuse":

$ opam / system / bin / google-drive-ocamlfuse -headless -id CLIENTID -secret CLIENTSECRET

The output is now a URL that you have to insert into a browser and call up. This can be done on any client. The only requirement is that you are logged into your Google account.
The browser window should now display an ID, which in turn should be copied into the input field of the waiting program “google-drive-ocamlfuse” (Please enter the verification code :).

After these steps you can now integrate the Google Drive account with the following command:

$ opam / system / bin / google-drive-ocamlfuse / mnt / drive

That was all :-).