1
1
sovereign-stack/deployment/btcpayserver/stub_btcpay_setup.sh

94 lines
2.8 KiB
Bash
Raw Normal View History

2022-06-22 17:39:46 +00:00
#!/bin/bash
2022-10-29 15:34:17 +00:00
set -e
2022-07-27 16:38:33 +00:00
cd "$(dirname "$0")"
2022-06-22 17:39:46 +00:00
# export BTCPAY_FASTSYNC_ARCHIVE_FILENAME="utxo-snapshot-bitcoin-testnet-1445586.tar"
# BTCPAY_REMOTE_RESTORE_PATH="/var/lib/docker/volumes/generated_bitcoin_datadir/_data"
# This is the config for a basic proxy to the listening port 127.0.0.1:2368
# It also supports modern TLS, so SSL certs must be available.
2022-11-14 01:23:48 +00:00
#opt-add-nostr-relay;
2022-06-22 17:39:46 +00:00
cat > "$SITE_PATH/btcpay.sh" <<EOL
#!/bin/bash
2022-10-29 15:34:17 +00:00
set -e
2022-07-27 16:38:33 +00:00
cd "\$(dirname "\$0")"
2022-06-22 17:39:46 +00:00
# wait for cloud-init to complete yo
while [ ! -f /var/lib/cloud/instance/boot-finished ]; do
sleep 1
done
if [ ! -d "btcpayserver-docker" ]; then
echo "cloning btcpayserver-docker";
2022-07-27 16:38:33 +00:00
git clone -b master https://github.com/btcpayserver/btcpayserver-docker btcpayserver-docker;
git config --global --add safe.directory /home/ubuntu/btcpayserver-docker
else
cd ./btcpayserver-docker
git pull
git pull --all --tags
cd -
2022-06-22 17:39:46 +00:00
fi
2022-07-27 16:38:33 +00:00
cd btcpayserver-docker
export BTCPAY_HOST="${BTCPAY_USER_FQDN}"
export BTCPAY_ANNOUNCEABLE_HOST="${DOMAIN_NAME}"
2023-02-01 19:44:05 +00:00
export NBITCOIN_NETWORK="${BITCOIN_CHAIN}"
2022-11-02 18:54:02 +00:00
export LIGHTNING_ALIAS="${PRIMARY_DOMAIN}"
2022-06-22 17:39:46 +00:00
export BTCPAYGEN_LIGHTNING="clightning"
export BTCPAYGEN_CRYPTO1="btc"
2023-01-05 16:14:48 +00:00
export BTCPAYGEN_ADDITIONAL_FRAGMENTS="opt-save-storage-s;bitcoin-clightning.custom;"
2022-06-22 17:39:46 +00:00
export BTCPAYGEN_REVERSEPROXY="nginx"
export BTCPAY_ENABLE_SSH=false
2022-07-27 16:38:33 +00:00
export BTCPAY_BASE_DIRECTORY=${REMOTE_HOME}
export BTCPAYGEN_EXCLUDE_FRAGMENTS="nginx-https;"
export REVERSEPROXY_DEFAULT_HOST="$BTCPAY_USER_FQDN"
2022-06-22 17:39:46 +00:00
if [ "\$NBITCOIN_NETWORK" != regtest ]; then
# run fast_sync if it's not been done before.
if [ ! -f /home/ubuntu/fast_sync_completed ]; then
cd ./contrib/FastSync
./load-utxo-set.sh
touch /home/ubuntu/fast_sync_completed
cd -
fi
fi
# next we create fragments to customize various aspects of the system
# this block customizes clightning to ensure the correct endpoints are being advertised
# We want to advertise the correct ipv4 endpoint for remote hosts to get in touch.
cat > ${REMOTE_HOME}/btcpayserver-docker/docker-compose-generator/docker-fragments/bitcoin-clightning.custom.yml <<EOF
services:
clightning_bitcoin:
environment:
LIGHTNINGD_OPT: |
announce-addr-dns=true
EOF
2022-08-03 14:53:11 +00:00
# run the setup script.
2022-06-22 17:39:46 +00:00
. ./btcpay-setup.sh -i
touch ${REMOTE_HOME}/btcpay.complete
2022-06-22 17:39:46 +00:00
EOL
2022-10-26 23:33:43 +00:00
# send an updated ~/.bashrc so we have quicker access to cli tools
scp ./bashrc.txt "ubuntu@$FQDN:$REMOTE_HOME/.bashrc"
ssh "$BTCPAY_FQDN" "chown ubuntu:ubuntu $REMOTE_HOME/.bashrc"
ssh "$BTCPAY_FQDN" "chmod 0664 $REMOTE_HOME/.bashrc"
2022-06-22 17:39:46 +00:00
# send the setup script to the remote machine.
scp "$SITE_PATH/btcpay.sh" "ubuntu@$FQDN:$REMOTE_HOME/btcpay_setup.sh"
2022-08-24 14:11:50 +00:00
ssh "$BTCPAY_FQDN" "chmod 0744 $REMOTE_HOME/btcpay_setup.sh"
2022-12-25 18:04:48 +00:00
# script is executed under sudo
2022-11-02 18:54:02 +00:00
ssh "$BTCPAY_FQDN" "sudo bash -c $REMOTE_HOME/btcpay_setup.sh"
2022-12-25 18:04:48 +00:00
# lets give time for the containers to spin up
sleep 10