home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / share / doc / wpasupplicant / examples / wpasupplicant.init-daemon < prev   
Encoding:
Text File  |  2006-08-11  |  3.6 KB  |  129 lines

  1. #!/bin/sh
  2.  
  3. # Buyer beware! This is really only useful if you want to use
  4. # wpasupplicant in roaming mode. 
  5. #
  6. # PLEASE READ /usr/share/doc/wpasupplicant/README.modes for 
  7. # details of the modes of operation of wpasupplicant.
  8. #
  9.  
  10. # To activate the wpasupplicant daemon, set ENABLE_ROAMING_MODE to 1
  11.  
  12. ENABLE_ROAMING_MODE=0
  13.  
  14. # Location of the wpa_supplicant.conf configuration file to be used
  15. # by the daemon.
  16. #
  17. # See the wpa_supplicant.conf(5) manpage for detailed information
  18. # about the wpa_supplicant configuration file. Example configuration
  19. # files are located at /usr/share/doc/wpasupplicant/examples.
  20. #
  21. # Failure to set CONFIG to the full pathname of your configuration
  22. # file will cause the daemon to exit immediately.
  23.  
  24. CONFIG=""
  25.  
  26. # Specify the network interface that the daemon will attach to.
  27. #
  28. # Examples: INTERFACE="eth1"
  29. #           INTERFACE="ath0"
  30. #
  31. # Failure to set INTERFACE to a valid network interface name will
  32. # cause the daemon to fail or exit immediately.
  33.  
  34. INTERFACE=""
  35.  
  36. # DRIVER specifies the driver type of the interface defined above.
  37. #
  38. # If DRIVER is not set, the daemon will default to the "wext" driver
  39. #
  40. # Currently, the following drivers are supported:
  41. #  hostap = Host AP driver (Intersil Prism2/2.5/3)
  42. #  madwifi = MADWIFI 802.11 support (Atheros, etc.)
  43. #  atmel = ATMEL AT76C5XXx (USB, PCMCIA)
  44. #  wext = Linux wireless extensions (generic, ipw2100/2200/3495, linux >= 2.6.14)
  45. #  ndiswrapper = Linux ndiswrapper
  46. #  ipw = Intel ipw2100/2200 driver (linux kernels 2.6.13 or older only)
  47. #  wired = wpa_supplicant wired Ethernet driver
  48.  
  49. DRIVER=""
  50.  
  51. # End user defined section
  52.  
  53. PATH=/sbin:/bin:/usr/sbin:/usr/bin
  54.  
  55. DAEMON="/sbin/wpa_supplicant"
  56. PNAME="wpa_supplicant"
  57.  
  58. # exit silently if daemon is not installed/executable
  59. [ -x $DAEMON ] || exit 0
  60.  
  61. if [ "$ENABLE_ROAMING_MODE" = "0" ]; then
  62.         exit 0;
  63. fi
  64.  
  65. if [ -z "$INTERFACE" ]; then
  66.         echo "No INTERFACE was defined, not starting.";
  67.         exit 1;
  68. fi
  69.  
  70. if [ ! -r "$CONFIG" ]; then
  71.         echo "No configuration file found, not starting."; 
  72.         exit 1; 
  73. fi
  74.  
  75. if [ -z "$DRIVER" ]; then
  76.     DRIVER="wext"
  77. fi
  78.  
  79. # the pidfile name is important for avoiding unwanted interactions
  80. # with the wpasupplicant pre-up script
  81. PIDFILE="/var/run/wpa_supplicant.$INTERFACE.pid"
  82.  
  83. OPTIONS="-B -w -i $INTERFACE -D $DRIVER -c $CONFIG -P $PIDFILE"
  84.  
  85. set -e
  86.  
  87. case "$1" in
  88.         start)
  89.                 if [ -f "$PIDFILE" ]; then
  90.             echo "$PNAME not starting, $PIDFILE already exists."
  91.             exit 1
  92.         fi
  93.         echo "Starting $PNAME."
  94.                 start-stop-daemon --start --name $PNAME \
  95.                         --oknodo --startas $DAEMON -- $OPTIONS
  96.                 ;;
  97.         stop)
  98.                 echo "Stopping $PNAME."
  99.                 start-stop-daemon --stop --name $PNAME \
  100.                         --oknodo
  101.                 if [ -f "$PIDFILE" ]; then
  102.                         rm -f $PIDFILE;
  103.                 fi
  104.                 ;;
  105.         reload|force-reload)
  106.                 echo "Reloading $PNAME."
  107.                 start-stop-daemon --stop --signal HUP \
  108.                         --name $PNAME
  109.                 ;;
  110.         restart)
  111.                 echo "Stopping $PNAME."
  112.                 start-stop-daemon --stop --name $PNAME \
  113.                         --oknodo
  114.                 if [ -f "$PIDFILE" ]; then
  115.                         rm -f $PIDFILE;
  116.                 fi
  117.  
  118.                 echo "Starting $PNAME."
  119.                 start-stop-daemon --start --name $PNAME \
  120.                         --oknodo --startas $DAEMON -- $OPTIONS
  121.                 ;;
  122.         *)
  123.                 echo "Usage: wpasupplicant {start|stop|restart|reload|force-reload}" >&2
  124.                 exit 1
  125.                 ;;
  126. esac
  127.  
  128. exit 0 
  129.