Samba Network Shares with Nautilus in Hardy Heron Part 2

Posted by Ryan Baxter Sun, 01 Jun 2008 23:07:00 GMT

Nearly a month ago I wrote about my problems connecting to the network shares of my Linksys NAS200 using Nautilus in Ubuntu, Hardy Heron. My fix was simple and it worked. Unfortunately, the solution’s WAF (Wife Acceptance Factor) was low. Apparently she didn’t think it was easy enough to execute smbmount from a Terminal window. Whatever :) I have since written a small shell script that is called from Session Startup.

Initially, the script failed to connect to my network shares because my wireless network connection hadn’t finished negotiating before the script was executed. I coded around this by creating a while loop that greps the output of a ping to my router. If successful, the mount_shares function is called. Otherwise. the thread will sleep for 10 seconds and try again.

#!/bin/bash

user="thorbardin/ryan%password"
root_dir="/home/ryan/Network Shares"

mount_shares() {
  public_dir="$root_dir"/"Public on Thorbardin"
  home_dir="$root_dir"/"Home on Thorbardin"

  [ -d "$public_dir" ] || mkdir -p "$public_dir"
  [ -d "$home_dir" ] || mkdir -p "$home_dir"

  smbmount "//192.168.1.105/public disk" "$public_dir" -o user="$user"
  smbmount "//192.168.1.105/ryan" "$home_dir" -o user="$user"
}

while [ 1 ]; do
  if ping -c2 192.168.1.1 2>&1 | grep ttl; then
    mount_shares

    exit 0   
  fi
  sleep 10
done

exit 0

I’m already thinking about rewriting this script so that it scans my network using smbtree and automatically mounts all available network shares. That’ll be Part 3!

Trackbacks

Use the following link to trackback from your own site:
http://crunchlife.com/articles/trackback/67

Comments

Leave a response

Avatar
Glenn Comment_bubble 9 days later:
Thanks for posting this (and part 1). I just bought a NAS200, and this information has been very beneficial.
Avatar
Ryan Baxter Comment_bubble 9 days later:
Excellent! How do you like the NAS200 so far?
Avatar
Glenn Comment_bubble 11 days later:
So far I like it. It was quite easy to get the device up and running. I'm slowly but surely copying my audio and video files to it. I also enabled the media server so I can access the files from my PS3.