Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 02 Dec 2016 21:48:12 +0000
From:      bugzilla-noreply@freebsd.org
To:        freebsd-sysinstall@FreeBSD.org
Subject:   [Bug 214933] [patch] bsdinstall: add support for "hidden" Wi-Fi networks
Message-ID:  <bug-214933-2920-477lXQnLpy@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-214933-2920@https.bugs.freebsd.org/bugzilla/>
References:  <bug-214933-2920@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D214933

--- Comment #5 from Devin Teske <dteske@FreeBSD.org> ---
In more than one place, please replace the following construct:

        case $? in
        0)
                # many lines
                ;;
        *)
                exit 1
        esac

with the following, reducing the indentation of the primary block:

        [ $? -eq 0 ] || exit 1
        # many lines

The scripts/wlanconfig module includes "dialog.subr" which provides both
f_dialog_noyes() and f_dialog_yesno() (depending on which you want to be the
default choice). See "bsdconfig api dialog" for more information. Please
change:

        dialog --backtitle "FreeBSD Installer" --title "Network Selection"
--yesno "Do you want to select the network manually?" 0 0

Into the following:

        f_dialog_yesno "Do you want to select the network manually?"

And there's no need to test $? exclusively, so instead of this:

        dialog ...
        [ $? -eq 0 ] || exit 1

You can instead simply say:

        f_dialog_yesno ... || exit 1

However, "exit" by default retains the status of the last command when not
given a number, so in reality you can say this:

        f_dialog_yesno ... || exit

And since the "||" is an "r-value seeking" operand, you can put the exit on=
 a
line of its own if you like for style:

        f_dialog_yesno "Do you want to select the network manually?" ||
                exit
        # many lines

That's the desired setup. The way you have it, everytime you call dialog, t=
he
following code is indented further and further, whereas I would like to see:

        f_dialog_yesno ... || exit
        # ...
        f_dialog_input ... || exit
        # ...
        f_dialog_input ... || exit

Which brings us to the API for input dialog boxen. Use f_dialog_input() ins=
tead
of "var=3D$( dialog ... --inputbox ... )". So instead of:

        NETWORK=3D`dialog --backtitle "FreeBSD Installer" --title "Network
Selection" --inputbox "Enter SSID" 0 0 2>&1 1>&3`

First of all, we don't use `...` but instead $(...) as the former is not
nest-able. But instead of the above, we would use f_dialog_input() in the
following way (see: bsdconfig api -dF 'f_dialog_input$'):

        f_dialog_title "Network Selection"
        f_dialog_input NETWORK "Enter SSID" || exit
        f_dialog_title_restore

Which introduces how to set the title if/when necessary. Feel free to use it
where most appropriate (e.g., before the f_dialog_yesno()).

NOTE: It's important to utilize f_dialog_title()/f_dialog_title_restore()
because some systems have backtitle and title reversed (and the API takes t=
his
into consideration with respect to which back-end system is in-use). The
restore is not strictly necessary and is optional since scripts/wlanconfig =
runs
in a discrete namespace, unshared with anything else (hence your ability to=
 use
"exit" without messing up the flow of bsdinstall).

However, all those issues aside, you completely neglected thew new wlan API.

See the following commands for required information:

% bsdconfig api media/wlan # brief oversight of functions
% bsdconfig api -da media/wlan | less -R # more verbose info

You should add a line toward the top scripts/wlanconfig:

f_include $BSDCFG_SHARE/media/wlan.subr

See also: /usr/libexec/bsdconfig/120.networking/wlanconfig

The bsdconfig wireless networking is much more advanced than, and is availa=
ble
to, bsdinstall's. Both have a "wlanconfig" module (e.g., see "bsdconfig wif=
i"
or "bsdconfig wlan" or "bsdconfig wireless" -- all aliases to wlanconfig), =
but
bsdconfig's is WAY more advanced than bsdinstall's.

It's worth taking a look at bsdconfig's wlanconfig for inspiration, but more
importantly, you can actually *use* the code there in the installer. Go ahe=
ad
and steal code from bsdconfig to make bsdinstall better. I welcome that
immensely ;D

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-214933-2920-477lXQnLpy>