Access acd_cli from the command line on Linux

In today’s online retail market dominated by cut throat competitions, one player stands in the forefront, leaving the pack far behind, and that is Amazon. Amazon has been judiciously expanding its business model to satisfy consumer appetites, and I think Amazon Prime membership lies in the center of its expanding business model. Starting out as unlimited free-shipping membership, Amazon Prime has grown over time to include a variety of other perks, including unlimited streaming music, movies and TV dramas, unlimited photo gallery, free e-book library, and now same-day/one-day delivery.

Granted 99USD/year price tag for Prime membership is still hefty for non-regular Amazon customers, but people like me who purchase virtually everything from Amazon and enjoy its other perks everyday, Prime membership is worth every penny.

What is Amazon Cloud Drive?

Amazon Cloud Drive (ACD) is one such benefit of Amazon Prime. ACD is a cloud storage service similar to Dropbox, Google Drive and the likes, but unlike others ACD is free only for Amazon Prime members. If you are not an Amazon Prime member or don’t plan to become one, this post is not for you (unless of course you are willing to pay for ACD).

For those Amazon Prime members, Amazon Cloud Drive is where you can store “unlimited” amount of photos and upto 5GB of other files for free. Some Prime customers (like me) may be offered a free upgrade to “Unlimited Everything” plan in which you get unlimited space for any files. If you are not a Amazon Prime member, you will have to pay a yearly subscription fee (11.99USD/year).

For what it’s worth, I think ACD still has a long way to go to qualify as a competitive “non-free” cloud storage. Not only is there no official Linux client, but also existing official desktop/mobile clients (for Windows, OS X, Android and iOS) are not yet up to par in terms of UI, reliability and sync capability. In the end, I found a much better “unofficial” ACD client called acd_cli, which I am going to introduce today.

acd_cli is a lightweight command-line client for Amazon Cloud Drive, allowing you to access ACD storage from the command line on Linux. It also comes with a FUSE module for ACD, so that you can “mount” ACD and access it as if it were part of local file system. Pretty neat!

In the rest of the tutorial, I will describe how to access Amazon Cloud Drive from the command line usingacd_cli. It’s still in beta, so be generous with any hiccups.

Install acd_cli on Linux

Requirements

acd_cli requires Python 3.3.2 or higher. So make sure that you have python3, and that its version meets this requirement.

$ python3 -V

Most recent Linux distributions should meet this requirement (e.g., Python 3.3.2 on Fedora 20, Python 3.4.0 on Ubuntu 14.04, Python 3.4.2 on Debian 8).

Also, you need to have pip3 installed (check the instruction if it is not installed).

For CentOS/RHEL systems which do not have python3/pip3 in their base repositories, you can install the latest python3/pip3 following this guide.

Install acd_cli with pip

Once you have python3 and pip3 on your system, installation of acd_cli is as easy as running:

$ sudo pip3 install –upgrade –pre acdcli

For Arch Linux users, there is a pre-built package from AUR.

Configure acd_cli for the First Time

Before using acd_cli, you need to go through one-time authentication, where you authorize acd_cli to access your Amazon Cloud Drive account via OAuth. To start the procedure, simply run:

$ acd_cli init

On a desktop, this will open up a new browser window, which then loads https://tensile-runway-92512.appspot.com. If you are on a headless server, you can open up a browser on a separate computer, and go to https://tensile-runway-92512.appspot.com.

You will then be asked to sign in to your Amazon account.

Type in your Amazon.com login credential, and you will be presented with a page where you authorizeacd_cli to access your ACD.

This will generate necessary OAuth credentials, which will be saved as a JSON file named “oauth_data”. Place this file in ~/.cache/acd_cli folder on the host where you ran acd_cli command, and press ENTER.

Before running any command with acd_cli, you need to sync its local cache with your Amazon Cloud Drive account. Most acd_cli commands require the node cache to be up-to-date. The following is theacd_cli sync command.

$ acd_cli sync

This completes the one-time setup of acd_cli. At this point, you should be able to access ACD from the command line.

Access Amazon Cloud Drive from the Command Line

Let’s quickly check whether acd_cli is configured correctly by running a few commands.

$ acd_cli usage
$ acd_cli ls /

The first command will show you the current usage of your ACD account (e.g., how much storage is being used). The second command shows the content of its root folder.

Here are other basic examples of acd_cli‘s command-line interface.

To browse a particular folder:

$ acd_cli ls /Pictures

To download an entire folder locally:

$ acd_cli dl /Pictures/Jessica_Wedding

To upload an entire local folder to ACD:

$ acd_cli ul ./Xmas_2015 /Pictures

Check the official documentation for the complete list of available actions.

Mount Amazon Cloud Drive on Linux

Another useful feature of acd_cli is its FUSE support, allowing unprivileged users to mount Amazon Cloud Drive as a FUSE filesystem.

To mount ACD locally, simply run:

$ acd_cli mount /local/mount/point

Now you can use native Linux commands (e.g., ls, df, cp, mv) to access your ACD account.

To unmount ACD:

$ acd_cli umount ./acd

If you want to have your ACD account mounted automatically on boot, you can configure systemd to auto-mount ACD (assuming that you are using systemd on your Linux).

The following is how to set up a systemd user instance for ACD service.

First create necessary folders (i.e., local mount point and systemd‘s user folder).

$ mkdir ~/acd
$ mkdir -p ~/.config/systemd/user

Create the following systemd file.

$ vi ~/.config/systemd/user/amazon-cloud-drive.service
[Unit]
Description=user Amazon Cloud Drive FUSE mount
Documentation=https://acd-cli.readthedocs.org/en/latest/
AssertPathIsDirectory=%h/acd
After=network-online.target

[Service]
Type=simple
ExecStart=/usr/local/bin/acd_cli mount --foreground %h/acd
ExecStop=/usr/local/bin/acd_cli -v -nl umount %h/acd
Restart=on-abort

[Install]
WantedBy=default.target

Finally reload and enable systemd as a “regular” user:

$ systemctl –user daemon-reload
$ systemctl –user start amazon-cloud-drive.service
$ systemctl –user enable amazon-cloud-drive.service

Now your ACD account should be mounted at ~/acd automatically upon boot.

Note that the FUSE support of acd_cli is labeled as “experimental.” So treat this feature as such.

Conclusion

In this tutorial, I went over a nice little command-line tool for Amazon Cloud Drive. Despite its unofficial status, acd_cli does a wonderful job to make ACD readily accessible on Linux, even in extremely user-friendly ways. Something folks at Amazon should learn from. Kudos to the developer!

Subscribe to Xmodulo

Last updated on January 12, 2016

Full article:

Source: How to access Amazon Cloud Drive from the command line on Linux – Xmodulo

Advertisement

1 Comment

  1. I keep getting an error mounting, any help would be greatly appreciated.

    FUSE(ACDFuse(**args), path, subtype=ACDFuse.__name__, **kwargs)
    File
    “/usr/local/lib/python3.4/dist-packages/acdcli/bundled/fuse.py”, line
    416, in __init__
    raise RuntimeError(err)

    Like

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.