From 14501520bef0a752017d9813614f69914db911f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Thu, 23 Jan 2020 10:33:47 +0100 Subject: [PATCH] add option to show enode as QR code if qrencode is available MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakub SokoĊ‚owski --- _assets/compose/mailserver/Makefile | 5 ++++- _assets/compose/mailserver/README.md | 1 + _assets/scripts/get_enode.sh | 14 ++++++++++++-- _assets/systemd/mailserver/Makefile | 5 ++++- _assets/systemd/mailserver/README.md | 1 + 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/_assets/compose/mailserver/Makefile b/_assets/compose/mailserver/Makefile index 698670864..ccc829359 100644 --- a/_assets/compose/mailserver/Makefile +++ b/_assets/compose/mailserver/Makefile @@ -18,7 +18,7 @@ export MAIL_PASSWORD ?= status-offline-inbox # Necessary to make mailserver available publicly export PUBLIC_IP ?= $(shell curl -s https://ipecho.net/plain) -all: checks start show info enode +all: checks start show info enode enode-qr checks: ifeq (, $(shell which docker)) @@ -52,6 +52,9 @@ logs: enode: @$(GIT_ROOT)/_assets/scripts/get_enode.sh +enode-qr: + @$(GIT_ROOT)/_assets/scripts/get_enode.sh --qr + config: @$(GIT_ROOT)/_assets/scripts/gen_config.sh diff --git a/_assets/compose/mailserver/README.md b/_assets/compose/mailserver/README.md index d99788b15..c33185f9a 100644 --- a/_assets/compose/mailserver/README.md +++ b/_assets/compose/mailserver/README.md @@ -20,6 +20,7 @@ To simply start a container run `make`, other commands include: * `make logs` - Shows you logs of the container. * `make config` - Creates `${DATA_PATH}/config.json` with your Public IP. * `make enode` - Shows `enode://` address of the container. +* `make enode-qr` - Shows `enode://` address using a QR code. # Settings diff --git a/_assets/scripts/get_enode.sh b/_assets/scripts/get_enode.sh index e570a3f66..8d14eb903 100755 --- a/_assets/scripts/get_enode.sh +++ b/_assets/scripts/get_enode.sh @@ -26,6 +26,16 @@ ENODE_RAW=$(echo "${RESP_JSON}" | jq -r '.result.enode') ENODE_CLEAN=$(echo "${ENODE_RAW}" | grep -oP '\Kenode://[^?]+') # replace localhost with public IP and add mail password -echo "${ENODE_CLEAN}" | sed \ +ENODE=$(echo "${ENODE_CLEAN}" | sed \ -e "s/127.0.0.1/${PUBLIC_IP}/" \ - -e "s/@/:${MAIL_PASSWORD}@/" + -e "s/@/:${MAIL_PASSWORD}@/") + +if [[ "$1" == "--qr" ]]; then + if ! [ -x "$(command -v qrencode)" ]; then + echo 'Install 'qrencode' for enode QR code.' >&2 + exit 0 + fi + qrencode -t UTF8 "${ENODE}" +else + echo "${ENODE}" +fi diff --git a/_assets/systemd/mailserver/Makefile b/_assets/systemd/mailserver/Makefile index d4e4acdca..f9764b448 100644 --- a/_assets/systemd/mailserver/Makefile +++ b/_assets/systemd/mailserver/Makefile @@ -38,7 +38,7 @@ $(shell $(GIT_ROOT)/_assets/scripts/get_enode.sh 2>/dev/null) endef export INFO_MSG -all: checks build config service enable restart info +all: checks build config service enable restart info enode-qr clean: stop disable rm-service forget @@ -62,6 +62,9 @@ info: enode: @$(GIT_ROOT)/_assets/scripts/get_enode.sh +enode-qr: + @$(GIT_ROOT)/_assets/scripts/get_enode.sh --qr + status: systemctl $(SCTL_OPTS) status --no-pager $(SERVICE_NAME) diff --git a/_assets/systemd/mailserver/README.md b/_assets/systemd/mailserver/README.md index fff413996..116e77b0c 100644 --- a/_assets/systemd/mailserver/README.md +++ b/_assets/systemd/mailserver/README.md @@ -18,6 +18,7 @@ In order to manage the new `statusd` service you use other `Makefile` targets: * `make info` - Info about service * `make enode` - Get enode address +* `make enode-qr` - Get enode address as QR code * `make start` - Start the service * `make stop` - Stop the service * `make status` - Check service status