Dropbox + Google Docs + LaTeX
For headless Linux servers you can install a copy of Dropbox in your home folder using the following command:
cd ~ && wget -O - "http://www.dropbox.com/download?plat=lnx.x86_64" | tar xzf -
cd ~ && wget -O - "http://www.dropbox.com/download?plat=lnx.x86" | tar xzf -
Then start dropbox:
It will give you a URL to go to provide that machine with an access token.
(described here as well: http://www.dropbox.com/install?os=lnx)
If it's not already available on your system, you will also need
to control your dropbox instance. Make sure the file is flagged
executable after you download it (
chmod +x dropbox.py) and put
it somewhere in your path.
Uploading Documents to Google Docs
If you don't already have them, you will need an install of GoogleCL and gdata <=2.0.14. As of the time this was written, 2.0.15 & 2.0.16 were causing issues with googlecl and docs. If these are packaged for your system and gdata is 2.0.14 or a bit earlier, go ahead and use those.
*NOTE: Based on the discussion linked above, it may now be possible to use a *trunk version of googlecl with the latest gdata, but I haven't tested this.
Get files that you want to start with somewhere on the machine with
GoogleCL & gdata and upload them (switch to the directory containing
.tex files you wish to upload):
google docs upload --folder=<foldername> --format=txt *.tex
where foldername is the collection name you want on google docs. Make sure that you have created this collection first or the files will go into your main collection.
If you also have other files you want editable as text files you can follow the same formula above (e.g.: for bib files):
google docs upload --folder=<foldername> --format=txt references.bib
The googlecl client will probably ask you to authorize use with your account in the process by giving you a link (maybe opening chrome over X11) and you'll have to paste back a token into the command line that is provided after you give permission on the site. If it opens something like lynx you may have connected to a machine over SSH without X11 forwarding or your default browser might be set to a text-based one. It appears that things won't work over lynx/links so you may need to enable X11 forwarding to allow it to open a browser in the background (add -X to your ssh command line to enable this when you connect to the host that Dropbox will be running on).
Document Build Script
Now modify the variables at the top of the script below so that the paths and names are correct and put this somewhere in your directory and chmod +x the file (I put it in ~/bin), making sure that you've set up the destination directory in Dropbox (mkdir -p ~/Dropbox/):
#!/bin/bash # name of output pdf file OUTPUT_PDF="main.pdf" # subfolder in dropbox for builds DROPBOX_SUBFOLDER="Project/proposal_build" # path to where dropbox.py is installed DROPBOXPY_PATH=/usr/local/bin # folder name on google docs DOCS_FOLDER="Project" cd $HOME/Dropbox/$DROPBOX_SUBFOLDER if [ ! -f $OUTPUT_PDF ] || [ ! -f "delete_to_refresh" ] then $DROPBOXPY_PATH/dropbox.py stop google docs get --folder=$DOCS_FOLDER --format=txt . for file in *.txt do sed -i 's/\xe2\x80\x9c/\`\`/g' "$file" sed -i 's/\xe2\x80\x9d/\x27\x27/g' "$file" sed -i 's/\xe2\x80\x98/\`/g' "$file" sed -i 's/\xe2\x80\x99/\x27/g' "$file" iconv -f utf8 -t ascii -c "$file" | sponge "$file" done rename 's/\.txt$//' *.txt -f make touch delete_to_refresh $DROPBOXPY_PATH/dropbox.py start fi
NOTE: In the version above, the
sponge command is used which
can be found in the
moreutils package (available in Ubuntu and
apt-get install moreutils
yum install moreutils
Make sure that all the other dependencies other than the
files are in the appropriate path structure around the destination
directory, and also put a Makefile in the destination with a default
rule that builds the pdf named in the script.
Test that the script works by running it.
Now add this to your crontab (crontab editor can be invoked using:
* * * * * /home/<username>/bin/<scriptname>
If you also want to prevent it from sending email every time it runs, you can add the following line:
Now you can go to dropbox & google docs and share the folder and collection as needed. When you delete the named PDF from the build directory or the "delete_to_refresh" file, it should attempt to update the build the next time the cron job runs.