Enabling or disabling wifi

This commit is contained in:
Bob Mottram 2016-04-27 17:54:26 +01:00
parent 91871787cd
commit e1a82b205f
No known key found for this signature in database
GPG Key ID: BA68F26108DC9F87
2 changed files with 38 additions and 17 deletions

View File

@ -1932,6 +1932,21 @@ function menu_media {
done
}
function wifi_enable {
disable_wifi='yes'
dialog --title $"Enable Wifi" \
--backtitle $"Freedombone Control Panel" \
--defaultno \
--yesno $"\nDo you wish to enable wifi?" 10 50
sel=$?
case $sel in
0) disable_wifi='no';;
1) disable_wifi='yes';;
255) return;;
esac
${PROJECT_NAME}-wifi --disable $disable_wifi
}
function menu_wifi {
hotspot_state=$'off'
if [ -f /etc/hostapd/hostapd.conf ]; then
@ -1944,21 +1959,23 @@ function menu_wifi {
trap "rm -f $data" 0 1 2 5 15
dialog --backtitle $"Freedombone Control Panel" \
--title $"Wifi Menu" \
--radiolist $"Choose an operation:" 12 70 4 \
1 $"Configure wifi networks" off \
2 $"Manually edit wifi networks file" off \
3 $"Hotspot settings" off \
4 $"Exit" on 2> $data
--radiolist $"Choose an operation:" 13 70 5 \
1 $"Enable or disable Wifi" off \
2 $"Configure wifi networks" off \
3 $"Manually edit wifi networks file" off \
4 $"Hotspot settings" off \
5 $"Exit" on 2> $data
sel=$?
case $sel in
1) break;;
255) break;;
esac
case $(cat $data) in
1) wifi_settings;;
2) editor $WIFI_NETWORKS_FILE;;
3) hotspot_settings;;
4) break;;
1) wifi_enable;;
2) wifi_settings;;
3) editor $WIFI_NETWORKS_FILE;;
4) hotspot_settings;;
5) break;;
esac
done
}

View File

@ -309,12 +309,16 @@ 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 disable_wifi {
if [[ ${1} == 'yes' || ${1} == 'y' ]]; then
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
else
networks_from_file
fi
}
function show_help {
@ -384,8 +388,8 @@ do
shift
done
if [[ $WIFI_DISABLE == $'yes' || $WIFI_DISABLE == $'y' ]]; then
disable
if [ $WIFI_DISABLE ]; then
disable_wifi $WIFI_DISABLE
exit 0
fi