Guest

nephix

By: a guest on Apr 4th, 2008  |  syntax: Bash  |  size: 1.28 KB  |  hits: 44  |  expires: Never
download  |  raw  |  embed  |  report abuse
Copied
  1. #!/bin/sh
  2. #
  3. # description:  This small start/stop-script will let you control
  4. #               your wpa_supplicant application to handle its correct
  5. #               usage.
  6. # @name:        wpa_supplicant.sh
  7. # @author:      Thomas Pischulski <Thomas.Pischulski@mailbox.tu-dresden.de>
  8. # @expanded:    Alexander Hagenah <ah@primepage.de>
  9. # @created:     04/02/2008
  10.  
  11.  
  12. # VARIABLES
  13. # Edit them to match your system settings
  14. DEVICE="wlan0"
  15. CONFIG="/etc/wpa_supplicant/wpa_supplicant.conf"
  16. USERID=`id -u`
  17. ANSWER=""
  18.  
  19.  
  20. if [ $USERID != 0 ]; then
  21.         echo "You're not root"
  22.         exit 0
  23.  
  24. else
  25.         case "$1" in
  26.                 "start")
  27.                         WPAPID=`pidof wpa_supplicant`
  28.                         if [ $? -eq 0 ]; then
  29.                                 echo "wpa_supplicant process still running."
  30.                                 echo "Kill it? [y/n] "
  31.                                 read ANSWER
  32.  
  33.                                 case "$ANSWER" in
  34.                        
  35.                                         "y"|"Y")
  36.                                                 kill -9 $WPAPID
  37.                                         ;;
  38.  
  39.                                         "n"|"N")
  40.                                                 echo "Could not start wpa_supplicant because another"
  41.                                                 echo "process is still running. Exiting.."
  42.                                                 exit 0
  43.                                         ;;
  44.  
  45.                                         *)
  46.                                                 echo "Answer not allowed. Exiting.."
  47.                                                 exit 0
  48.                                 esac
  49.                         fi
  50.                                
  51.                         ifconfig $DEVICE up
  52.                         wpa_supplicant -dd -B -c $CONFIG -i $DEVICE -D wext
  53.                         dhclient $DEVICE
  54.                 ;;
  55.  
  56.                 "stop")
  57.                         ifconfig $DEVICE down
  58.                         killall wpa_supplicant
  59.                 ;;
  60.  
  61.                 *) echo "No argument given. Usage: wlanfrz (start|stop)";
  62.         esac
  63. fi