Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
AE script
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gentoo on PPC
View previous topic :: View next topic  
Author Message
Jimmers
Tux's lil' helper
Tux's lil' helper


Joined: 02 Feb 2005
Posts: 145

PostPosted: Tue Jun 20, 2006 9:32 pm    Post subject: AE script Reply with quote

Now that the Airport Extreme drivers are integrated into the kernel, I thought I'd post this. I've been using some form of this ever since the bcm43xx project became usable. It assumes that you've either already loaded the necessary modules or built them into the kernel, and you've extracted a usable firmware.

Code:
#!/bin/bash

VERSION="0.16"
WLAN="eth1"
LAN="eth0"

mk_entry()
{
        echo "mk_entry() still needs work..."
        RATE=`/sbin/iwlist $WLAN scan | grep -A 5 $1 | grep Rate | egrep -o \:\[0-9\]\* | tr -d :`
        CHANNEL=`/sbin/iwlist $WLAN scan | grep -A 5 $1 | grep Channel | egrep -o \[:\[0-9\]\* | tr -d :`
        echo "Name: $1" >> ${HOME}.known_nets
        echo "Channel: ${CHANNEL}" >> ${HOME}.known_nets
        echo "Rate: ${RATE}M" >> ${HOME}.known_nets
        echo "Does network $1 require WEP encryption?"
        OPTIONS2="yes_128bit yes_64bit no"
        select opt2 in $OPTIONS2
        do
                if [ $opt2 == "no" ]
                then
                        echo
                elif [ $opt2 == "yes_64bit" ]
                then
                        echo "Bit: 64" >> ${HOME}.known_nets
                        echo "Enter the encryption key now in the format: XXXX-XXXX-XX"
                        read KEY
                        echo "Wep: $KEY" >> ${HOME}.known_nets
                elif [ $opt2 == "yes_128bit" ]
                then
                        echo "Bit: 128" >> ${HOME}.known_nets
                        echo "Enter the encryption key now in the format: XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XX"
                        read KEY
                        echo "Wep: $KEY" >> ${HOME}.known_nets
                else
                        echo "choose a real option"
                        echo "Hit enter to see them again"
                fi               
                break
        done
}

wlan_init()
{
        if [ $4 == "NULL" ]
        then
                /sbin/iwconfig $WLAN rate $3 channel $2 essid $1
        else
                /sbin/iwconfig $WLAN rate $3 channel $2 essid $1 enc $4
        fi
        /sbin/dhcpcd $WLAN
        echo "Interface ${WLAN} should be operational now"
}

chk_nets()
{
        echo $1
        if [ `cat ${HOME}.known_nets | grep -c $1` != 0 ]
        then
                CHANNEL=`cat ${HOME}.known_nets | grep -A 4 $1 | grep Channel | egrep -o \[0-9\]\*\$`
                RATE=`cat ${HOME}.known_nets | grep -A 5 $1 | grep Rate | egrep -o \[0-9\]\*\M\$`
                if [ `cat ${HOME}.known_nets | grep -A 5 $1 | grep -c Bit` == 1 ]
                then
                        WKEY=`cat ${HOME}.known_nets | grep -A 5 $1 | grep Wep | egrep -o \[A-F0-9\-\]\*\$`
                else
                        WKEY="NULL"
                fi
                wlan_init $1 $CHANNEL $RATE $WKEY
        else
                mk_entry $1
        fi
}

pre_wlan_init()
{
        /sbin/ifconfig $WLAN up
        LIST=`iwlist $WLAN scan | grep ESSID | egrep -o \"\[a-zA-Z0-9\s\]\*\"\$`
        echo "Select withc network you'd like to join"
        echo "Or hit 'rescan' to scan again"
        OPTIONS1="$LIST rescan quit"
        select opt1 in $OPTIONS1
        do
                if [ $opt1 == "rescan" ]
                then
                        pre_wlan_init
                elif [ $opt1 == "quit" ]
                then
                        echo "Quitting..."
                        exit
                else                       
                        opt1g=`echo $opt1 | tr -d \"`
                        chk_nets $opt1g
                        exit
                fi
        done
}

pre_wlan_dinit()
{
        /sbin/dhcpcd -k $WLAN
        /sbin/ifconfig $WLAN down
        echo "Interface $WLAN should be down"
}

clear
echo "Welcom to ifspec v.$VERSION"
echo "The constantly morphing network interface specification tool"
echo
echo "What would you like to do?"
OPTIONS0="init_lan kill_lan init_wlan kill_wlan quit"
select opt0 in $OPTIONS0
do
        if [ $opt0 == "init_lan" ]
        then
                /etc/init.d/net.${LAN} start
        elif [ $opt0 == "kill_lan" ]
        then
                /etc/init.d/net.${LAN} stop
        elif [ $opt0 == "init_wlan" ]
        then
                pre_wlan_init
        elif [ $opt0 == "kill_wlan" ]
        then
                pre_wlan_dinit
        elif [ $opt0 == "quit" ]
        then
                echo "Quiting..."
                exit
        else
                echo "Please select a real option"
                echo "Hit 'enter' to see options again"
        fi
done


EDIT: Suggestions and problems welcome
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo on PPC All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum