http://bjoernstechblog.rueffer.info/posts/vpn/mac/eee/publishing/networking/2010/04/10/automate-EEE-remote-website-publishing/
last updated on 25 May 2018

10 April 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 © 2009–2018 — bjoern.rueffer.info