From 10d6b04ac82226dd8c39da492ef63f1491b2dd65 Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Wed, 27 Nov 2019 14:04:47 +0100 Subject: [PATCH] support enabling clightning and lnd simultaneously Needed for testing. --- modules/nix-bitcoin.nix | 16 +++++++--------- pkgs/nodeinfo/nodeinfo.sh | 4 ++-- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/modules/nix-bitcoin.nix b/modules/nix-bitcoin.nix index cc050c3..5cbab71 100644 --- a/modules/nix-bitcoin.nix +++ b/modules/nix-bitcoin.nix @@ -103,15 +103,13 @@ in { # Unfortunately c-lightning doesn't allow setting the permissions of the rpc socket # https://github.com/ElementsProject/lightning/issues/1366 - security.sudo.configFile = ( - if config.services.clightning.enable then '' - operator ALL=(clightning) NOPASSWD: ALL - '' - else if config.services.lnd.enable then '' - operator ALL=(lnd) NOPASSWD: ALL - '' - else "" - ); + security.sudo.configFile = + (optionalString config.services.clightning.enable '' + operator ALL=(clightning) NOPASSWD: ALL + '') + + (optionalString config.services.lnd.enable '' + operator ALL=(lnd) NOPASSWD: ALL + ''); # Give root ssh access to the operator account systemd.services.copy-root-authorized-keys = { diff --git a/pkgs/nodeinfo/nodeinfo.sh b/pkgs/nodeinfo/nodeinfo.sh index a45bc5b..bb6dcdb 100644 --- a/pkgs/nodeinfo/nodeinfo.sh +++ b/pkgs/nodeinfo/nodeinfo.sh @@ -4,7 +4,7 @@ set -o pipefail BITCOIND_ONION="$(cat /var/lib/onion-chef/operator/bitcoind)" echo BITCOIND_ONION="$BITCOIND_ONION" -if [ -x "$(command -v lightning-cli)" ]; then +if systemctl is-active --quiet clightning; then CLIGHTNING_NODEID=$(lightning-cli getinfo | jq -r '.id') CLIGHTNING_ONION="$(cat /var/lib/onion-chef/operator/clightning)" CLIGHTNING_ID="$CLIGHTNING_NODEID@$CLIGHTNING_ONION:9735" @@ -13,7 +13,7 @@ if [ -x "$(command -v lightning-cli)" ]; then echo CLIGHTNING_ID="$CLIGHTNING_ID" fi -if [ -x "$(command -v lncli)" ]; then +if systemctl is-active --quiet lnd; then LND_NODEID=$(lncli getinfo | jq -r '.uris[0]') echo LND_NODEID="$LND_NODEID" fi