Paste number 134392: untitled

Paste number 134392: untitled
Pasted by: bdfy
When:9 years, 10 months ago
Share:Tweet this! | http://paste.lisp.org/+2VP4
Channel:None
Paste contents:
Raw Source | XML | Display As
#!/bin/sh
#
# /etc/rc.d/wifi: start/stop network
#

# ifconfig -a|grep wlan|awk '{print $1}'

if ifconfig -a|grep wlan2 &> /dev/null; then
    _iface=wlan2
    else _iface=wlan0
fi
#_iface=wlan0
_oldmacfl=/var/tmp/oldmac
if [ ! -f $_oldmacfl ]
    then ifconfig -a |grep $_iface|awk '{print $5}' > $_oldmacfl
fi

case $1 in
start)
    # loopback
    /sbin/ip addr add 127.0.0.1/8 dev lo broadcast + scope host
    /usr/bin/macchanger -m 2e:a3:d4:ab:d2:1f $_iface
    /usr/bin/macchanger -r $_iface
    /sbin/ip link set lo up
# wpa_supplicant + wlan0 connection
    /usr/sbin/wpa_supplicant -B -Dwext -i${_iface} -c/etc/wpa_supplicant.conf
#   /sbin/dhcpcd -t 5 -h $HOSTNAME $_iface
    /sbin/dhclient $_iface
    cat > /etc/resolv.conf << "EOF"
nameserver 208.67.222.222
nameserver 208.67.220.220
EOF
    ;;
stop)
#   /usr/bin/killall -q /sbin/dhcpcd
    /usr/bin/killall -q /sbin/dhclient
    /usr/bin/killall -q /usr/sbin/wpa_supplicant
    /sbin/ip link set lo down
    /sbin/ip addr del 127.0.0.1/8 dev lo
    /usr/bin/macchanger -m $(cat $_oldmacfl) $_iface
cat > /etc/resolv.conf << "EOF"
nameserver 208.67.222.222
nameserver 208.67.220.220
EOF
    ;;
restart)
    $0 stop
    $0 start
    ;;
*)
    echo "usage: $0 [start|stop|restart]"
    ;;
esac

# End of file

This paste has no annotations.

Colorize as:
Show Line Numbers

Lisppaste pastes can be made by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively.