<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:arial,helvetica,sans-serif;font-size:10pt"><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><font face="Tahoma" size="2"><hr size="1"><b><span style="font-weight: bold;">From:</span></b> Avi Schwartz <ubuntu-users352@cfftechnologies.com><br><b><span style="font-weight: bold;">To:</span></b> "Ubuntu user technical support, not for general discussions" <ubuntu-users@lists.ubuntu.com><br><b><span style="font-weight: bold;">Sent:</span></b> Mon, February 14, 2011 10:50:21 PM<br><b><span style="font-weight: bold;">Subject:</span></b> Re: automatically mount network drive - 10.04 LTS<br></font><br>
<p style="margin-bottom: 0cm; margin-top: 0pt;">On 02/14/2011 07:58
PM, Arnaud G wrote:<br>
</p>
<blockquote type="cite">
<div style="font-family: arial,helvetica,sans-serif; font-size: 10pt;">
<div>I am back to the drawing board. Below is what I need to
accomplish. I have been looking around, trying different
solutions, experimenting but so far I am not satisfied with
the result I got.<br>
<br>
We are migrating people, in my university, to Ubuntu 10.04
LTS. On the "desktop" side (approx 500 users) LTSP will be
used. It works. So far so good.<br>
By default everything is saved under their "Documents" folder.<br>
<br>
My problem is about the laptop users. They will have 10.04 LTS
installed on their machine. When they use their laptop their
work is saved by default in their "Documents" folder. So far
everything is good.<br>
I would like to synchronize their laptop "Documents" folder to
their network drive "Documents" folder. I can use rsync for
that once their network drive is "mounted". I could use
something similar to that in their .bashrc or write a little
script<br>
<br>
if [ ! -f ~/homework/.lock ]; then<br>
/usr/bin/smbmount //ldap/username ./homework -o noperm<br>
fi<br>
<br>
That would be fine but one thing is they should not have to
open a bash, type anything or double click something. The
reason is that they will never synchronize their folder if
they have to do something. I know, I know, they are academics
:)<br>
Then we would be held responsible for any loss or whatever
went wrong.<br>
<br>
If I put in fstab the mount instruction and they are not
connected to the network, it will "freeze" until it times out.
Can be a pain and a source of complaints. XP was better :(<br>
<br>
Basically what I am looking for as a solution is this:<br>
<br>
a) When the machine gets an ip from the network at work, their
network drive should be automatically mounted. A mount point
will be created on their default install.<br>
<br>
b) When the laptop gets an ip that is not from work, the
"mount instruction" should immediately be ignored.<br>
<br>
c) If the machine is already up and running, but was not
connected to the network, and they connect it to the network,
the drive should be mounted automatically. At this point I
would be able to sync both directories (local and network
"Documents"). I will use a cron job for that. Maybe not the
best solution but I have limited knowledge, so I use what I
know.<br>
<br>
I am thinking there might be a possibility to accomplish what
I described above with pam_auth. If there are authenticated to
the network, the drive is mounted, if not it is not mounted. I
am not sure though if it can be done that way. I still have
some reading to do, but before I continue, I would like to
know if <br>
<br>
1) it's make sense to do it the way I described it<br>
<br>
2) if there is a better solution<br>
<br>
3) what people do in that situation.<br>
</div>
</div>
</blockquote>
<br>
Maybe there are better ways, but in the past I used to install
scripts in the /etc/network directory? This directory has 4
sub-directories, if-down.d, if-post-down.d, if-pre-up.d, and
if-up.d in which you can install scripts to be executed when the
network connection is brought up and/or down. Also, if you use the
network manager then there is the directory
/etc/NetworkManager/dispatcher.d in which I used in the past to run
a script that detected network interface changes and acted upon.
That may help you automate the process.<br>
<br>
Avi<br><br><br>Thank you for the pointer, I will try the solution mentioned above. Yes I use NM.<br>
</div></div>
</div><br>
</body></html>