add option to show enode as QR code if qrencode is available

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2020-01-23 10:33:47 +01:00 committed by Jakub
parent b476d5c6f3
commit 14501520be
5 changed files with 22 additions and 4 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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