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

82 lines
2.4 KiB
Bash
Raw Normal View History

2022-06-22 17:39:46 +00:00
#!/bin/bash
2022-07-27 16:38:33 +00:00
set -ex
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.
cat > "$SITE_PATH/btcpay.sh" <<EOL
#!/bin/bash
set -ex
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}"
2022-06-22 17:39:46 +00:00
export NBITCOIN_NETWORK="${BTC_CHAIN}"
export LIGHTNING_ALIAS="${DOMAIN_NAME}"
export BTCPAYGEN_LIGHTNING="clightning"
export BTCPAYGEN_CRYPTO1="btc"
export BTCPAYGEN_ADDITIONAL_FRAGMENTS="opt-save-storage-s;opt-add-btctransmuter;opt-add-nostr-relay;"
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}
2022-08-15 13:42:52 +00:00
EOL
# can add opt-add-tor-relay; in BTCPAYGEN_ADDITIONAL_FRAGMENTS
if [ "$VPS_HOSTING_TARGET" = lxd ]; then
cat >> "$SITE_PATH/btcpay.sh" <<EOL
export BTCPAYGEN_EXCLUDE_FRAGMENTS="nginx-https"
export REVERSEPROXY_DEFAULT_HOST="$BTCPAY_USER_FQDN"
EOL
elif [ "$VPS_HOSTING_TARGET" = aws ]; then
cat >> "$SITE_PATH/btcpay.sh" <<EOL
export BTCPAY_ADDITIONAL_HOSTS="${BTCPAY_ADDITIONAL_HOSTNAMES}"
export LETSENCRYPT_EMAIL="${CERTIFICATE_EMAIL_ADDRESS}"
2022-08-15 13:42:52 +00:00
EOL
fi
cat >> "$SITE_PATH/btcpay.sh" <<EOL
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
2022-08-03 14:53:11 +00:00
# run the setup script.
2022-06-22 17:39:46 +00:00
. ./btcpay-setup.sh -i
EOL
# 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"
ssh "$BTCPAY_FQDN" "sudo bash -c ./btcpay_setup.sh"
ssh "$BTCPAY_FQDN" "touch $REMOTE_HOME/btcpay.complete"