print qrcode as text in logs

in order to get started quickly with the wireguard addon, it would be nice to have the qr code ready in the logs.

else you'll need to use the File Editor add on, which does not allow by default access to the /ssl/wireguard folder. so this change would make it more beginner friendly.
This commit is contained in:
Daniel Oltmanns 2022-01-07 17:13:41 +01:00
parent c57f7e15e5
commit 8370506f25
2 changed files with 5 additions and 1 deletions

View file

@ -35,7 +35,7 @@ Follow the following steps for installation & a quick start:
1. Forward port `51820` (UDP!) in your router to your Hass.io IP.
1. Download/Open the file `/ssl/wireguard/myphone/qrcode.png` stored on your
Hass.io machine, e.g., using Samba, Visual Studio Code or the Configurator
add-on.
add-on. You can also find the QR Code in the add-on logs.
1. Install the WireGuard app on your phone.
1. Add a new WireGuard connection to your phone, by scanning the QR code.
1. Connect!

View file

@ -291,6 +291,10 @@ for peer in $(bashio::config 'peers|keys'); do
# Generate QR code with client configuration
qrencode -t PNG -o "${config_dir}/qrcode.png" < "${config_dir}/client.conf"
# Show QR code with client configuration in logs
bashio::log.info "QR code for peer ${name}:"
qrencode -t ANSI < "${config_dir}/client.conf"
# Store client name for the status API based on public key
filename=$(sha1sum <<< "${peer_public_key}" | awk '{ print $1 }')
echo -n "${name}" > "/var/lib/wireguard/${filename}"