On Fri, 24 May 2019 12:46:17 -0600 Michael Torrie <[email protected]> wrote:
> On 05/24/2019 07:44 AM, Barry Roberts wrote: > > I don't un-dock my laptop at work much, it's practically just a > > desktop. But when I do, it would be nice if the cifs-mounted > > shares I normally use would handle the switch between wired and > > wifi better. Some wifi networks at work allow me to access to some > > of the cifs servers, some don't. And none of them are available at > > home unless I connect to the VPN. It would be nice if there was an > > automounter that just handled all that for me. It's annoying to > > accidentally hit tab and have a bash prompt hang for minutes > > because I forgot I can't use that mount from here. > > > > I'm old-school, so I'm still using /etc/fstab, but I would switch to > > autofs or systemd if they automatically and gracefully handled > > switching networks. It seems to me systemd doesn't do that, but I > > can't decide about autofs. It's lazy mount and auto-unmount might > > give me similar results. But I wondered if I'm just missing some > > docs., orr if there are some cool nm event scripts already around > > to un-mount and remount network shares when the network changes. > > I know you can write custom scripts that run when an interface goes up > or down. That might partially help. But the interface won't know > whether or not the share is available on that particular wifi network. > I suppose the script could check to see what SSID it's attached to and > decide whether the share is accessible or not. Might work anyway. Right. That's more or less what I do on my laptops. I have two configurations, home and foreign. I use the ssid to detect the difference. And if it's an Ethernet connection, it's presumed foreign. I also have separate shorewall (firewall) configurations, deployed from this script. And some other goodies. First thing to do is detect the interface and any ssid. The action being performed (up, ipv6-change, etc) is passed in as a parameter. Once you have the interface and ssid, everything is a case statement using the action. All of this is in a script, 50ifupdown, which lives in /etc/NetworkManager/dispatcher.d. I use it with Network Manager, but you can probably adapt it to other connection managers. -- "When we talk of civilization, we are too apt to limit the meaning of the word to its mere embellishments, such as arts and sciences; but the true distinction between it and barbarism is, that the one presents a state of society under the protection of just and well-administered law, and the other is left to the chance government of brute force." - The Rev. James White, Eighteen Christian Centuries, 1889 Key fingerprint = CE5C 6645 A45A 64E4 94C0 809C FFF6 4C48 4ECD DFDB https://charlescurley.com /* PLUG: http://plug.org, #utah on irc.freenode.net Unsubscribe: http://plug.org/mailman/options/plug Don't fear the penguin. */
