dispatch script not working as expected



Hi Everyone.

Thank you in advance for reading this.

I want to mount some shares off my QNAP in my home office. So I found a script[1] that, depending on the MAC of gateway I'm facing, will mount what I want depending on my location. I'm noticing however, that regardless of the MAC that NM is always running the homeupcommand. So I'm guessing either something is wrong that NM isn't making it to my else statement or the part to id the MAC isn't working. And that's where I could use some help. btw I can confirm the script does properly mount the share when I'm in my home office. Also, if I run the away parts in the shell all works as expected.

Does any one know if this script is sound for usage with NM?

I'm on F17 w/NM 0.9.6.4 rel 3.fc17

Thanks,
Phil

references
[1]
#from /etc/NetworkManager/dispatcher.d/50-mount-QNAP
#
gateway=`/usr/sbin/ip route show 0.0.0.0/0 | awk '{print $3}'`
mactest=$(/usr/sbin/arp -n -a $gateway | awk '{print $4}')
targetmac="00:08:9b:cb:7e:42"
homeupcommand="mount /home/plecavalier/QNAP"
homedowncommand="umount /home/plecavalier/QNAP"
awayupcommand="/usr/bin/sshfs admin@<undisclosed_IP>:/share/Public /home/plecavalier/QNAP"
awaydowncommand="/usr/bin/fusermount -u /home/plecavalier/QNAP"
#
#
#
if [ $mactest==$targetmac ]
then
        case "$2" in
                up)
                        $homeupcommand
                ;;
                down)
                        $homedowncommand
                ;;
        esac
else
    case "$2" in
        up)
            $awayupcommand
        ;;
        down)
            $awaydowncommand
        ;;
    esac
fi
exit $?


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]