parent
574a38a2e6
commit
088015a1a0
|
@ -0,0 +1,68 @@
|
|||
#!/bin/bash /usr/lib/turtle/turtle_module
|
||||
VERSION="1.1"
|
||||
DESCRIPTION="Clone Client's MAC address into WAN interface"
|
||||
AUTHOR="Shad"
|
||||
|
||||
: ${DIALOG_OK=0}
|
||||
: ${DIALOG_CANCEL=1}
|
||||
: ${DIALOG_HELP=2}
|
||||
: ${DIALOG_EXTRA=3}
|
||||
: ${DIALOG_ITEM_HELP=4}
|
||||
: ${DIALOG_ESC=255}
|
||||
|
||||
function configure {
|
||||
dialog --title "clomac" --msgbox "\n\
|
||||
(\___/) \n\
|
||||
(='.'=) Nothing to configure here.\n\
|
||||
(\")_(\")\ \n\
|
||||
" 9 72
|
||||
}
|
||||
|
||||
|
||||
function start {
|
||||
if [ "`grep clomac /etc/dnsmasq.conf`" == "" ]; then
|
||||
echo "dhcp-script=/tmp/clomac_pivot" >> /etc/dnsmasq.conf
|
||||
fi
|
||||
echo "#!/bin/bash" > /tmp/clomac_pivot
|
||||
echo "/etc/turtle/modules/clomac start" >> /tmp/clomac_pivot
|
||||
chmod 755 /tmp/clomac_pivot
|
||||
echo "debug" >> /tmp/clomac.debug
|
||||
|
||||
CLIENT_MAC="`cat /tmp/dhcp.leases | tail -1 | awk '{ print $2; }'`"
|
||||
if [ "$CLIENT_MAC" != "" ]; then
|
||||
if [ "$CLIENT_MAC" != "`macchanger -s eth1 | awk '{ print $3; }'`" ]; then
|
||||
ifconfig eth1 down
|
||||
macchanger -s eth1 | awk '{ print $3; }' > /tmp/clomac.srcmac
|
||||
macchanger -m "$CLIENT_MAC" eth1
|
||||
ifconfig eth1 up
|
||||
sleep 1
|
||||
ETH1_IP="`ifconfig eth1 | grep "inet addr"`"
|
||||
if [ "$ETH1_IP" == "" ]; then
|
||||
killall -9 udhcpc
|
||||
udhcpc -p /var/run/udhcpc-eth1.pid -s /lib/netifd/dhcp.script -f -t 0 -i eth1 -C
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
function stop {
|
||||
if [ "`grep clomac /etc/dnsmasq.conf`" != "" ]; then
|
||||
cp /etc/dnsmasq.conf /etc/dnsmasq.conf.back
|
||||
cat /etc/dnsmasq.conf.back | grep -v clomac > /etc/dnsmasq.conf
|
||||
fi
|
||||
rm -f /tmp/clomac_pivot
|
||||
ifconfig eth1 down
|
||||
macchanger -m `cat /tmp/clomac.srcmac` eth1
|
||||
ifconfig eth1 up
|
||||
}
|
||||
|
||||
|
||||
function status {
|
||||
if [ "`grep clomac /etc/dnsmasq.conf`" == "" ]; then
|
||||
echo 0
|
||||
elif [ -e /tmp/clomac_pivot ]; then
|
||||
echo 1
|
||||
fi
|
||||
}
|
||||
|
Loading…
Reference in New Issue