Option to disable wifi

This commit is contained in:
Bob Mottram 2016-04-27 17:41:19 +01:00
parent 14cc474649
commit 91871787cd
No known key found for this signature in database
GPG Key ID: BA68F26108DC9F87
1 changed files with 82 additions and 63 deletions

View File

@ -44,6 +44,7 @@ WIFI_HOTSPOT='no'
WIFI_CONFIG=/etc/wpa_supplicant/wpa_supplicant.conf
WIFI_NETWORKS_FILE=~/${PROJECT_NAME}-wifi.cfg
NETWORKS_INTERACTIVE=
WIFI_DISABLE=
function wifi_get_psk {
ssid=$1
@ -308,6 +309,14 @@ function create_networks_interactive {
done
}
function disable {
hotspot_off
echo '# interfaces(5) file used by ifup(8) and ifdown(8)' > /etc/network/interfaces
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
}
function show_help {
echo ''
echo $"${PROJECT_NAME}-wifi -i [interface] -t [type] -s [ssid] -p [passphrase]"
@ -322,6 +331,7 @@ function show_help {
echo $' --hotspot [yes|no] Create a hotspot'
echo $' --networks [filename] File containing wifi networks'
echo $' --createnetworks [filename] Create file containing wifi networks'
echo $' --disable [yes/no] Disable wifi'
echo ''
exit 0
}
@ -363,6 +373,10 @@ do
NETWORKS_INTERACTIVE='yes'
WIFI_NETWORKS_FILE=${1}
;;
--disable)
shift
WIFI_DISABLE=${1}
;;
*)
# unknown option
;;
@ -370,6 +384,11 @@ do
shift
done
if [[ $WIFI_DISABLE == $'yes' || $WIFI_DISABLE == $'y' ]]; then
disable
exit 0
fi
if [ $NETWORKS_INTERACTIVE ]; then
create_networks_interactive
exit 0