rendered paste body#!/bin/bash
. /etc/rc.conf
. /etc/rc.d/functions
WLAN_DEVICE=wlan0
SSID=gripir
WEPKEY=30:32:39:35:34:38:39:37:34:33:31:31:39
AUTHTYPE=opensystem
###Load module (prism2_pci for pci devices)
MOD="modprobe prism2_usb prism2_doreset=1"
###Reset Card
RESET="wlanctl-ng $WLAN_DEVICE lnxreq_ifstate ifstate=enable"
###SETUP FOR WEP AND THEN CONNECT
S1="wlanctl-ng $WLAN_DEVICE dot11req_mibset mibattribute=dot11WEPDefaultKeyID=0"
S2="wlanctl-ng $WLAN_DEVICE dot11req_mibset mibattribute=dot11ExcludeUnencrypted=true"
S3="wlanctl-ng $WLAN_DEVICE dot11req_mibset mibattribute=dot11PrivacyInvoked=true"
S4="wlanctl-ng $WLAN_DEVICE dot11req_mibset mibattribute=dot11WEPDefaultKey0=${WEPKEY}"
S5="wlanctl-ng $WLAN_DEVICE lnxreq_autojoin ssid=${SSID} authtype=${AUTHTYPE}"
###Static IP
#IP=192.168.0.1
#IPGW=255.255.255.0
#STATIC=`ifconfig $WLAN_DEVICE $IP`
#route add default gw $IPGW
###DHCP
DHCP="dhcpcd $WLAN_DEVICE"
case "$1" in
start)
stat_busy "Starting WLAN"
${MOD} && ${RESET} && ${S1}&& ${S2} && ${S3} && ${S4} && ${S5} && ${DHCP}
if [ $? -gt 0 ]; then
stat_fail
else
add_daemon wlan
stat_done
fi
;;
stop)
stat_busy "Stopping WLAN"
if [ -f /var/run/dhcpcd-${WLAN_DEVICE}.pid ]; then
kill `cat /var/run/dhcpcd-${WLAN_DEVICE}.pid`
else
/sbin/ifconfig ${WLAN_DEVICE} down
fi
if [ $? -gt 0 ]; then
stat_fail
else
rm_daemon wlan
stat_done
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "usage: $0 {start|stop|restart}"
esac
exit 0