Friday, April 9, 2010

automate EEE remote website publishing

This is a University of Melbourne internal thing, probably not even relevant for anyone outside EEE.

If you are at home/overseas and want to update your webpage, then you have to use the VPN and mount the Samba share containing your personal web page. From my own experience, especially this last step is tedious, involves a lot of mouse usage and generally can take quite long if your connection isn't too fantastic. Especially so if you do update frequently. So is there a quicker way? Yes, there is: I use the following script to publish one file, say index.html automatically, which is sufficient for my purposes most of the time. But you can also upload a directory structure recursively, see the comment in the script.

I have deleted a few technical details from this script, that's where you have to put in your own credentials and the server name. Needless to say, this will only work in a unix environment like MacOS and you need to have the vpn client installed. This script should serve as a bare bone, of course there is room for more automation and more beauty...

#!/bin/bash 
SAMBASERVER=the samba server name, see below
SHARENAME=put share name here as in smb://SERVERNAME/SHARENAME
USERNAME=put username here in uppercase
PASSWORD=your password 

vpnclient connect staffvpn user $USERNAME pwd $PASSWORD&

# vpnclient needs some time, so lets just wait a little bit
sleep 10

cd ~/path-to-folder-containing-webpage
smbclient '\\.\'$SHARENAME -I $SAMBASERVER -U 'unimelb\'$USERNAME'%'$PASSWORD -c "put index.html"

# you can instead use `` -c "recurse; prompt; mput *.*" ''
# to recursively upload everything in this folder

vpnclient disconnect

Instead of this fiddling ideally there would be a (restricted) ssh account for this. This way one could use public key authentication, which can be much securer and more convenient. But that's not up to me, unfortunately.

A final disclaimer: It is not a good idea to store your password in a text file like this. I'd recommend to use an encrypted home directory and to harden your notebook using additional security measures, but that's a different story. Or even better: Do not store your password in a text file like this.


Björn Rüffer, Copyright 20092011
Disclaimer: The author of this page cannot accept any responsibility for content of pages that this page provides hyperlinks to. Also the author cannot accept responsibility or liability for any damage caused by following or not following instructions given on this page. This page, its contents and style, are the responsibility of the author and do not represent the views, policies or opinions of any other party. The author will not be held responsible for comments posted by third parties on this site. Inappropriate comments will be removed. There is no warranty for any program or source code provided here, to the extent permitted by applicable law. Except when otherwise stated in writing the copyright holders and/or other parties provide the program “as is” without warranty of any kind, either expressed or implied, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. The entire risk as to the quality and performance of the program is with you. Should the program prove defective, you assume the cost of all necessary servicing, repair or correction.