You are not logged in.
Pages: 1
Hi,
I am attempting to automate nfs mounts upon succesful connection of an openvpn client to an openvpn server. I am using network manager dispatcher to accomplish this task.
here is my 30_nfs.sh:
#!/bin/bash
SERVER="VPN CONNECTION NAME GOES HERE"
MOUNT_POINTS=$(sed -e '/^.*#/d' -e '/^.*:/!d' -e 's/\t/ /g' /etc/fstab | tr -s " " | cut -f2 -d" ")
VPNSTAT=$(nmcli con status | grep demon $SERVER | tr -s ' ' | cut -f 5 -d ' ') 2>/dev/null
if [[ "$VPNSTAT" = "yes" ]]; then
# The vpn connection is established, make sure the shares are mounted
for mntpnt in ${MOUNT_POINTS}; do
mountpoint -q $mntpnt || mount $mntpnt
done
else
# The vpn connection is down, unmount the shares
for umntpnt in ${MOUNT_POINTS}; do
umount -l -f $umntpnt &>/dev/null
done
fi
Have I scripted this correctly? Does NetworkManager dispatcher listen for vpn connection? If not how would I be able to automate nfs mounts upon the establishment of the vpn connection.
Thanks in advance
Offline
A few tips:
- you can use vpn-up and vpn-down to act upon vpn connection activation/deactivation,
- $CONNECTION_UUID contains the connection uuid,
- "mount -a -t nfs4" would mount all nfs4 filesystems specified in fstab without "noauto",
- "umount -a -l -t nfs4" would unmount all nfs4 filesystems,
- peek at https://bbs.archlinux.org/viewtopic.php … 0#p1410970
Offline
Thanks for the quick response.
That is good advice I will try it as soon as I get some time tonight, and post my script.
Offline
Here's a thought. Have you considered using autofs? I am not sure whether it works over VPN, but I use autofs for automatic mounting of NFS shares and it works very well.
Geek, runner, motorcyclist and professional know-it-all
Offline
Pages: 1