Archive for June, 2009

Ok, it’s not a full location detection as such.. I use my laptop (Ubuntu 9.04) both at home and work, as well as other places.  The problem that I had was related to how SAMBA was configured.  At home I have one workgroup name and at work I want the machine to appear in the company domain.  But also, while out and about in the big bad world I don’t want SAMBA on at all, no need to share anything with anyone.

So, to over come this and correct it at boot time I’ve come up with the simple script below.  The only other thing you need to do is prepare a couple of smb.conf files to suit the locations you’ll be in.   I have 2 smb.conf files, one for HOME and one for WORK.   I run the script from /etc/rc.local so it runs when I should have networking fully up and running. 

Here is the script:

#!/bin/bash
 
HOME=YOUR_HOME_GW_IP
WORK=YOUR_WORK_GW_IP
 
GW=`route -n | grep ^0.0.0.0| awk '{print $2}'`
 
if [ $GW = $WORK ]; then
    #echo "You're at work"
    cp /etc/samba/smb.conf.WORK /etc/samba/smb.conf
    /etc/init.d/samba restart
elif [ $GW = $HOME ]; then
    #echo "You're at home"
    cp /etc/samba/smb.conf.HOME /etc/samba/smb.conf
    /etc/init.d/samba restart
else
    #echo "You're somewhere else"
    /etc/init.d/samba stop
fi

Pretty simple really.  Hope others will find it useful.

Comments 4 Comments »

From the looks of the weather we’ve had it should be a good summer for camping … at least I sure hope so anyhow. Need to get the tent dug out and setup in the garden for to check it for any damage and such .. it’s been put away for 2 years since we last used it .. there was no camping last year.

I’ve been looking at some camp sites and one that has stuck out as looking like a fun place to go (for the kids too) …

River Dart Country Park – http://www.riverdart.co.uk/ Check out the pics of the place on the site.

Also found this place http://www.woodovis.com/cmx/content/view/2/4/ seems all right. Will have to check them out more.

Comments 2 Comments »