qusal/salt/sys-electrumx/files/server/bin/electrumx-cookie-save
Ben Grande bdd4c789c1
fix: avoid echo usage
Echo can interpret operand as an option and checking every variable to
be echoed is troublesome while with printf, if the format specifier is
present before the operand, printing as string can be enforced.
2024-08-06 18:15:24 +02:00

25 lines
535 B
Bash
Executable File

#!/bin/sh
## SPDX-FileCopyrightText: 2024 Benjamin Grande M. S. <ben.grande.b@gmail.com>
##
## SPDX-License-Identifier: AGPL-3.0-or-later
set -eu
electrumx_conf="${HOME}/.electrumx/conf.d/cookie.conf"
cookie="${HOME}/.bitcoin/.cookie"
if ! test -f "${cookie}"; then
printf '%s\n' "cookie not found" >&2
exit 1
fi
if ! test -r "${cookie}"; then
printf '%s\n' "cannot read from cookie" >&2
exit 1
fi
auth="$(cat -- "${cookie}")"
printf '%s\n' "DAEMON_URL=${auth}@127.0.0.1:8332" | \
tee -- "${electrumx_conf}" >/dev/null