nephix
By: a guest | Apr 4th, 2008 | Syntax:
Bash | Size: 1.28 KB | Hits: 43 | Expires: Never
#!/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 <Thomas.Pischulski@mailbox.tu-dresden.de>
# @expanded: Alexander Hagenah <ah@primepage.de>
# @created: 04/02/2008
# VARIABLES
# Edit them to match your system settings
DEVICE="wlan0"
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 wext
dhclient $DEVICE
;;
"stop")
ifconfig $DEVICE down
killall wpa_supplicant
;;
*) echo "No argument given. Usage: wlanfrz (start|stop)";
esac
fi