Revision: 32138
Updated Code
at September 19, 2011 15:59 by nathwill
Updated Code
#!/bin/bash
gateway=$(ip route show 0.0.0.0/0 | awk '{print $3}')
mactest=$(arp -n -a $gateway | awk '{print $4}')
targetmac="XX:XX:XX:XX:XX:XX"
homeup="mount -t cifs -o username=USER,password=PASSWORD //SERVER/SHARE /mnt/remote"
awayup="sshfs my.dyndns.tld:/path/to/share /mnt/remote"
down="umount -l /mnt/remote"
if [ $mactest==$targetmac ]
then
case "$2" in
up)
$homeup
;;
down)
$down
;;
esac
else
case "$2" in
up)
$awayup
;;
down)
$down
;;
esac
fi
exit $?
Revision: 32137
Updated Code
at September 19, 2011 15:21 by nathwill
Updated Code
#!/bin/bash
gateway=$(ip route show 0.0.0.0/0 | awk '{print $3}')
mactest=$(arp -n -a $gateway | awk '{print $4}')
targetmac="XX:XX:XX:XX:XX:XX"
homeup="mount -t cifs -o username=USER,password=PASSWORD //SERVER/SHARE /mnt/remote"
awayup="sshfs my.dyndns.tld:/path/to/share /mnt/remote"
down="umount /mnt/remote"
if [ $mactest==$targetmac ]
then
case "$2" in
up)
$homeup
;;
down)
$down
;;
esac
else
case "$2" in
up)
$awayup
;;
down)
$down
;;
esac
fi
exit $?
Revision: 32136
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at September 19, 2010 07:29 by nathwill
Initial Code
#!/bin/bash
gateway=`ip route show 0.0.0.0/0 | awk '{print $3}'`
mactest=$(arp -n -a $gateway | awk '{print $4}')
targetmac="00:00:00:00:00:00"
upcommand="mount /media/net"
downcommand="umount /media/net"
if [ $mactest==$targetmac ]
then
case "$2" in
up)
$upcommand
;;
down)
$downcommand
;;
esac
fi
exit $?
Initial URL
http://nathanewilliams.com/
Initial Description
updated...
Initial Title
Network Event Triggered Bash Script
Initial Tags
event, Bash, script
Initial Language
Bash