BASH Dropbox Uploader on OpenWRT

by smching in Circuits > Software

7971 Views, 14 Favorites, 0 Comments

BASH Dropbox Uploader on OpenWRT

BASH_Dropbox_uploader_on_OpenWRT.jpg

This guide is to provide detailed information on how install BASH Dropbox Uploader to a wireless router flashed with OpenWRT. Dropbox Uploader is a BASH script written by Andred Fabriz that allows you to upload, download, delete files (and more) from Dropbox.

Prerequisite

  1. Router flashed with OpenWRT firmware. I'm using TP-Link TL-Wr103ND V2 & flashed with OpenWRT Barrier Breaker 14.07
  2. A Dropbox account

Dropbox App Key & App Secret

Dropbox_sign_in.jpg

The first step is to sign in to Dropbox app creation page to get a Dropbox App key & App Secret from Dropbox. The App key & App Secret will used by Dropbox API for authorizing access to resources on Dropbox.

Create a New Dropbox Platform App

Dropbox_Apps.jpg

Select a Dropbox Package

Dropbox_Basic.jpg

Email Verification

Email_verification.jpg

Select Type of App

Dropbox_API_app.jpg

Record Down the Permission Type, App Key and App Secret

App_key.jpg

Installing Dropbox Uploader

Zero_file_size.jpg

Next step is to SSH to router and download Dropbox Uploader from github to the router /root directory. Command line below supposed to do the job, unfortunately it is not working. It just download the Dropbox Uploader file (dropbox_uploader.sh) with zero file size as shown in figure above.

opkg update

opkg install bash curl coreutils-statcd /rootcurl -k https://raw.github.com/andreafabrizi/Dropbox-Uplo... > dropbox_uploader.sh

chmod 755 dropbox_uploader.sh

Correct Procedures to Installing the Dropbox Uploader

WinSCP.jpg

To overcome this problem, I have to download the Dropbox Uploader (dropbox_uploader.sh) to my computer and then transfer it to router. I'm using WinSCP to transfer Dropbox Uploader to the router as shown in figure above.

SSH to the router and enter the following command once the dropbox_uploader.sh file has been uploaded to router.

opkg update

opkg install bash curl coreutils-stat

cd /root

chmod 755 dropbox_uploader.sh

Authorizing Access to Resources on Dropbox

Setup_Dropbox_API.jpg

SSH to router and run the Dropbox Uploader

./dropbox_uploader.sh -k

Enter the App key and App secret accordingly, enter "a" (lower case) will set Folder Permission type to App Folder. Finally enter "y" to continue.

If everything is OK, it will generated a URL for you to access your Dropbox folder, otherwise it will prompted "bad App key" until you had enter a correct App key & App secret.

Leave the above windows open and then open your web browser, enter the generated URL (https://www.dropbox.com/1/oauth/authorize?oauth_token=??????????) as shown in figure above, this will prompted you to access folder inside your Dropbox.

Allowed the Dropbox Uploader Access to Your Dropbox Folder

Allow_access_to_Dropbox_folder.jpg

After clicking on the Allow button, you are allowed the Dropbox Uploader access to your Dropbox folder, come back to the SSH window and press the Enter key.

Your Dropbox Uploader is setup completed.

Upload File to Dropbox

Dropbox.jpg

Example below will upload the test.txt file in /tmp directory to the Dropbox app root folder.

./dropbox_uploader.sh -k upload /tmp/test.txt /

or

/root/dropbox_uploader.sh -k upload /tmp/test.txt /

Download File From Dropbox

Example below will download test.txt from Dropbox to router /tmp folder

/root/dropbox_uploader.sh -k download /test.txt /tmp/

Delete a File From Dropbox

Example below will delete a file from Dropbox

/root/dropbox_uploader.sh -k delete /text.txt