bitcoind: add netns and nonetns cli scripts

nonetns script needed for bitcoind-import-banlist
This commit is contained in:
nixbitcoin 2020-06-18 10:18:11 +00:00
parent 75ca6f186c
commit 515aae2825
No known key found for this signature in database
GPG Key ID: DD11F9AD5308B3BA
2 changed files with 14 additions and 2 deletions

View File

@ -257,11 +257,20 @@ in {
}; };
cli = mkOption { cli = mkOption {
type = types.package; type = types.package;
default = cfg.cli-nonetns-exec;
description = "Binary to connect with the bitcoind instance.";
};
# Needed because bitcoind-import-banlist already executes inside
# nb-bitcoind, hence it doesn't need netns-exec prefixed.
cli-nonetns-exec = mkOption {
readOnly = true; readOnly = true;
type = types.package;
default = pkgs.writeScriptBin "bitcoin-cli" '' default = pkgs.writeScriptBin "bitcoin-cli" ''
exec ${cfg.package}/bin/bitcoin-cli -datadir='${cfg.dataDir}' "$@" exec ${cfg.package}/bin/bitcoin-cli -datadir='${cfg.dataDir}' "$@"
''; '';
description = "Binary to connect with the bitcoind instance."; description = ''
Binary to connect with the bitcoind instance without netns-exec.
'';
}; };
enforceTor = nix-bitcoin-services.enforceTor; enforceTor = nix-bitcoin-services.enforceTor;
}; };
@ -321,7 +330,7 @@ in {
bindsTo = [ "bitcoind.service" ]; bindsTo = [ "bitcoind.service" ];
after = [ "bitcoind.service" ]; after = [ "bitcoind.service" ];
script = '' script = ''
cd ${cfg.cli}/bin cd ${cfg.cli-nonetns-exec}/bin
# Poll until bitcoind accepts commands. This can take a long time. # Poll until bitcoind accepts commands. This can take a long time.
while ! ./bitcoin-cli getnetworkinfo &> /dev/null; do while ! ./bitcoin-cli getnetworkinfo &> /dev/null; do
sleep 1 sleep 1

View File

@ -176,6 +176,9 @@ in {
] ++ lib.lists.concatMap (s: [ ] ++ lib.lists.concatMap (s: [
"${netns.${s}.address}" "${netns.${s}.address}"
]) netns.bitcoind.availableNetns; ]) netns.bitcoind.availableNetns;
cli = pkgs.writeScriptBin "bitcoin-cli" ''
netns-exec nb-bitcoind ${config.services.bitcoind.package}/bin/bitcoin-cli -datadir='${config.services.bitcoind.dataDir}' "$@"
'';
}; };
}) })