Skip to content

Commit

Permalink
add option to show enode as QR code if qrencode is available
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Sokołowski <jakub@status.im>
  • Loading branch information
jakubgs committed Jan 23, 2020
1 parent 754ef3d commit 78c2420
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
5 changes: 4 additions & 1 deletion _assets/compose/mailserver/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions _assets/compose/mailserver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 13 additions & 2 deletions _assets/scripts/get_enode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ 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
echo "${ENODE}"
exit 0
fi
qrencode -t UTF8 "${ENODE}"
else
echo "${ENODE}"
fi
5 changes: 4 additions & 1 deletion _assets/systemd/mailserver/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

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

Expand Down
1 change: 1 addition & 0 deletions _assets/systemd/mailserver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` - Get enode address as QR code
* `make start` - Start the service
* `make stop` - Stop the service
* `make status` - Check service status
Expand Down

0 comments on commit 78c2420

Please sign in to comment.