Sunday, 17 May 2015 10:53

BASH Dropbox Uploader on OpenWRT

BASH Dropbox uploader on OpenWRT

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

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

 

Dropbox App Key & App Secret

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.

  • Sign in to Dropbox app
    Dropbox sign in
  • Create a new Dropbox Platform app
    Dropbox Apps
  • Select a Dropbox package
    Dropbox Basic
  • Email verification
    Email verification
  • Select type of app
    Dropbox API app
  • Record down the Permission type, App key and App secret
    App key

 

Installing Dropbox Uploader

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.

opkg update
opkg install bash curl coreutils-stat
cd /root
curl -k https://raw.github.com/andreafabrizi/Dropbox-Uploader/master/dropbox_uploader.sh > dropbox_uploader.sh
chmod 755 dropbox_uploader.sh #give the execution permission

 

It download the Dropbox Uploader file (dropbox_uploader.sh) with zero file size as shown in figure below

Zero file size

 

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 below.

WinSCP

 

The correct procedures to installing the Dropbox Uploader would be:
  1. Download the Dropbox Uploader (dropbox_uploader.sh) to computer
  2. Transfer the dropbox_uploader.sh file to router /root directory using WinSCP.
  3. SSH to router & execute the following command
opkg update
opkg install bash curl coreutils-stat
cd /root
chmod 755 dropbox_uploader.sh #give the execution permission

 

Authorizing access to resources on Dropbox

SSH to router and run the Dropbox Uploader

./dropbox_uploader.sh -k

-k means doesn't check for SSL certificates (insecure)

  

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.

Setup Dropbox API

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.

Allow access to Dropbox folder

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 as shown in figure below:

Access Token request successful

 

Upload file to Dropbox

Example below will upload the test.txt file in /tmp directory to the Dropbox app root folder. Please read here for more usages.

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

or

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

Dropbox

 

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

Read 4654 times Last modified on Thursday, 30 July 2015 23:20

Leave a comment

Back to Top