Created
January 17, 2017 23:17
-
-
Save SkaTeMasTer/affba7514d17b237c36253e276f89131 to your computer and use it in GitHub Desktop.
connect to best network.. he priority in this file determines to which network you will connect if more then 2 configured networks are available. This will always be the network with the highest priority. WPA start script Create the WPA startup script /etc/init.d/wpa.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The priority in this file determines to which network you will connect if more then 2 configured networks are available. This will always be the network with the highest priority. | |
WPA start script | |
Create the WPA startup script /etc/init.d/wpa.sh | |
sudo vi /etc/init.d/wpa.sh | |
#!/bin/bash | |
### BEGIN INIT INFO | |
# Provides: wpa | |
# Required-Start: $network $syslog $local_fs | |
# Required-Stop: $network $syslog $local_fs | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: Start/stop script for wpa supplicant | |
# Description: Custom start/stop script for wpa_supplicant. | |
### END INIT INFO | |
SELF=`basename $0` | |
WPA=wpa_supplicant | |
PROGRAM=/sbin/${WPA} | |
CONF=/etc/${WPA}.conf | |
INTERFACE=wlan0 | |
DRIVER=wext | |
DAEMONMODE="-B" | |
LOGFILE=/var/log/$WPA.log | |
function start() { | |
# TODO: Support multiple interfaces and drivers | |
OPTIONS="-c $CONF -i $INTERFACE -D $DRIVER $DAEMONMODE" | |
## You can remove this if you are running 8.10 and up. | |
# Ubuntu 8.10 and up doesn't need the -w anymore.. | |
# And the logfile option is not valid on 8.04 and lower | |
local ver=$(lsb_release -sr | sed -e 's/\.//g'); | |
[ $ver -lt 810 ] && OPTIONS="$OPTIONS -w" && LOGFILE="" | |
## | |
# Log to a file | |
[ -n "$LOGFILE" ] && OPTIONS="$OPTIONS -f $LOGFILE" | |
echo " * Starting wpa supplicant" | |
eval $PROGRAM $OPTIONS | |
} | |
function stop() { | |
echo " * Stopping wpa supplicant" | |
wpa_cli -i $INTERFACE terminate | |
#pkill $PROGRAM ## alternative method | |
} | |
function debug() { | |
stop | |
DAEMONMODE="-ddd" | |
start | |
} | |
function restart() { | |
stop | |
start | |
} | |
function status() { | |
pgrep -lf $PROGRAM | |
} | |
function usage() { | |
echo "Usage: $SELF <start|stop|status|debug>" | |
return 2 | |
} | |
case $1 in | |
start|stop|debug|restart|status) $1 ;; | |
*) usage ;; | |
esac | |
Make the start script executable. | |
sudo chmod +x /etc/init.d/wpa.sh | |
You can now start WPA supplicant as a service or in debugging mode: | |
# Service | |
/etc/init.d/wpa.sh start | |
# Debugging | |
/etc/init.d/wpa.sh debug | |
Make sure the script gets run on boot and stopped at shutdown | |
sudo update-rc.d wpa.sh defaults | |
With wpa_cli you can make changes to your wpa_supplicant config file and reload these changes: | |
sudo wpa_cli | |
Enter help to see what you can do with wpa_cli. Some of the options are: reconfigure, disconnect, reconnect, reassociate. These options speak for themself. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment