forked from ss/sovereign-stack
BTCPAY Server migration improvements.
This commit is contained in:
parent
f80ef6f051
commit
fc6d7fda90
17
deploy.sh
17
deploy.sh
@ -23,7 +23,7 @@ if ! lsb_release -d | grep -q "Ubuntu 22.04 LTS"; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
MIGRATE_VPS=false
|
MIGRATE_BTCPAY=false
|
||||||
DOMAIN_NAME=
|
DOMAIN_NAME=
|
||||||
RESTORE_ARCHIVE=
|
RESTORE_ARCHIVE=
|
||||||
VPS_HOSTING_TARGET=lxd
|
VPS_HOSTING_TARGET=lxd
|
||||||
@ -81,7 +81,7 @@ for i in "$@"; do
|
|||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--migrate-btcpay)
|
--migrate-btcpay)
|
||||||
MIGRATE_VPS=true
|
MIGRATE_BTCPAY=true
|
||||||
RUN_CERT_RENEWAL=false
|
RUN_CERT_RENEWAL=false
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
@ -211,14 +211,15 @@ function run_domain {
|
|||||||
export RUN_CERT_RENEWAL="$RUN_CERT_RENEWAL"
|
export RUN_CERT_RENEWAL="$RUN_CERT_RENEWAL"
|
||||||
export BTC_CHAIN="$BTC_CHAIN"
|
export BTC_CHAIN="$BTC_CHAIN"
|
||||||
export UPDATE_BTCPAY="$UPDATE_BTCPAY"
|
export UPDATE_BTCPAY="$UPDATE_BTCPAY"
|
||||||
export MIGRATE_VPS="$MIGRATE_VPS"
|
export MIGRATE_BTCPAY="$MIGRATE_BTCPAY"
|
||||||
export RECONFIGURE_BTCPAY_SERVER="$RECONFIGURE_BTCPAY_SERVER"
|
export RECONFIGURE_BTCPAY_SERVER="$RECONFIGURE_BTCPAY_SERVER"
|
||||||
|
|
||||||
# iterate over all our server endpoints and provision them if needed.
|
# iterate over all our server endpoints and provision them if needed.
|
||||||
# www
|
# www
|
||||||
VPS_HOSTNAME=
|
VPS_HOSTNAME=
|
||||||
# OPTINOAL umbrel
|
|
||||||
for VIRTUAL_MACHINE in www btcpayserver umbrel; do
|
|
||||||
|
for VIRTUAL_MACHINE in www btcpayserver; do
|
||||||
FQDN=
|
FQDN=
|
||||||
|
|
||||||
# shellcheck disable=SC1091
|
# shellcheck disable=SC1091
|
||||||
@ -386,7 +387,7 @@ function run_domain {
|
|||||||
|
|
||||||
if [ "$MACHINE_EXISTS" = true ]; then
|
if [ "$MACHINE_EXISTS" = true ]; then
|
||||||
# we delete the machine if the user has directed us to
|
# we delete the machine if the user has directed us to
|
||||||
if [ "$MIGRATE_VPS" = true ]; then
|
if [ "$MIGRATE_BTCPAY" = true ]; then
|
||||||
|
|
||||||
# if the RESTORE_ARCHIVE is not set, then
|
# if the RESTORE_ARCHIVE is not set, then
|
||||||
if [ -z "$RESTORE_ARCHIVE" ]; then
|
if [ -z "$RESTORE_ARCHIVE" ]; then
|
||||||
@ -422,13 +423,13 @@ function run_domain {
|
|||||||
RESTORE_BTCPAY="$RESTORE_BTCPAY" UPDATE_BTCPAY="$UPDATE_BTCPAY" RUN_RESTORE="$USER_RUN_RESTORE" RUN_BACKUP="$RUN_BACKUP" RUN_SERVICES=true ./deployment/domain_init.sh
|
RESTORE_BTCPAY="$RESTORE_BTCPAY" UPDATE_BTCPAY="$UPDATE_BTCPAY" RUN_RESTORE="$USER_RUN_RESTORE" RUN_BACKUP="$RUN_BACKUP" RUN_SERVICES=true ./deployment/domain_init.sh
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [ "$MIGRATE_VPS" = true ]; then
|
if [ "$MIGRATE_BTCPAY" = true ]; then
|
||||||
echo "INFO: User has indicated to delete the machine, but it doesn't exist. Going to create it anyway."
|
echo "INFO: User has indicated to delete the machine, but it doesn't exist. Going to create it anyway."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# The machine does not exist. Let's bring it into existence, restoring from latest backup.
|
# The machine does not exist. Let's bring it into existence, restoring from latest backup.
|
||||||
echo "Machine does not exist. RUN_RESTORE=$USER_RUN_RESTORE RUN_BACKUP=false"
|
echo "Machine does not exist. RUN_RESTORE=$USER_RUN_RESTORE RUN_BACKUP=false"
|
||||||
RESTORE_BTCPAY=false UPDATE_BTCPAY="$UPDATE_BTCPAY" RUN_RESTORE="$USER_RUN_RESTORE" RUN_BACKUP=false RUN_SERVICES=true ./deployment/domain_init.sh
|
RESTORE_BTCPAY="$RESTORE_BTCPAY" UPDATE_BTCPAY="$UPDATE_BTCPAY" RUN_RESTORE="$USER_RUN_RESTORE" RUN_BACKUP=false RUN_SERVICES=true ./deployment/domain_init.sh
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ cd "$(dirname "$0")"
|
|||||||
# the script executed here from the BTCPAY repo will automatically take services down
|
# the script executed here from the BTCPAY repo will automatically take services down
|
||||||
# and bring them back up.
|
# and bring them back up.
|
||||||
|
|
||||||
ssh "$FQDN" "cd $REMOTE_HOME/; sudo BTCPAY_BASE_DIRECTORY=$REMOTE_HOME bash -c $BTCPAY_SERVER_APPPATH/btcpay-down.sh"
|
ssh "$FQDN" "mkdir -p $REMOTE_HOME/backups; cd $REMOTE_HOME/; sudo BTCPAY_BASE_DIRECTORY=$REMOTE_HOME bash -c $BTCPAY_SERVER_APPPATH/btcpay-down.sh"
|
||||||
|
|
||||||
# TODO enable encrypted archives
|
# TODO enable encrypted archives
|
||||||
# TODO switch to btcpay-backup.sh when on LXD fully.
|
# TODO switch to btcpay-backup.sh when on LXD fully.
|
||||||
|
@ -24,11 +24,19 @@ elif [ "$RESTORE_BTCPAY" = true ]; then
|
|||||||
RUN_SERVICES=true
|
RUN_SERVICES=true
|
||||||
OPEN_URL=true
|
OPEN_URL=true
|
||||||
|
|
||||||
|
# if this is a new VM from a migration procedure, then we can now run setup.
|
||||||
|
if [ "$MIGRATE_BTCPAY" = true ]; then
|
||||||
|
./stub_btcpay_setup.sh
|
||||||
|
fi
|
||||||
|
|
||||||
elif [ "$RECONFIGURE_BTCPAY_SERVER" == true ]; then
|
elif [ "$RECONFIGURE_BTCPAY_SERVER" == true ]; then
|
||||||
# the administrator may have indicated a reconfig;
|
# the administrator may have indicated a reconfig;
|
||||||
# if so, we re-run setup script.
|
# if so, we re-run setup script.
|
||||||
./run_setup.sh
|
./stub_btcpay_setup.sh
|
||||||
exit
|
|
||||||
|
RUN_BACKUP=false
|
||||||
|
RUN_SERVICES=true
|
||||||
|
OPEN_URL=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# if the script gets this far, then we grab a regular backup.
|
# if the script gets this far, then we grab a regular backup.
|
||||||
@ -37,7 +45,6 @@ if [ "$RUN_BACKUP" = true ]; then
|
|||||||
./backup.sh "$UNIX_BACKUP_TIMESTAMP"
|
./backup.sh "$UNIX_BACKUP_TIMESTAMP"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [ "$RUN_SERVICES" = true ]; then
|
if [ "$RUN_SERVICES" = true ]; then
|
||||||
# The default is to resume services, though admin may want to keep services off (eg., for a migration)
|
# The default is to resume services, though admin may want to keep services off (eg., for a migration)
|
||||||
# we bring the services back up by default.
|
# we bring the services back up by default.
|
||||||
@ -48,6 +55,6 @@ fi
|
|||||||
|
|
||||||
if [ "$OPEN_URL" = true ]; then
|
if [ "$OPEN_URL" = true ]; then
|
||||||
if wait-for-it -t 5 "$FQDN:443"; then
|
if wait-for-it -t 5 "$FQDN:443"; then
|
||||||
xdg-open "https://$FQDN"
|
xdg-open "https://$FQDN" > /dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
@ -67,13 +67,17 @@ echo "ℹ️ Archiving files in $(pwd)…"
|
|||||||
{
|
{
|
||||||
tar \
|
tar \
|
||||||
--exclude="volumes/backup_datadir" \
|
--exclude="volumes/backup_datadir" \
|
||||||
--exclude="volumes/generated_bitcoin_datadir/blocks" \
|
--exclude="volumes/generated_bitcoin_datadir/_data/blocks" \
|
||||||
--exclude="volumes/generated_bitcoin_datadir/chainstate" \
|
--exclude="volumes/generated_bitcoin_datadir/_data/chainstate" \
|
||||||
--exclude="volumes/generated_bitcoin_datadir/debug.log" \
|
--exclude="volumes/generated_bitcoin_datadir/_data/debug.log" \
|
||||||
--exclude="volumes/generated_litecoin_datadir/blocks" \
|
--exclude="volumes/generated_bitcoin_datadir/_data/testnet3/blocks" \
|
||||||
--exclude="volumes/generated_litecoin_datadir/chainstate" \
|
--exclude="volumes/generated_bitcoin_datadir/_data/testnet3/chainstate" \
|
||||||
--exclude="volumes/generated_litecoin_datadir/debug.log" \
|
--exclude="volumes/generated_bitcoin_datadir/_data/testnet3/debug.log" \
|
||||||
|
--exclude="volumes/generated_bitcoin_datadir/_data/regtest/blocks" \
|
||||||
|
--exclude="volumes/generated_bitcoin_datadir/_data/regtest/chainstate" \
|
||||||
|
--exclude="volumes/generated_bitcoin_datadir/_data/regtest/debug.log" \
|
||||||
--exclude="volumes/generated_postgres_datadir" \
|
--exclude="volumes/generated_postgres_datadir" \
|
||||||
|
--exclude="volumes/generated_tor_relay_datadir" \
|
||||||
--exclude="volumes/generated_clightning_bitcoin_datadir/_data/lightning-rpc" \
|
--exclude="volumes/generated_clightning_bitcoin_datadir/_data/lightning-rpc" \
|
||||||
--exclude="**/logs/*" \
|
--exclude="**/logs/*" \
|
||||||
-cvzf "$backup_path" "$dbdump_name" volumes/generated_*
|
-cvzf "$backup_path" "$dbdump_name" volumes/generated_*
|
||||||
|
@ -59,10 +59,9 @@ if [ "\$NBITCOIN_NETWORK" != regtest ]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# provision the btcpayserver
|
# run the setup script.
|
||||||
. ./btcpay-setup.sh -i
|
. ./btcpay-setup.sh -i
|
||||||
|
|
||||||
sleep 15
|
|
||||||
EOL
|
EOL
|
||||||
|
|
||||||
# send the setup script to the remote machine.
|
# send the setup script to the remote machine.
|
@ -36,8 +36,7 @@ function prepare_host {
|
|||||||
|
|
||||||
if [ "$VIRTUAL_MACHINE" = btcpayserver ]; then
|
if [ "$VIRTUAL_MACHINE" = btcpayserver ]; then
|
||||||
echo "INFO: new machine detected. Provisioning BTCPay server scripts."
|
echo "INFO: new machine detected. Provisioning BTCPay server scripts."
|
||||||
|
./btcpayserver/stub_btcpay_setup.sh
|
||||||
./btcpayserver/run_setup.sh
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user