Automatic detection of wifi adaptor
This commit is contained in:
parent
904d8d60af
commit
e6e21d0b24
|
@ -37,6 +37,7 @@ CONFIGURATION_FILE=$HOME/${PROJECT_NAME}.cfg
|
||||||
COMPLETION_FILE=$HOME/${PROJECT_NAME}-completed.txt
|
COMPLETION_FILE=$HOME/${PROJECT_NAME}-completed.txt
|
||||||
|
|
||||||
WIFI_INTERFACE=wlan0
|
WIFI_INTERFACE=wlan0
|
||||||
|
wifi_interface_specified=
|
||||||
WIFI_TYPE='wpa2-psk'
|
WIFI_TYPE='wpa2-psk'
|
||||||
WIFI_SSID=
|
WIFI_SSID=
|
||||||
WIFI_PASSPHRASE=
|
WIFI_PASSPHRASE=
|
||||||
|
@ -46,6 +47,25 @@ WIFI_NETWORKS_FILE=~/${PROJECT_NAME}-wifi.cfg
|
||||||
NETWORKS_INTERACTIVE=
|
NETWORKS_INTERACTIVE=
|
||||||
WIFI_DISABLE=
|
WIFI_DISABLE=
|
||||||
|
|
||||||
|
IFACE=
|
||||||
|
IFACE_SECONDARY=
|
||||||
|
|
||||||
|
function update_wifi_adaptors {
|
||||||
|
IFACE=
|
||||||
|
IFACE_SECONDARY=
|
||||||
|
|
||||||
|
for i in $(seq 10 -1 0); do
|
||||||
|
if grep -q "wlan${i}" /proc/net/dev; then
|
||||||
|
if [ ! $IFACE ]; then
|
||||||
|
IFACE="wlan${i}"
|
||||||
|
else
|
||||||
|
IFACE_SECONDARY="wlan${i}"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
function wifi_get_psk {
|
function wifi_get_psk {
|
||||||
ssid=$1
|
ssid=$1
|
||||||
passphrase=$2
|
passphrase=$2
|
||||||
|
@ -267,6 +287,12 @@ function networks_from_file {
|
||||||
}
|
}
|
||||||
|
|
||||||
function create_networks_interactive {
|
function create_networks_interactive {
|
||||||
|
update_wifi_adaptors
|
||||||
|
if [ ! $IFACE ]; then
|
||||||
|
# Don't try to configure wifi if there are no adaptors
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -f $WIFI_NETWORKS_FILE ]; then
|
if [ -f $WIFI_NETWORKS_FILE ]; then
|
||||||
rm $WIFI_NETWORKS_FILE
|
rm $WIFI_NETWORKS_FILE
|
||||||
fi
|
fi
|
||||||
|
@ -384,6 +410,7 @@ do
|
||||||
-i|--if|--interface)
|
-i|--if|--interface)
|
||||||
shift
|
shift
|
||||||
WIFI_INTERFACE=${1}
|
WIFI_INTERFACE=${1}
|
||||||
|
wifi_interface_specified=1
|
||||||
;;
|
;;
|
||||||
-t|--type)
|
-t|--type)
|
||||||
shift
|
shift
|
||||||
|
@ -426,14 +453,23 @@ do
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [ $NETWORKS_INTERACTIVE ]; then
|
||||||
|
create_networks_interactive
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
if [ $WIFI_DISABLE ]; then
|
if [ $WIFI_DISABLE ]; then
|
||||||
disable_wifi $WIFI_DISABLE
|
disable_wifi $WIFI_DISABLE
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $NETWORKS_INTERACTIVE ]; then
|
if [ ! $wifi_interface_specified= ]; then
|
||||||
create_networks_interactive
|
update_wifi_adaptors
|
||||||
exit 0
|
if [ ! $IFACE ]; then
|
||||||
|
echo $'No wifi adaptors were found'
|
||||||
|
exit 872356
|
||||||
|
fi
|
||||||
|
WIFI_INTERFACE=$IFACE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f $WIFI_NETWORKS_FILE ]; then
|
if [ -f $WIFI_NETWORKS_FILE ]; then
|
||||||
|
|
Loading…
Reference in New Issue