From 5c182edb23fa79cdb72d6b9e607d21cd62c34b1a Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 21 Oct 2016 17:40:06 +0100 Subject: [PATCH] Terminale wpa_supplicant before restart of wifi --- src/freedombone-utils-wifi | 5 ++++- src/freedombone-wifi | 28 +++++++++++++++------------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/freedombone-utils-wifi b/src/freedombone-utils-wifi index 396f6286..aed57100 100755 --- a/src/freedombone-utils-wifi +++ b/src/freedombone-utils-wifi @@ -70,6 +70,7 @@ function setup_wifi_atheros { cd $curr_dir update_wifi_adaptors if [ $IFACE ]; then + wpa_cli -i ${IFACE} terminate ifdown --force $IFACE ifup $IFACE fi @@ -208,7 +209,8 @@ function hotspot_off { fi systemctl restart network-manager - ifdown --force $WIFI_INTERFACE + wpa_cli -i ${WIFI_INTERFACE} terminate + ifdown --force ${WIFI_INTERFACE} } function hotspot_on { @@ -494,6 +496,7 @@ function disable_wifi { echo '# Include files from /etc/network/interfaces.d:' >> /etc/network/interfaces echo 'source-directory /etc/network/interfaces.d' >> /etc/network/interfaces systemctl restart network-manager + wpa_cli -i ${WIFI_INTERFACE} terminate ifdown --force ${WIFI_INTERFACE} else networks_from_file diff --git a/src/freedombone-wifi b/src/freedombone-wifi index d61d88b6..8d96843e 100755 --- a/src/freedombone-wifi +++ b/src/freedombone-wifi @@ -85,8 +85,9 @@ do WIFI_INTERFACE=${1} wifi_interface_specified=1 write_config_param "WIFI_INTERFACE" "$WIFI_INTERFACE" - ifdown --force $WIFI_INTERFACE - ifup $WIFI_INTERFACE + wpa_cli -i ${WIFI_INTERFACE} terminate + ifdown --force ${WIFI_INTERFACE} + ifup ${WIFI_INTERFACE} ;; -t|--type) shift @@ -129,41 +130,42 @@ do shift done -if [ $NETWORKS_INTERACTIVE ]; then +if [ ${NETWORKS_INTERACTIVE} ]; then create_networks_interactive exit 0 fi -if [ ! $wifi_interface_specified ]; then +if [ ! ${wifi_interface_specified} ]; then update_wifi_adaptors if [ ! $IFACE ]; then echo $'No wifi adaptors were found' exit 872356 fi - WIFI_INTERFACE=$IFACE + WIFI_INTERFACE=${IFACE} echo "Adaptor: $WIFI_INTERFACE" write_config_param "WIFI_INTERFACE" "$WIFI_INTERFACE" - ifdown --force $WIFI_INTERFACE - ifup $WIFI_INTERFACE + wpa_cli -i ${WIFI_INTERFACE} terminate + ifdown --force ${WIFI_INTERFACE} + ifup ${WIFI_INTERFACE} fi -if [ $WIFI_DISABLE ]; then - disable_wifi $WIFI_DISABLE +if [ ${WIFI_DISABLE} ]; then + disable_wifi ${WIFI_DISABLE} remove_config_param "WIFI_INTERFACE" exit 0 fi -if [ -f $WIFI_NETWORKS_FILE ]; then +if [ -f ${WIFI_NETWORKS_FILE} ]; then networks_from_file exit 0 fi -if [ ! $WIFI_SSID ]; then +if [ ! ${WIFI_SSID} ]; then echo $'No SSID given' exit 1 fi -if [[ $WIFI_HOTSPOT != 'no' ]]; then +if [[ ${WIFI_HOTSPOT} != 'no' ]]; then hotspot_on exit 0 else @@ -177,7 +179,7 @@ if [[ "$WIFI_TYPE" != 'none' && "$WIFI_TYPE" != 'open' ]]; then fi fi -if [[ $WIFI_TYPE == 'wpa2-psk' ]]; then +if [[ ${WIFI_TYPE} == 'wpa2-psk' ]]; then if [ ! -d /etc/wpa_supplicant ]; then echo $'wpasupplicant package is not installed' exit 3