qusal/salt/sys-bitcoin/files/server/bin/bitcoin-rpcwhitelist-cookie
Ben Grande 1b2f1ba941
fix: avoid operand evaluation as argument
Explicit end option parsing as the shell can be quite dangerous without
it.
2024-08-06 17:13:25 +02:00

19 lines
505 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
conf="${HOME}/.bitcoin/conf.d/cookie.conf"
if ! systemctl is-active bitcoind >/dev/null 2>&1; then
echo "systemd service 'bitcoind' is inactive" >&2
echo "remote RPC can't add crendetials" >&2
exit 1
fi
rpc_list="$(bitcoin-cli help | awk '/^[a-z]/{print $1}' | tr "\n" ",")"
echo "rpcwhitelist=__cookie__:${rpc_list}" | tee -- "${conf}" >/dev/null