You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
2.3 KiB
Plaintext
73 lines
2.3 KiB
Plaintext
LND_VERSION_DIR_AARCH64=lnd-linux-arm64-v0.16.4-beta
|
|
LND_URL_AARCH64=https://github.com/lightningnetwork/lnd/releases/download/v0.16.4-beta/lnd-linux-arm64-v0.16.4-beta.tar.gz
|
|
LND_SHA256_AARCH64=ec5ee06edeef8af55edb18460ffc6a4b32b9fa632ff011883425e83fabcafa9e
|
|
|
|
# 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
|
|
local lnd_targz=$LND_VERSION_DIR_AARCH64.tar.gz
|
|
test -f $LND_VERSION_DIR_AARCH64/lnd && return 0;
|
|
curl -sSL -o $lnd_targz "$LND_URL_AARCH64"
|
|
if [ $? -ne 0 ]; then
|
|
printf "ERROR: unable to download $LND_URL_AARCH64\n" 1>&2
|
|
return 1
|
|
fi
|
|
printf "$LND_SHA256_AARCH64 $lnd_targz" | sha256sum --check
|
|
[ $? -ne 0 ] && return 1
|
|
tar -C $LND_HOME --no-same-owner -xf $lnd_targz
|
|
rm -f $lnd_targz
|
|
return $?
|
|
}
|
|
|
|
lnd_svc_install() {
|
|
# 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 <<EOF > /$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 /$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 /$LND_SVDIR/run.new /$LND_SVDIR/run
|
|
sv start lnd || printf "ERROR: sv start lnd failed\n" 1>&2
|
|
fi
|
|
rm -f /$LND_SVDIR/run.new
|
|
# whatever happened above, try to ensure the service is up
|
|
chmod +x /$LND_SVDIR/run
|
|
[ ! -f /$LND_SVDIR/down ] && sv start lnd
|
|
}
|
|
|
|
lnd_cli_install() {
|
|
mkdir -p /opt/bin
|
|
cat <<EOF > /opt/bin/lncli.sh
|
|
#!/bin/sh
|
|
set -e
|
|
cli=$LND_HOME/$LND_VERSION_DIR_AARCH64/lncli
|
|
exec doas -u lnd \$cli --macaroonpath /ssd/lnd/data/chain/bitcoin/mainnet/admin.macaroon "\$@"
|
|
EOF
|
|
chmod +x /opt/bin/lncli.sh
|
|
}
|
|
|
|
lnd_apply() {
|
|
lnd_bin_install || return 1
|
|
lnd_svc_install || return 1
|
|
lnd_cli_install || return 1
|
|
}
|