1
1
Fork 1
sovereign-stack/deployment/btcpayserver/go.sh

70 lines
1.8 KiB
Bash
Raw Normal View History

#!/bin/bash
2022-06-22 17:29:52 +00:00
set -eux
cd "$(dirname "$0")"
2022-07-29 22:33:24 +00:00
OPEN_URL=false
2022-07-27 16:38:33 +00:00
# we will re-run the btcpayserver provisioning scripts if directed to do so.
# if an update does occur, we grab another backup.
if [ "$UPDATE_BTCPAY" = true ]; then
# run the update.
2022-07-27 16:38:33 +00:00
ssh "$FQDN" "bash -c $BTCPAY_SERVER_APPPATH/btcpay-down.sh"
2022-07-27 16:38:33 +00:00
# btcpay-update.sh brings services back up, but does not take them down.
ssh "$FQDN" "sudo bash -c $BTCPAY_SERVER_APPPATH/btcpay-update.sh"
sleep 20
2022-07-27 16:38:33 +00:00
elif [ "$RESTORE_BTCPAY" = true ]; then
2022-07-29 22:33:24 +00:00
# run the update.
ssh "$FQDN" "bash -c $BTCPAY_SERVER_APPPATH/btcpay-down.sh"
sleep 10
2022-07-27 16:38:33 +00:00
./restore.sh
2022-07-29 22:33:24 +00:00
RUN_SERVICES=true
OPEN_URL=true
2022-08-03 14:53:11 +00:00
# if this is a new VM from a migration procedure, then we can now run setup.
2022-08-24 14:11:50 +00:00
if [ "$MIGRATE_BTCPAY" = true ]; then
2022-08-03 14:53:11 +00:00
./stub_btcpay_setup.sh
fi
2022-07-27 16:38:33 +00:00
elif [ "$RECONFIGURE_BTCPAY_SERVER" == true ]; then
# the administrator may have indicated a reconfig;
# if so, we re-run setup script.
2022-08-03 14:53:11 +00:00
./stub_btcpay_setup.sh
RUN_SERVICES=true
OPEN_URL=true
2022-07-27 16:38:33 +00:00
fi
# if the script gets this far, then we grab a regular backup.
2022-08-24 14:11:50 +00:00
if [ "$BACKUP_BTCPAY" = true ]; then
2022-07-27 16:38:33 +00:00
# we just grab a regular backup
./backup.sh "$UNIX_BACKUP_TIMESTAMP"
fi
2022-07-27 16:38:33 +00:00
if [ "$RUN_SERVICES" = true ]; then
# 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.
2022-07-27 16:38:33 +00:00
ssh "$FQDN" "bash -c $BTCPAY_SERVER_APPPATH/btcpay-up.sh"
2022-08-15 13:39:10 +00:00
2022-07-29 22:33:24 +00:00
OPEN_URL=true
fi
2022-07-29 22:33:24 +00:00
if [ "$OPEN_URL" = true ]; then
if [ "$VPS_HOSTING_TARGET" = lxd ]; then
2022-08-24 14:11:50 +00:00
if wait-for-it -t 5 "$WWW_FQDN:80"; then
xdg-open "http://$WWW_FQDN" > /dev/null 2>&1
fi
else
if wait-for-it -t 5 "$FQDN:443"; then
xdg-open "https://$FQDN" > /dev/null 2>&1
fi
2022-07-29 22:33:24 +00:00
fi
2022-08-03 14:53:11 +00:00
fi