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.

Snippet: Chromium Snapshot Download (Cygwin) (Updated 3rd April)

A snippet to download and run the latest build of the Chromium browser. Meant for Cygwin/Windows but can be adapted if needed.

If you need to use a proxy, set your http_proxy and https_proxy variables before using this.

Now updated to kill running Chrome/Chromium processes before running the installer (in case of locking issues). Also created a Bitbucket repo here for this script

if [ -f ./mini_installer.exe ]; then
  echo "WARNING: Previous script run did not clean up"
  rm ./mini_installer.exe

if [ ! -f prev ]; then
  echo "No previous build logged"
  echo "-1" >prev

if [[ `wget -q -O-` == `cat prev` ]]; then
  echo "No build change (`wget -q -O-` = `cat prev`)"
  exit 1
  echo "New build (previous: `cat prev`, new: `wget -q -O-`)"
echo Downloading`wget -q -O-`/mini_installer.exe
wget`wget -q -O-`/mini_installer.exe

if [[ `ps -W | grep chrome | wc -l` != 0 ]]; then
  echo "`ps -W | grep chrome | wc -l` Chrome Processes Running. Attempting to Kill"
  for a in `ps -W | grep chrome | awk '{ print $1}'`
      echo Killing PID $a
      /bin/kill -f $a #This is the cygwin kill, not the bash kill
  echo "No Chrome Processes Running"
fiecho "Running installer"
chmod +x ./mini_installer.exe
echo Done
wget -q -O prev
echo "New build recorded (`cat prev`)"
rm ./mini_installer.exe

git Snippet: Proxy Configuration

I do a fair amount of work using git as version control, with SVN and CVS close behind, but I haven’t used any of them so much as a distributed version control. ¬†However, since I’ve started using Bitbucket and GitHub, I have encountered many issues to do with DVC. One of the main ones is communication via proxy.

My workplace doesn’t allow communication through the net without it going through a proxy server and it is an major pain in the arse to get through. Fortunately, git allows you to configure git to use a proxy server:

To use a proxy server for HTTP communication:

git config --global http.proxy http://user:password@proxyserver:9999

To use a proxy server for HTTPS communication:

git config --global https.proxy http://user:password@proxyserver:9999

My company firewall also injects its own SSL certificate, which breaks SSL verification, so to get around that:

git config --global http.sslVerify false

Bash Snippet: basename

I love linux and bash scripting. Whilst I am no expert, I really love the way you can pipe one application’s output into another.

One thing I don’t like to much about linux, however, is the case-sensitivity. “file.ext” is not the same as “file.EXT”, for example. On Windows, it doesn’t much care about the case of the extension, but on linux, it does. And therein is my problem.

My digital camera takes pictures and gives them a .JPG extension, which doesn’t show up on listings on my linux box where the application is looking for .jpg extensions. Sure, I can rename them manually, or macro together a simple bash script, but when you have to do this repeatedly, it gets quite frustrating.

So I did some research, and found out about the basename application. It serves two purposes. It strips out directory information to leave just the file name so that “dir1/dir2/dir3/file” becomes just “file” and optionally, allows you to strip out a suffix from the name, so for example to rename all .JPG files to .jpg in the current folder, I would use this:

for a in *.JPG
   mv $a `basename $a .JPG`.jpg

Here’s an example output

$ ls
file1.JPG file2.JPG file3.JPG

$ for a in *.JPG
> do
> echo mv $a `basename $a .JPG`.jpg
> done
mv file1.JPG file1.jpg
mv file2.JPG file2.jpg
mv file3.JPG file3.jpg

$ for a in *.JPG
> do
> mv $a `basename $a .JPG`.jpg
> done

$ ls
file1.jpg file2.jpg file3.jpg
%d bloggers like this: