|
|
|
LND_VERSION_DIR_AARCH64=lnd-linux-arm64-v0.16.0-beta
|
|
|
|
LND_URL_AARCH64=https://github.com/lightningnetwork/lnd/releases/download/v0.16.0-beta/lnd-linux-arm64-v0.16.0-beta.tar.gz
|
|
|
|
LND_SHA256_AARCH64=63d6a37d77942735ef58a59208ca1bb4d6a5ddfe554c2664ec3f5020ffab2414
|
|
|
|
|
|
|
|
LND_HOME=/home/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() {
|
|
|
|
mkdir -p /etc/sv/lnd
|
|
|
|
cat <<EOF > /etc/sv/lnd/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
|
|
|
|
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
|
|
|
|
sv start lnd || printf "ERROR: sv start lnd failed\n" 1>&2
|
|
|
|
fi
|
|
|
|
rm -f /etc/sv/lnd/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
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|