What this script does is, check the gateway mac address to find out if you are within your lan or in a different place. If at home, mount a share as normal. If away, mount that share as a ssh file system.
bash |copy code |?
01 #!/bin/bash02 gateway=$(ip route show 0.0.0.0/0 | awk '{print $3}')03 mactest=$(arp -n -a $gateway | awk '{print $4}')04 targetmac="XX:XX:XX:XX:XX:XX"05 homeup="mount -t cifs -o username=USER,password=PASSWORD //SERVER/SHARE /mnt/remote"06 awayup="sshfs my.dyndns.tld:/path/to/share /mnt/remote"07 down="umount -l /mnt/remote"08 if [ $mactest==$targetmac ]09 then10 case "$2" in11 up)12 $homeup13 ;;14 down)15 $down16 ;;17 esac18 else19 case "$2" in20 up)21 $awayup22 ;;23 down)24 $down25 ;;26 esac27 fi28 29 30