project/btcpayserver/go.sh

46 lines
1.4 KiB
Bash
Raw Permalink Normal View History

2023-03-06 19:30:56 +00:00
#!/bin/bash
2023-03-06 19:56:45 +00:00
set -eu
2023-03-06 19:30:56 +00:00
cd "$(dirname "$0")"
2023-04-07 17:59:14 +00:00
if [ "$VIRTUAL_MACHINE" = btcpayserver ]; then
# send an updated ~/.bashrc so we have quicker access to cli tools
2023-08-11 13:48:20 +00:00
scp ./bashrc.txt "ubuntu@$BTCPAY_SERVER_FQDN:$REMOTE_HOME/.bashrc"
ssh "$BTCPAY_SERVER_FQDN" "chown ubuntu:ubuntu $REMOTE_HOME/.bashrc"
ssh "$BTCPAY_SERVER_FQDN" "chmod 0664 $REMOTE_HOME/.bashrc"
2023-04-07 17:59:14 +00:00
fi
2023-08-11 13:48:20 +00:00
./stub_btcpay_setup.sh
2023-03-06 19:30:56 +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.
2023-08-11 13:48:20 +00:00
ssh "$BTCPAY_SERVER_FQDN" "bash -c $BTCPAY_SERVER_APPPATH/btcpay-down.sh"
2023-03-06 19:30:56 +00:00
# btcpay-update.sh brings services back up, but does not take them down.
2023-08-11 13:48:20 +00:00
ssh "$BTCPAY_SERVER_FQDN" "sudo bash -c $BTCPAY_SERVER_APPPATH/btcpay-update.sh"
2023-03-06 19:30:56 +00:00
2023-04-04 20:23:42 +00:00
sleep 30
2023-03-06 19:30:56 +00:00
elif [ "$RESTORE_BTCPAY" = true ]; then
# run the update.
2023-08-11 13:48:20 +00:00
ssh "$BTCPAY_SERVER_FQDN" "bash -c $BTCPAY_SERVER_APPPATH/btcpay-down.sh"
2023-11-19 18:59:20 +00:00
sleep 25
2023-03-06 19:30:56 +00:00
./restore.sh
BACKUP_BTCPAY=false
fi
# if the script gets this far, then we grab a regular backup.
if [ "$BACKUP_BTCPAY" = true ]; then
# we just grab a regular backup
./backup_btcpay.sh
fi
2023-08-11 13:48:20 +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.
ssh "$BTCPAY_SERVER_FQDN" "bash -c $BTCPAY_SERVER_APPPATH/btcpay-up.sh"