diff --git a/btc/env b/btc/env index 83fb6ba..29adf40 100644 --- a/btc/env +++ b/btc/env @@ -2,7 +2,10 @@ BITCOIN_CORE_VERSION_DIR_AARCH64=bitcoin-24.0.1 BITCOIN_CORE_URL_AARCH64=https://bitcoincore.org/bin/bitcoin-core-24.0.1/bitcoin-24.0.1-aarch64-linux-gnu.tar.gz BITCOIN_CORE_SHA256_AARCH64=0b48b9e69b30037b41a1e6b78fb7cbcc48c7ad627908c99686e81f3802454609 +# binaries and config root; data is elsewhere, in /ssd/bitcoind as per conf file. BITCOIN_HOME=/home/bitcoind +# no root slash since it's combined with other path prefixes. +BITCOIN_SVDIR=etc/sv/bitcoind bitcoin_core_bin_install() { cd $BITCOIN_HOME @@ -21,22 +24,31 @@ bitcoin_core_bin_install() { } bitcoind_svc_install() { - local svdir=/etc/sv/bitcoind - mkdir -p $svdir - cat < $svdir/run.new + # service directories + mkdir -p /$BITCOIN_SVDIR + mkdir -p /$BITCOIN_SVDIR/log + + # logging facility + if [ ! -f /$BITCOIN_SVDIR/log/run ]; then + cp $SYSUPDATES_ROOTDIR/files/$BITCOIN_SVDIR/log/run /$BITCOIN_SVDIR/log/ + chmod +x /$BITCOIN_SVDIR/log/run + fi + + # the actual bitcoin service + cat < /$BITCOIN_SVDIR/run.new #!/bin/sh exec chpst -u bitcoind $BITCOIN_HOME/$BITCOIN_CORE_VERSION_DIR_AARCH64/bin/bitcoind -conf=$BITCOIN_HOME/mainnet.conf 2>&1 EOF - chmod +x $svdir/run.new - test -f $svdir/run && diff $svdir/run $svdir/run.new + chmod +x /$BITCOIN_SVDIR/run.new + test -f /$BITCOIN_SVDIR/run && diff /$BITCOIN_SVDIR/run /$BITCOIN_SVDIR/run.new if [ $? -ne 0 ]; then - mv $svdir/run.new $svdir/run + mv /$BITCOIN_SVDIR/run.new /$BITCOIN_SVDIR/run # don't touch the actual service if on manual control - the down file - test -f $svdir/down && return 0 + test -f /$BITCOIN_SVDIR/down && return 0 sv -w 600 stop bitcoind || printf "ERROR: sv stop bitcoind failed\n" 1>&2 sv start bitcoind || printf "ERROR: sv start bitcoind failed\n" 1>&2 fi - rm -f $svdir/run.new + rm -f /$BITCOIN_SVDIR/run.new } bitcoin_cli_install() { diff --git a/files/etc/sv/bitcoind/log/run b/files/etc/sv/bitcoind/log/run new file mode 100755 index 0000000..62d846c --- /dev/null +++ b/files/etc/sv/bitcoind/log/run @@ -0,0 +1,2 @@ +#!/bin/sh +exec vlogger -t bitcoind -p daemon diff --git a/files/etc/sv/lnd/log/run b/files/etc/sv/lnd/log/run new file mode 100755 index 0000000..5670a25 --- /dev/null +++ b/files/etc/sv/lnd/log/run @@ -0,0 +1,2 @@ +#!/bin/sh +exec vlogger -t lnd -p daemon diff --git a/lnd/env b/lnd/env index 67eee54..1c3cd2e 100644 --- a/lnd/env +++ b/lnd/env @@ -2,7 +2,10 @@ LND_VERSION_DIR_AARCH64=lnd-linux-arm64-v0.16.2-beta LND_URL_AARCH64=https://github.com/lightningnetwork/lnd/releases/download/v0.16.2-beta/lnd-linux-arm64-v0.16.2-beta.tar.gz LND_SHA256_AARCH64=21e2b6640e06c84c43c5610f7f7613f609cdb09129e6704772436d6209a862af +# binaries and config root; data is elsewhere, in /ssd/lnd as per lnd conf. LND_HOME=/home/lnd +# no root slash since it's combined with other path prefixes. +LND_SVDIR=etc/sv/lnd lnd_bin_install() { cd $LND_HOME @@ -21,24 +24,34 @@ lnd_bin_install() { } lnd_svc_install() { - mkdir -p /etc/sv/lnd - cat < /etc/sv/lnd/run.new + # service directories + mkdir -p /$LND_SVDIR + mkdir -p /$LND_SVDIR/log + + # logging facility + if [ ! -f /$LND_SVDIR/log/run ]; then + cp $SYSUPDATES_ROOTDIR/files/$LND_SVDIR/log/run /$LND_SVDIR/log/ + chmod +x /$LND_SVDIR/log/run + fi + + # the actual lnd service + cat < /$LND_SVDIR/run.new #!/bin/sh [ -r conf ] && . ./conf sv start bitcoind || exit 1 exec chpst -u lnd $LND_HOME/$LND_VERSION_DIR_AARCH64/lnd -C /home/lnd/lnd.mainnet.conf 2>&1 EOF - chmod +x /etc/sv/lnd/run.new - test -f /etc/sv/lnd/run && diff /etc/sv/lnd/run /etc/sv/lnd/run.new + chmod +x /$LND_SVDIR/run.new + test -f /$LND_SVDIR/run && diff /$LND_SVDIR/run /$LND_SVDIR/run.new if [ $? -ne 0 ]; then sv -w 600 stop lnd || printf "ERROR: sv stop lnd failed\n" 1>&2 - mv /etc/sv/lnd/run.new /etc/sv/lnd/run + mv /$LND_SVDIR/run.new /$LND_SVDIR/run sv start lnd || printf "ERROR: sv start lnd failed\n" 1>&2 fi - rm -f /etc/sv/lnd/run.new + rm -f /$LND_SVDIR/run.new # whatever happened above, try to ensure the service is up - chmod +x /etc/sv/lnd/run - [ ! -f /etc/sv/lnd/down ] && sv start lnd + chmod +x /$LND_SVDIR/run + [ ! -f /$LND_SVDIR/down ] && sv start lnd } lnd_cli_install() {