From 3e24c14dde0e8f83447a087cf6cf6bba4957a1a4 Mon Sep 17 00:00:00 2001 From: Oscar Najera Date: Wed, 22 Feb 2023 09:58:09 +0100 Subject: Bitcoin shepherd loading from pass --- config/shepherd/init.d/bitcoin.scm | 61 ++++++++++-------------------------- config/systemd/user/shepherd.service | 1 + 2 files changed, 17 insertions(+), 45 deletions(-) (limited to 'config') diff --git a/config/shepherd/init.d/bitcoin.scm b/config/shepherd/init.d/bitcoin.scm index d5f128c..93f76a3 100644 --- a/config/shepherd/init.d/bitcoin.scm +++ b/config/shepherd/init.d/bitcoin.scm @@ -1,31 +1,33 @@ +(use-modules (ice-9 popen) + (ice-9 rdelim)) + (define (make-dir-parents dir-path) (unless (access? dir-path F_OK) (make-dir-parents (dirname dir-path)) (mkdir dir-path))) + +(define (bitcoin-rpc-pass) + (let* ((port + (open-input-pipe + "pass show Development/bitcoin/testnet/localhost")) + (result (read-line port))) + (close-pipe port) + result)) + ;; TESTNET ;; Requires the running node which is now under systemd -(register-services - (make - #:docstring "Electrs testnet" - #:provides '(electrs-testnet) - #:start (make-forkexec-constructor - (list "/home/titan/dev/bitcoin/electrs/target/release/electrs" - "--conf" "/home/titan/dev/bitcoin/electrs/testnet-conf.toml") - #:log-file "/tmp/electrs.log") - #:stop (make-kill-destructor 2) ;; 2 is SIGINT - interupt process stream, ctrl-C - #:respawn? #t)) - (register-services (make #:docstring "Bitcoin testnet index" #:provides '(index-testnet) #:start (make-forkexec-constructor (list "/home/titan/dev/bitcoin/rust-bitcoin-indexer/target/release/bitcoin-indexer") - #:directory "/home/titan/dev/bitcoin/rust-bitcoin-indexer/" + #:environment-variables `("DATABASE_URL=postgres://titan@%2Frun%2Fpostgresql/btc-testnet-idx" + ,(format #f "NODE_RPC_URL=http://crazy:~a@127.0.0.1:18332/" (bitcoin-rpc-pass)) + "RUST_LOG=bitcoin_indexer=info") #:log-file "/tmp/btc-indexer.log") #:stop (make-kill-destructor 2) ;; 2 is SIGINT - interupt process stream, ctrl-C - #:requires '(bitcoin-testnet) #:respawn? #t)) (register-services @@ -33,39 +35,8 @@ #:docstring "Bitcoin testnet lnd lightning" #:provides '(lnd-testnet) #:start (make-forkexec-constructor - (list "lnd" + (list "/home/titan/.local/bin/lnd" "--lnddir=/mnt/disk/personal/bitcoin/lnd/" "--noseedbackup")) #:stop (make-kill-destructor 2) ;; 2 is SIGINT - interupt process stream, ctrl-C #:respawn? #t)) - -;; Mainnet -(register-services - (make - #:docstring "Sarah tunnel btc" - #:provides '(sarah-ssh) - #:start (make-forkexec-constructor - (list "ssh" "-NTv" - "-o" "ServerAliveInterval=60" - "-o" "ExitOnForwardFailure=yes" - "-o" "StreamLocalBindUnlink=yes" - "-L" "8332:localhost:8332" - "-L" "8333:localhost:8333" - "sarah") - #:log-file "/tmp/sarah-ssh.log" - #:environment-variables '("SSH_AUTH_SOCK=/run/user/1000/gnupg/S.gpg-agent.ssh")) - #:stop (make-kill-destructor 2) ;; 2 is SIGINT - interupt process stream, ctrl-C - #:respawn? #t)) - -(register-services - (make - #:docstring "Electrs mainnet" - #:provides '(electrs-mainnet) - #:start (make-forkexec-constructor - (list "/home/titan/dev/bitcoin/electrs/target/release/electrs" - "--conf" "/home/titan/dev/bitcoin/electrs/mainnet-conf.toml") - #:log-file "/tmp/electrs-m.log") - #:stop (make-kill-destructor 2) ;; 2 is SIGINT - interupt process stream, ctrl-C - #:requires '(sarah-ssh) - #:respawn? #t)) - diff --git a/config/systemd/user/shepherd.service b/config/systemd/user/shepherd.service index 42d052d..b57d7ec 100644 --- a/config/systemd/user/shepherd.service +++ b/config/systemd/user/shepherd.service @@ -1,3 +1,4 @@ +# -*- mode: conf-unix; -*- [Unit] Description=GNU Shepherd Daemon After=network.target -- cgit v1.2.3