Skip to content

Commit

Permalink
Add connect_no_password, for use with networks which misreport
Browse files Browse the repository at this point in the history
Some networks report the need of a password but can be connected
without one, and ask for a login in a network page.
  • Loading branch information
hishamhm committed Sep 15, 2018
1 parent f202f41 commit 57b528a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/gobonet
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ function network_config_file() {

function connect_wifi() {
local essid="$1"
local no_password="$2"
local file="$(network_config_file "$essid")"

if ! [ -e "$wifi_dir/$file" ]
Expand All @@ -159,7 +160,7 @@ function connect_wifi() {
info=$(gobonet_backend full-scan "$wifi_interface" | grep -B 1 -F "ESSID:\"$essid\"")
fi
info=$(echo "$info" | head -n 2)
if echo "$info" | grep "Encryption key:off"
if [ "$no_password" = "no_password" ] || echo "$info" | grep "Encryption key:off"
then
{
echo "network={"
Expand Down Expand Up @@ -296,6 +297,9 @@ function show_help() {
echo " Scan WiFi networks and connect to a known one"
echo " gobonet connect \"<essid>\""
echo " Connect to a given WiFi network"
echo " gobonet connect_no_password \"<essid>\""
echo " Connect to a given WiFi network without a password,"
echo " if network misreports the need"
echo " gobonet connect_wired"
echo " Connect to a wired network"
echo " gobonet disconnect"
Expand Down Expand Up @@ -349,6 +353,11 @@ case "$1" in
[ "$essid" -a "$3" = "" ] || usage "connect \"<essid>\""
connect_wifi "$essid" && echo "gobonet: Connected to \"$essid\"!"
;;
connect_no_password)
essid="$2"
[ "$essid" -a "$3" = "" ] || usage "connect_no_password \"<essid>\""
connect_wifi "$essid" no_password && echo "gobonet: Connected to \"$essid\"!"
;;
connect_wired)
[ "$2" = "" ] || usage "connect_wired"
connect_wired && echo "gobonet: Connected to \"$wired_interface\"!"
Expand Down

0 comments on commit 57b528a

Please sign in to comment.