Debian wireless menu

Here's how I setup my wireless on Debian.

Firstly, create a script in /usr/local/bin called wireless-mapping or something similar. Make sure the dialog package is installed.

#!/bin/bash

if [ -f /etc/default/wireless ] ; then
    . /etc/default/wireless
else
    echo Please setup /etc/default/wireless
fi

for profile in $WIRELESS_PROFILES
do
  LOCATION_NAME=$profile\_NAME
  LOCATION_DESCR=$profile\_DESCR

  DIALOG_ARGS="$DIALOG_ARGS \"${!LOCATION_NAME}\" \"${!LOCATION_DESCR}\""
done

LOCATION=`eval dialog --stdout --menu \"Select your wireless location\" 10 50 5 $DIALOG_ARGS`

echo eth2-$LOCATION

Then create a file /etc/default/wireless where you put descriptions of your wireless networks. Put each of your networks in WIRELESS_PROFILES and then setup a name and a description, like below.

#WIRELESS OPTIONS

WIRELESS_PROFILES="home keg nicta"

home_NAME="home"
home_DESCR="At home"

keg_NAME="keg"
keg_DESCR="keg private"

nicta_NAME="nicta"
nicta_DESCR="nicta (hack)"

Finally, you need to make the mapping in /etc/network/interfaces for each network. It should look something like this.

mapping eth2
    script /usr/local/bin/wireless-mapping

iface eth2-keg inet dhcp
      wireless-essid keg
      wireless-key [key]

iface eth2-home inet dhcp
      wireless-essid wienand
      wireless-key [key]

iface eth2-nicta inet dhcp
      wireless-essid nicta_wireless

Notice how the mapping for your ethernet card is the script, and then you have a bunch of interfaces defined as interface-name, where name is the name you chose in the /etc/defaults/wireless script.

All going well, next time you ifup eth2 you should see something like this

Dialog selecting wireless interfaces on Debian