Guest WiFi QR Code (via luci-app-commands?)

GREAT ! thanks

Where is everyone storing the script?

/root/ may be sufficient...
You can also add a call from /etc/rc.local to have a fresh update of qrcodes at bootup...

As obvious as it sounds, has anyone proposed the idea of having a dedicated LuCI page to show QR codes for WireGuard client configurations and SSIDs?

It would be a nice feature for OpenWrt to have a page you could display QR codes for the WireGuard client configurations so that clients can QR scan their configuration in with the smartphone app for example and also you could show the QR codes for all of the SSIDs.

1 Like

I fully support this!

Hats off man! I really love this solution!! :slight_smile:

@dibdot How would one go about adding that guest ssid parameter to the code?
I have tried several combinations but no success, atm I have this:

guest_ssid="(./patch.sh "whatevername")"

I would like the same thing but viewable only when authenticated on Luci.

Someone have done like that ?
How can I do that ?

seems not working anymore with latest 22.03.2, any ideas?

There is no sysauth.htm anymore but the /www/ dir is still present.

So today not finding any QR option in basic installation of my router, choose to play a little with this:

(Have almost 0 experience with coding - would like to thanks mainly @juppin , @dibdot that can reuse the code and tweak it fast.)

ssh in router > mkdir wifi_qr > cd /wifi_qr > vi qr_generator.sh > insert:
(Bevare the line starting qrencode - it's a long on, so make sure it is copied right into vi.)

#!/bin/sh

command -v qrencode >/dev/null 2>&1 || (
  opkg update && opkg install qrencode
) || exit 1

. /lib/functions.sh

guest_ssid="${1}"

handle_qrcode() {
    local device mode ssid pass
    device="$(uci_get "wireless" "${section}" "device")"
    mode="$(uci_get "wireless" "${section}" "mode")"
    ssid="$(uci_get "wireless" "${section}" "ssid")"
    pass="$(uci_get "wireless" "${section}" "key")"
    encryption="$(uci_get "wireless" "${section}" "encryption")"

   if [ -n "${ssid}" ] && [ -n "${pass}" ] && [ "${mode}"="ap" ] && \
        { [ -z "${guest_ssid}" ] || [ "${guest_ssid}" = "${ssid}" ]; }
    then
        qrencode --inline --8bit -s6 --type=SVG --output=- "WIFI:S:${ssid};T:${encryption};P:${pass};" \
        > /www/"${ssid}.svg"
    fi
}

config_load wireless
config_foreach handle_qrcode

Esc > :wq

chmod +x qr_generator.sh

and finally run

./qr_generator.sh

First time it will update opkg, download qrencode - each next subsequent run rewrite existing QR (if WiFi name remain same) or will create a new one.

It doesn't delete anyhow the QR codes, it's not secure to leave it there as is after all set up is done.

QR to be found at IPv4 address of the router - so what is the set up in LuCI LAN section for router - the same address as LuCI.

Usually:

192.168.1.1/name_of_WiFi_chosen_in_settings.svg

Of if https enabled:

h t t p s://192.168.1.1/test_example_2Ghz.svg

As how many WiFi is created that many .svg should be possible to iterate through just changing the name/path accordingly.

Script also does not care if the ap is active or not, if existing > should be there QR for it.


Tested several times today on really weak device with OWrt 23.05.4 / kernel 5.15.162 / some 55 MiB RAM / 8MiB space.

After installation it does take ~<1s for each .svg - really fast tbh.

See qrencode -h if should be rendered differently and change .sh file as it fits.
Set up my .svg to be bigger comparing previous versions.

2 Likes

Hi, I had some rough years and no more time for this hobby.

Better late then never?

1 Like