Dynamic IP Workaround

If you rely on remote access to your home computer but cannot be bothered with having to record your external IP each time then you can use DynDNS or No-IP, but they rely on installing their own tools to update their systems, and in some cases, want you to pay for the service. I have found a (somewhat convoluted) way of an alternative means, which should work under most Linux environments.

  1. Install the packages “at” and “grive” (at allows you to schedule tasks from command line with simple timing syntax. Grive is a console-based Google Drive syncing tool) — note, however, that grive may not be present in all repositories.
  2. Setup Grive.
  3. Add this script to the grive directory and name it externalIP.sh:

IP=wget -q -O - checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'
HOST=host $IP | cut -d ' ' -f5
echo $IP $HOST | tee externalIP.txt
grive
echo ‘cd {path-to-your-grive-folder};./externalIP.sh’ | at now + 2 hours

  1. Make the script executable
chmod +x externalIP.sh
  1. Run the script ONCE
$ ./externalIP.sh
XX.X.XXX.XXX your-hostname.
Reading local directories
Synchronizing folders
Reading remote server file list
Detecting changes from last sync
Synchronizing files
sync "./externalIP.txt" doesn't exist in server, uploading
Finished!
warning: commands will be executed using /bin/sh
job 278 at Tue May 6 22:48:00 2014

What the script does is determine the external IP address of your machine, do a reverse lookup on it, write the results to a text file, then sync it with Google Drive. What you can do is read the text file (externalIP.txt) off your Google Drive storage via the web interface at http://drive.google.com, and you can then access it remotely, using either the IP or the hostname. The last line schedules the script to be run again in two hours from now (in case your IP address changes), this is the “job 278” line.

It should also be noted that the scheduling carries on between reboots.

Grive & Fedora — Working

Grive is an open source command-line-based sync tool to synchronise a directory with your Google Drive. Grive is not in the Fedora repositories, although it is undergoing review for addition into the repositories.

In the meantime, if you want to use it, I’ve written a script that should pick the latest version from the russianfedora website. Bitbucket repository is here.

Direct link to script: here

Once you install the application, create a blank folder (this will be the sync folder), then run
grive -a
to request an authentication URL. Go to that URL, log into Google if you need to, and you’ll get a response string you need to copy back into the console window. If the authentication was successful, Grive will sync your files into the folder. Each subsequent time you run Grive, it will download and/or upload files to/from your Google Drive.

There is only one limitation that I’m aware of. Documents created from within Google Drive won’t sync, but if you convert them to odt or doc files, they will sync.

%d bloggers like this: