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
# 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
# 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.