#!/bin/sh
#2007 Lesser GPL licence v2 (http://www.fsf.org/licensing/licenses/lgpl.html)
#wizard to setup wireless

BUTTONS="Setup_ndiswrapper:10,Run_WAG:11,EXIT:19"

if [ "`which perl`" ];then
 MSG01="GOOD: It seems that Perl is available, and Perl is needed to install the
      Windows driver for the wireless card. You now have three choices:

CHOICE 1: ndiswrapper
Note that Perl is only required during installation of the driver.
Okay, that is one requirement out of two! Now, do you have the CD that came with
the wireless card? If so, click the \"Setup_ndiswrapper\" button...

CHOICE 2: wifi-beta.pup
If you do not have the XP driver for the card, Bladehunter (Forum name) has
developed wifi-beta.pup, a DotPup package that enables you to use ndiswrapper
without requiring Perl. But, it only works for certain wifi cards. Find out more
and to download, go to the Announcements section of the Puppy Forum. Download
it, install it (it is a DotPup package, so after downloading it, you just click
on it to install it), then run this Wizard again. 
Please click \"EXIT\" button if wifi-beta.pup not installed...
Please click \"Run_WAG\" button if wifi-beta.pup is installed...

CHOICE 3: Use a Linux driver
Many wifi cards have a Linux driver module and some are installed in Puppy, and
more can be found if you go to the Announcements section of the Puppy Forum.
Quit this Wizard, install a driver, load it with modprobe, then run this Wizard.
Please click \"EXIT\" button only..."
else
 MSG01="BAD: ndiswrapper needs Perl to install the Windows card driver,
     and Perl is not installed in Puppy. You now have three choices:

CHOICE 1: Install Perl via usr_devx.sfs
Click the \"EXIT\" button to quit this script. You must install Perl first, before
running this Wizard. It is easy to do: just download usr_devx.sfs, that you will
find via the Puppy download page (one day I will get this script to do it!),
download it to /mnt/home (unless /mnt/home is a NTFS partition, then you have to
boot Windows and download it to C: drive). Or, if you have a full hard drive
installation of Puppy (Option-2) then place usr_devx.sfs at /. After downloading
usr_devx.sfs, reboot Puppy, then run this Wireless Wizard again.
Note 1: Perl is only required during installation of the card driver.
Note 2: usr_devx.sfs is 43M so if on dialup you may want CHOICE 1b, 2 or 3.
Please click \"EXIT\" button only...

CHOICE 1b: Install Perl via PupGet
As above, but there is a Perl PupGet package, that is only a 924K download.
Choose this if on dialup, or not interested in the compiling tools provided by
usr_devx.sfs. After installing the wireless driver, Perl may be uninstalled.
Please click \"EXIT\" button only...

CHOICE 2: Install wifi-beta.pup
This is a package developed by Bladehunter (Forum name) that enables you to use
ndiswrapper without requiring Perl at all. This works for certain wireless cards
only -- go to the Announcements section of the Puppy Forum for more information
and a download link. Download it, install it (it is a DotPup package, so after
downloading it, you just click on it to install it), then run this Wizard again.
Please click \"EXIT\" button if wifi-beta.pup not installed...
Click \"Run_WAG\" button if wifi-beta.pup installed...

CHOICE 3: Use a Linux driver
Many wifi cards have a Linux driver module and some are installed in Puppy, and
more can be found if you go to the Announcements section of the Puppy Forum.
Quit this Wizard, install a driver, load it with modprobe, then run this Wizard
and click on \"Run_WAG\" button.
Please click \"EXIT\" button only..."
fi

if [ "`iwconfig | grep "Signal level"`" = "" ];then
 #BUTTONS="Setup_ndiswrapper:10,EXIT:19"
 MSG11="$MSG01"
else
 #BUTTONS="Run_WAG:11,EXIT:19"
 MSG11="VERY GOOD:
It seems that you already have a working wireless interface, so go ahead and
click on the \"Run_WAG\" button to establish connectivity with a wireless
network. WAG is an acronym for Wireless Access Gadget and is a brilliant
program developed by keenerd (Forum name). 

Click the \"Run_WAG\" button now..."
fi

 xmessage -bg "light yellow" -center -name "wirelesswizard" -title "wirelesswizard: Welcome" -buttons "$BUTTONS" "Welcome to the Puppy Wireless Networking Wizard!
NOTE: if you have a physical Ethernet cable plugged into your PC, this is the
      wrong Wizard! Click \"EXIT\" button, and run the Ethernet Wizard....

$MSG11
"

case ${?} in
 10)
  echo "ndiswrapper"
  ;;
 11)
  exec /usr/sbin/wag
  ;;
 *)
  exit
  ;;
esac

#ndiswrapper setup...
xmessage -bg "light yellow" -center -name "wirelesswizard" -title "wirelesswizard: Ndiswrapper" -buttons "Run_WAG:10,EXIT:19" "Early days with this Wizard. For now the ndiswrapper setup is manual.

Follow these instructions, write them down if necessary.
If the ndiswrapper does not work, which is possible, you will need to find
a specific Linux driver for your wireless card. Look on the Forum and Wiki
for further information on that.
Here are the steps:

1. Mount the CD supplied with the wireless card.
2. Open a terminal in the XP drivers folder on the CD. Then type these:
3. # ndiswrapper -i drivername.inf        ...this creates /etc/ndiswrapper/
   (substitute the actual .inf filename for drivername.inf)
4. # ndiswrapper -l                  ...this tests status of installed driver.
   (that is the letter l, not the numerical 1)
5. # modprobe ndiswrapper            ...this loads the module
6. # iwconfig                        ...tests if interface available

After Step 6, if it does look like you have a functioning wireless interface,
go ahead and click the \"Run_WAG\" button...
If one of the steps failed, click \"EXIT\" button..."

case ${?} in
 10)
  exec /usr/sbin/wag
  ;;
 *)
  exit
  ;;
esac


###END###
