Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
About try to making Airport Extreme connection shell 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
terry
n00b
n00b


Joined: 27 Jul 2002
Posts: 64
Location: Korea Seoul

PostPosted: Wed Sep 06, 2006 4:36 am    Post subject: About try to making Airport Extreme connection shell script Reply with quote

Hi

I am tring to make some script for bcm43xx(bcm4318) wireless.
(I don't know well abut shell script)
That script is
Code:
#!/bin/sh
#####################################################
#    For My bcm43xx wireless
#####################################################
declare -a WLIST
declare -a ALIST
declare -a CLIST
declare -i es
declare -i s
declare -i si
function setwireless {
   echo "rmmod bcm43xx"
   rmmod bcm43xx
   echo "modprobe bcm43xx"
   modprobe bcm43xx
   echo "ifconfig eth1 up"
   ifconfig eth1 up
   echo "iwconfig eth1 ap \"$2\""
   iwconfig eth1 ap "$2"
   echo "iwconfig eth1 channel \"$3\""
   iwconfig eth1 channel "$3"
   echo "iwconfig eth1 essid \"$1\" mode managed"
   iwconfig eth1 essid "$1" mode managed
}

function add_wpa {
   echo "network={"
   echo "         ssid=\"$1\""
   echo "         priority=6"
   echo "         key_mgmt=NONE"
   if [ $2 ]; then
      echo "         wep_key0=$2"
      echo "         wep_kx_keyidx=0"
   fi
   echo "}"
}

rmmod bcm43xx
modprobe bcm43xx
ifconfig eth1 up

echo "" > .wlist
echo "Scaned ESSID List is"
iwlist eth1 scan | tee .encrypt_chk | grep ESSID | awk -F: '{print $2}'| sed s/\"//g | while read fn
do
   s=$[$s+1]
   WLIST[$s]="$fn:"
   echo "${WLIST[@]}" > .wlist
done


for enc in `cat .encrypt_chk | grep Encryption | sed s/Encryption\ //g `
do
   si=$[$si+1]
   CLIST[$si]="$enc"
#   echo "$s : ${CLIST[$s]}"
done

for enc in `cat .encrypt_chk | grep Channel | sed s/Channel://g `
do
   sp=$[$sp+1]
   PLIST[$sp]="$enc"
#   echo "$s : ${CLIST[$s]}"
done


for kenc in `cat .encrypt_chk | grep Address | sed s/Address:\ /Address:/g | awk -F: '{print $2":"$3":"$4":"$5":"$6":"$7}' `
do
   sj=$[$sj+1]
   ALIST[$sj]="$kenc"
#   echo "$sj : ${ALIST[$sj]}"
done


IFS=":"

#s="0"

for new in `cat .wlist| sed s/:\ /:/g`
do
   s=$[$s+1]
   WLIST[$s]="$new"
   echo "$s : ${WLIST[$s]} - Encryption ${CLIST[$s]} with ${ALIST[$s]} MAC"
done

if [ $s ]
then

   IFS=""
   echo "Which want to ESSID access try to"
   echo -n "Type Number : "
   read -s -n 1 es
   echo $es
   
   
   if [ "${WLIST[$es]}" ]; then
      wpa=$(grep ${WLIST[$es]} /etc/wpa_supplicant.conf)
      if [ "$wpa" ]; then
         wpa_returned=$(setwireless ${WLIST[$es]} ${ALIST[$es]} ${PLIST[$es]})
         echo $wpa_returned
         echo "wpa_supplicant -i eth1  -D wext -w -c /etc/wpa_supplicant.conf"
         wpa_supplicant -i eth1 -D wext -w -c /etc/wpa_supplicant.conf
         
      else
         echo "You need to add ESSID setting in /etc/wpa_supplicant.conf"
         echo "Do you want to add ${WLIST[$es]} ESSID Setting?"
         echo -n "[Y]es or No(Enter): "
         read -s -n 1 want
         case $want in
            Y | y | YES | yes | Yes )
               echo "Yes"
               echo "Ok you want to add ${WLIST[$es]}"
               echo "Dose ESSID ${WLIST[$es]} need to  wep key setting?"
               case ${CLIST[$es]} in
                  key:on )
                     echo -n "Type web key or Enter(no web key) : "
                     read webkey
                     ;;
               esac
               echo "---------------------"
               add_wpa ${WLIST[$es]} $webkey
               echo "---------------------"
               echo "Do you want to add these setting"
               echo -n "Type [Y]es or No(Enter) : "
               read -s -n 1 webkey_add
               case $webkey_add in
                  Y | y | YES | yes | Yes )
                     add_wpa ${WLIST[$es]} $webkey  >> /etc/wpa_supplicant.conf
                     setwireless ${WLIST[$es]} ${ALIST[$es]} ${PLIST[$es]}
                     echo "wpa_supplicant -i eth1  -D wext -w -c /etc/wpa_supplicant.conf"
                     wpa_supplicant -i eth1 -D wext -w -c /etc/wpa_supplicant.conf
                     ;;
                  * )
                     echo  "No"
               esac
               ;;
            * )
               echo "No"
               ;;
         esac
      fi
   else
      echo "You chose Wrong ESSID!!!"
   fi
else
   echo "There is No Ap Scaned"
   break
fi

After I am using that script, I have to run "dhclient eth1" manually.

Is there method input "dhclient eth1" put inside shell script.
(I try to , but fail)

Any help is welcome. :-)

Thanks
Back to top
View user's profile Send private message
timotheus25
Apprentice
Apprentice


Joined: 27 Dec 2005
Posts: 162
Location: *upstate* New York, USA

PostPosted: Thu Sep 07, 2006 6:06 am    Post subject: Reply with quote

I use the standard rc scripts to bring up my airport extreme, with some tricks in the postup, preup, hooks in /etc/conf.d/net.

Make sure that you installed net-misc/dhcp. When rc requests a DHCP address on my wireless, it uses the command (as root of course):
Code:

/sbin/dhclient -q -cf /etc/dhcp/dhclient.conf -e PEER_ROUTERS=yes -e PEER_DNS=yes -e PEER_NTP=yes -e IF_METRIC=2000 -q -1 -pf /var/run/dhclient-eth1.pid eth1


You can do:
Code:

setsid COMMAND &

to force it into the background if you wish.
_________________
http://tstotts.net/linux/gentoopb.html
http://tstotts.net/linux/gentooinsp640m.html
Back to top
View user's profile Send private message
timotheus25
Apprentice
Apprentice


Joined: 27 Dec 2005
Posts: 162
Location: *upstate* New York, USA

PostPosted: Thu Sep 07, 2006 8:11 am    Post subject: Reply with quote

I've just updated the following document to show details of how I use the standard rc scripts to initialize my Airport Extreme (bcm43xx -- 4306), making it behave just like any other wired/wireless interface.
http://tstotts.net/linux/gentoopb.html#d7e447a1900

YMMV.
_________________
http://tstotts.net/linux/gentoopb.html
http://tstotts.net/linux/gentooinsp640m.html
Back to top
View user's profile Send private message
terry
n00b
n00b


Joined: 27 Jul 2002
Posts: 64
Location: Korea Seoul

PostPosted: Thu Sep 07, 2006 2:43 pm    Post subject: Reply with quote

timotheus25 wrote:
I've just updated the following document to show details of how I use the standard rc scripts to initialize my Airport Extreme (bcm43xx -- 4306), making it behave just like any other wired/wireless interface.
http://tstotts.net/linux/gentoopb.html#d7e447a1900

YMMV.

Thanks, but my bcm4318(last 15" powerbook) doesn't work well with your method.
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