2022-05-20 15:06:41 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-03-06 16:47:27 +00:00
|
|
|
set -exu
|
2022-05-20 15:06:41 +00:00
|
|
|
cd "$(dirname "$0")"
|
|
|
|
|
2022-09-09 18:00:07 +00:00
|
|
|
export DOCKER_HOST="ssh://ubuntu@$BTCPAY_FQDN"
|
|
|
|
|
2023-03-02 14:46:17 +00:00
|
|
|
# run the btcpay setup script if it hasn't been done before.
|
|
|
|
if [ "$(ssh "$BTCPAY_FQDN" [[ ! -f "$REMOTE_HOME/btcpay.complete" ]]; echo $?)" -eq 0 ]; then
|
|
|
|
./stub_btcpay_setup.sh
|
|
|
|
BACKUP_BTCPAY=false
|
|
|
|
fi
|
|
|
|
|
2022-10-24 01:04:50 +00:00
|
|
|
RUN_SERVICES=true
|
2022-07-29 22:33:24 +00:00
|
|
|
|
2022-07-27 16:38:33 +00:00
|
|
|
# we will re-run the btcpayserver provisioning scripts if directed to do so.
|
2022-05-20 15:06:41 +00:00
|
|
|
# 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-05-20 15:06:41 +00:00
|
|
|
|
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"
|
2022-05-20 15:06:41 +00:00
|
|
|
|
2022-08-15 13:37:13 +00:00
|
|
|
sleep 20
|
2022-10-24 01:04:50 +00:00
|
|
|
|
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"
|
2022-10-27 01:41:14 +00:00
|
|
|
sleep 15
|
2022-08-15 13:37:13 +00:00
|
|
|
|
2022-07-27 16:38:33 +00:00
|
|
|
./restore.sh
|
2022-05-20 15:06:41 +00:00
|
|
|
|
2022-07-29 22:33:24 +00:00
|
|
|
RUN_SERVICES=true
|
2022-12-12 22:16:47 +00:00
|
|
|
BACKUP_BTCPAY=false
|
2022-07-29 22:33:24 +00:00
|
|
|
|
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
|
2023-03-02 14:46:17 +00:00
|
|
|
BACKUP_BTCPAY=false
|
2022-07-27 16:38:33 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# if the script gets this far, then we grab a regular backup.
|
2022-12-12 22:16:47 +00:00
|
|
|
if [ "$BACKUP_BTCPAY" = true ]; then
|
2022-07-27 16:38:33 +00:00
|
|
|
# we just grab a regular backup
|
2022-10-26 23:33:43 +00:00
|
|
|
./backup_btcpay.sh
|
2022-05-20 15:06:41 +00:00
|
|
|
fi
|
|
|
|
|
2022-12-12 22:16:47 +00:00
|
|
|
if [ "$RUN_SERVICES" = true ] && [ "$STOP_SERVICES" = false ]; then
|
2022-05-20 15:06:41 +00:00
|
|
|
# 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-05-20 15:06:41 +00:00
|
|
|
fi
|
2022-07-29 22:33:24 +00:00
|
|
|
|
2023-03-02 14:46:17 +00:00
|
|
|
echo "FINISHED btcpayserver/go.sh"
|