From 81782057627b6f72b990e26a19c9d67b65d09f4f Mon Sep 17 00:00:00 2001 From: Jeffrey Paul Date: Wed, 18 Sep 2019 14:32:15 -0700 Subject: [PATCH] better config file management --- bitcoind.run | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/bitcoind.run b/bitcoind.run index 87924df..e73a3e7 100644 --- a/bitcoind.run +++ b/bitcoind.run @@ -5,11 +5,21 @@ export HOME="/var/lib/bitcoind" # gen random pw for rpc server RANDOMPW=$(openssl rand -hex 10) -if [[ ! -e $HOME/bitcoin.conf ]]; then +# if password is specified, overwrite config file +if [[ "$BITCOIND_RPCPASSWORD" != "" ]]; then cat < $HOME/bitcoin.conf rpcuser=${BITCOIND_RPCUSER:-rpcuser} rpcpassword=${BITCOIND_RPCPASSWORD:-$RANDOMPW} EOF +else +# if using randomly generated pw, do not overwrite config +# if it already exists +if [[ ! -e $HOME/bitcoin.conf ]]; then +cat < $HOME/bitcoin.conf +rpcuser=${BITCOIND_RPCUSER:-rpcuser} +rpcpassword=$RANDOMPW +EOF +fi fi # SECURITY this puts the rpc password into the container log