From b3857bb34ddde75d47b67ff0984af619741f7566 Mon Sep 17 00:00:00 2001 From: Derek Smith Date: Wed, 22 Jun 2022 13:39:46 -0400 Subject: [PATCH] Renamed/moved existing files. --- deployment/btcpayserver/backup.sh | 9 + deployment/btcpayserver/restore.sh | 19 ++ deployment/btcpayserver/run_setup.sh | 71 +++++++ umbrel.sh | 295 +++++++++++++++++++++++++++ 4 files changed, 394 insertions(+) create mode 100755 deployment/btcpayserver/backup.sh create mode 100755 deployment/btcpayserver/restore.sh create mode 100755 deployment/btcpayserver/run_setup.sh create mode 100644 umbrel.sh diff --git a/deployment/btcpayserver/backup.sh b/deployment/btcpayserver/backup.sh new file mode 100755 index 0000000..567c345 --- /dev/null +++ b/deployment/btcpayserver/backup.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +set -e + +# take the services down, create a backup archive, then pull it down. +ssh "$FQDN" "cd $REMOTE_HOME/btcpayserver-docker/; sudo bash -c ./backup.sh" +ssh "$FQDN" "sudo cp /var/lib/docker/volumes/backup_datadir/_data/backup.tar.gz $REMOTE_HOME/backups/btcpay.tar.gz" +ssh "$FQDN" "sudo chown ubuntu:ubuntu $REMOTE_HOME/backups/btcpay.tar.gz" +scp "$FQDN:$REMOTE_HOME/backups/btcpay.tar.gz" "$LOCAL_BACKUP_PATH/btcpay-$1.tar.gz" diff --git a/deployment/btcpayserver/restore.sh b/deployment/btcpayserver/restore.sh new file mode 100755 index 0000000..09d6feb --- /dev/null +++ b/deployment/btcpayserver/restore.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# this scripts ASSUMES services have already been taken down. + +# first let's ask the user for the absolute path to the backup file that we want to restore. +FILE_PATH= +read -r -p "Please enter the absolute path of the backup file you want to restore: ": FILE_PATH +if [ -f "$FILE_PATH" ]; then + # then we grab a backup of the existing stuff BEFORE the restoration attempt + ./btcpayserver/backup.sh "before-restore-$UNIX_BACKUP_TIMESTAMP" + + echo "INFO: Restoring BTCPAY Server: $FILE_PATH" + ssh "$FQDN" mkdir -p "$REMOTE_BACKUP_PATH" + scp "$FILE_PATH" "$FQDN:$REMOTE_BACKUP_PATH/btcpay.tar.gz" + ssh "$FQDN" "cd /; sudo tar -xzvf $REMOTE_BACKUP_PATH/btcpay.tar.gz" +else + echo "ERROR: File does not exist." + exit 1 +fi diff --git a/deployment/btcpayserver/run_setup.sh b/deployment/btcpayserver/run_setup.sh new file mode 100755 index 0000000..da617f8 --- /dev/null +++ b/deployment/btcpayserver/run_setup.sh @@ -0,0 +1,71 @@ +#!/bin/bash + +set -e + +# 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" </dev/null 2>&1 + then + +cat << 'EOF' +It looks like you already have Docker installed. Umbrel requires a modern version of Docker so this script will update them with the official Docker install script. + +If you would like to disable this behaviour you can abort this install and run again with --no-install-docker or --no-install-compose. + +You can pass flags to the installer like this: + + curl -L https://umbrel.sh | bash -s -- --no-install-docker --no-install-compose + +Waiting for 30 seconds... + +You may press Ctrl+C now to abort the install. + +EOF + sleep 30 + fi + + if [[ "${INSTALL_UMBREL}" = "true" ]] + then + mkdir -p "${UMBREL_INSTALL_PATH}" + if [[ "$(ls --almost-all "${UMBREL_INSTALL_PATH}")" ]] + then + echo "Error: Umbrel install path \"${UMBREL_INSTALL_PATH}\" already contains files" + echo "You can install Umbrel in a custom location with:" + echo + echo " curl -L https://umbrel.sh | bash -s -- --install-path /some/path" + exit 1 + fi + fi + + if [[ "${UPDATE_APT}" = "true" ]] + then + update_apt + fi + + if [[ "${INSTALL_APT_DEPS}" = "true" ]] + then + install_apt_deps + fi + + if [[ "${INSTALL_AVAHI}" = "true" ]] + then + install_avahi + fi + + if [[ "${INSTALL_YQ}" = "true" ]] + then + install_yq + fi + + if [[ "${INSTALL_DOCKER}" = "true" ]] + then + install_docker + fi + + if [[ "${INSTALL_DOCKER_COMPOSE}" = "true" ]] + then + install_docker_compose + fi + + if [[ "${INSTALL_UMBREL}" = "true" ]] + then + install_umbrel + + if [[ "${INSTALL_START_SCRIPT}" = "true" ]] + then + install_systemd_service + fi + + # Do the initial start outside of systemd so we get logs + sudo ${UMBREL_INSTALL_PATH}/scripts/start + + if [[ "${INSTALL_START_SCRIPT}" = "true" ]] + then + # Kick off the systemd service again so it's in sync + sudo systemctl start "umbrel-startup.service" + fi + + echo + echo "Umbrel has been sucessfully installed!" + fi +} + +main \ No newline at end of file