From 20c5c1e991ab5fdf4a2f5f95b945819e98f11202 Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Tue, 25 Feb 2014 22:06:48 +1300 Subject: [PATCH] Add in VPN support and make sure obnam is dead... --- NetworkManager/dispatcher.d/20network-shares | 27 +++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/NetworkManager/dispatcher.d/20network-shares b/NetworkManager/dispatcher.d/20network-shares index 1ab0f3b..d93f86c 100755 --- a/NetworkManager/dispatcher.d/20network-shares +++ b/NetworkManager/dispatcher.d/20network-shares @@ -5,14 +5,18 @@ targetuuid=c7090012-2327-4cf0-a703-2d99ecf93df7 vpnuuid=44774b0a-aa38-45d7-841c-476c82837eb5 gateway=$(ip route show 0.0.0.0/0 | awk '{print $3}') -mactest=$(arp -n -a $gateway | awk '{print $4}') +if [ "x$gateway" != "x" ] +then + ping -c 1 $gateway + mactest=$(arp -n -a $gateway | awk '{print $4}') +fi date >> /tmp/nm.set - $1 >> /tmp/nm.set + echo "$1 $2" >> /tmp/nm.set set >> /tmp/nm.set echo >> /tmp/nm.set case "$2" in - up) + up|vpn-up) if [ "$CONNECTION_UUID" == "$targetuuid" -o "$CONNECTION_UUID" == "$vpnuuid" -o "$mactest" == "$targetmac" ] then echo "Start" >> /tmp/nm.set @@ -21,14 +25,24 @@ case "$2" in # Add any network shares the users may have bookmarked. for user in $(ls /home/*/.gtk-bookmarks | sed 's/\/home\///; s/\/.*//') do - sudo -u $user /usr/local/bin/network-bookmarks-add + sudo -u $user /usr/bin/network-bookmarks-add done + else + echo "On a foreign network, make sure we clean up" >> /tmp/nm.set + for user in $(ls /home/*/bin/network-bookmarks-remove | sed 's/\/home\///; s/\/.*//') + do + sudo -u $user /home/$user/bin/network-bookmarks-remove + done + + /etc/init.d/autofs stop + killall obnam + for x in $(mount | grep Network | sed 's/^.* on //; s/ type .*//' | sort -r); do umount -l $x; done fi # Cups doesn't always pickup that printers have appeared. /etc/init.d/cups restart ;; - down) + down|vpn-down) if ping -q -c 1 $gateway > /dev/null then echo "Lies, our gateway - $gateway - is still up" >> /tmp/nm.set @@ -38,11 +52,12 @@ case "$2" in # Remove any network shares the users may have bookmarked. for user in $(ls /home/*/.gtk-bookmarks | sed 's/\/home\///; s/\/.*//') do - sudo -u $user /usr/local/bin/network-bookmarks-remove + sudo -u $user /usr/bin/network-bookmarks-remove done # Autofs, your job is done. /etc/init.d/autofs stop + killall obnam # Lazy unmount the Network shares, as they may be busy and autofs stopping # doesn't remove them. -- 2.30.2