#!/bin/sh # # description: This small start/stop-script will let you control # your wpa_supplicant application to handle its correct # usage. # @name: wpa_supplicant.sh # @author: Thomas Pischulski # @expanded: Alexander Hagenah # @created: 04/02/2008 # VARIABLES # Edit them to match your system settings DEVICE="wlan0" DRIVER="wext" CONFIG="/etc/wpa_supplicant/wpa_supplicant.conf" USERID=`id -u` ANSWER="" if [ $USERID != 0 ]; then echo "You're not root" exit 0 else case "$1" in "start") WPAPID=`pidof wpa_supplicant` if [ $? -eq 0 ]; then echo "wpa_supplicant process still running." echo "Kill it? [y/n] " read ANSWER case "$ANSWER" in "y"|"Y") kill -9 $WPAPID ;; "n"|"N") echo "Could not start wpa_supplicant because another" echo "process is still running. Exiting.." exit 0 ;; *) echo "Answer not allowed. Exiting.." exit 0 esac fi ifconfig $DEVICE up wpa_supplicant -dd -B -c $CONFIG -i $DEVICE -D $DRIVER dhclient $DEVICE ;; "stop") ifconfig $DEVICE down killall wpa_supplicant ;; *) echo "No argument given. Usage: wlan_tu (start|stop)"; esac fi