Good news, my HOWTO explaining my solution has just been approved. The two solutions are complimentary. This script can maintain the status of the shares as their respective servers become available or unavailable, and my script and immediately mount and unmount them when your own network comes up or down (for example, if your laptop has just connected to a wireless network). Useful if you are so impatient that you can't wait up to 120 seconds for the next iteration of this script to come around, or if you want to set this script's idle time much higher but still have instant access when you first connect. My script is here. The crux of the automation is a pair of scripts in the /etc/network/if-(up|down).d directories that get executed whenever the network comes up or down.
The simplest adaptation of this script to that system would be to create the following files and make them executable:
/etc/network/if-up.d/netfs-automount-start
Code:
#!/bin/sh
# start the network automount script in the background
automount &
/etc/network/if-down.d/netfs-automount-stop
Code:
#!/bin/sh
# stop the autmount script
killall automount
# unmount all cifs shares
umount -a -l -t cifs
# unmount all sshfs shares (only if you're using that feature)
umount -l `grep '^sshfs#' /etc/mtab | awk '{print $2}'`
That setup should ensure that the automount script is only running while your computer is connected to the network, and that any shares that are available when the network first comes up are mounted ASAP.
Bookmarks