Find the answer to your Linux question:
Results 1 to 2 of 2
Greetings all... I'm a newbie at this so go easy... What I want to achieve is to mount my servers file system when my laptop is able to connect to ...
  1. #1
    Just Joined!
    Join Date
    Apr 2009
    Posts
    4

    Help with automount script

    Greetings all...

    I'm a newbie at this so go easy... What I want to achieve is to mount my servers file system when my laptop is able to connect to it via wireless.

    This is what I've come up with so far.

    #!/bin/bash
    #
    #Automount network drive

    # Check if file system is mounted locally

    touch /mnt/mntpoint/dir/connection.up
    if [ $? -ne 1 ]
    then echo 'Mounted'; exit
    else echo 'Ready to mount'
    fi

    # Check local connectivity to server

    /bin/ping -c3 10.14.1.5
    if [ $? -ne 0 ]
    then echo 'Failed to connect locally'
    else sshfs user@10.14.1.5:/home/user /mnt/mntpoint/ -o follow_symlinks
    fi
    Questions/points

    1. If I lose connectivity after mounting and run the script it hangs. Probable when it tries to touch the file that should be there but isn't. Can anyone help with a better way of testing if the filesystem is already mounted?

    2. I can't run it as a log in script because the wireless isn't connected at log in. I was going to run as a five minute cron job but was wondering if any one has any idea if I can run it once after the wireless connects. (Kubuntu 9.04 beta)

    3. This is just what I've been hashing out and so if anyone can think of a more elegant way to do this please let me know.

    4. From here I'm thinking to check if the server is available over the internet if local connectivity fails and possibly sync some files. Anyone with cool ideas for what else I can do lets have them. I'm still learning so projects like this help push me.

    Cheers

  2. #2
    tpl
    tpl is offline
    Linux User
    Join Date
    Jan 2007
    Location
    cleveland
    Posts
    452
    welcome to the forum

    > mount my server's file system when my
    > laptop is able to connect to it via wireless

    assuming the server is running *nix, the standard way
    to do this is by "nfs mount"

    1. on server, add the laptop to /etc/exports

    / laptop(rw,sync,no_subtree_check)

    2. on server, add laptop to /etc/hosts

    10.14.1.10 laptop

    3. on laptop, add a line to /etc/fstab

    server:/ /server_filesystem nfs rsize=8192 wsize=8192 timeo=14, intr

    4. on laptop, add a line to /etc/hosts

    10.14.1.5 server

    now if server is running, yr laptop mounts server root
    directory "/" on its directory /server_filesystem. If
    server is not running, a bootup delay will occur.
    the sun is new every day (heraclitus)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...