Eu criei o script para conexão e desconexão de wifi e ethernet
Desligue o Wi-Fi
killall wpa_supplicant
wirelessname='ls /sys/class/net | grep wlan* | head -1'
ifconfig $wirelessname down
Conecte o Wi-Fi
wirelessname='ls /sys/class/net | grep wlan* | head -1'
ifconfig $wirelessname up > /dev/null 2>&1 &
killall wpa_supplicant > /dev/null 2>&1 &
iwconfig $wirelessname power off > /dev/null 2>&1 &
wpa_passphrase > /root/wps.conf
wpa_supplicant -Dwext -i$wirelessname -c/root/wps.conf > /dev/null 2>&1 &
sleep 5
dhclient -r > /dev/null 2>&1 &
dhclient $wirelessname > /dev/null 2>&1 &
Conecte Ethernet
ifconfig $(ip link show | grep eth | grep state | awk '{printf }'| sed -e 's/:$//') up
ifconfig $(ifconfig | grep eth | awk '{print }'| head -1 ) $(ifconfig | grep Bcast | awk '{printf }' | cut -c6-) up
Desconectar ethernet
ifconfig $(ifconfig | grep eth | awk '{print }' | head -1 ) down