From 8370506f2581b155bb15f53a89d57f91382c6016 Mon Sep 17 00:00:00 2001 From: Daniel Oltmanns <53529846+oltdaniel@users.noreply.github.com> Date: Fri, 7 Jan 2022 17:13:41 +0100 Subject: [PATCH] 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. --- wireguard/DOCS.md | 2 +- wireguard/rootfs/etc/cont-init.d/config.sh | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/wireguard/DOCS.md b/wireguard/DOCS.md index f6e1d0c..48da7f9 100644 --- a/wireguard/DOCS.md +++ b/wireguard/DOCS.md @@ -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! diff --git a/wireguard/rootfs/etc/cont-init.d/config.sh b/wireguard/rootfs/etc/cont-init.d/config.sh index bdd5e23..fb17341 100644 --- a/wireguard/rootfs/etc/cont-init.d/config.sh +++ b/wireguard/rootfs/etc/cont-init.d/config.sh @@ -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}"