forked from ss/sovereign-stack
Renamed/moved existing files.
This commit is contained in:
parent
0a298f6293
commit
b3857bb34d
9
deployment/btcpayserver/backup.sh
Executable file
9
deployment/btcpayserver/backup.sh
Executable file
@ -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"
|
19
deployment/btcpayserver/restore.sh
Executable file
19
deployment/btcpayserver/restore.sh
Executable file
@ -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
|
71
deployment/btcpayserver/run_setup.sh
Executable file
71
deployment/btcpayserver/run_setup.sh
Executable file
@ -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" <<EOL
|
||||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
# wait for cloud-init to complete yo
|
||||
while [ ! -f /var/lib/cloud/instance/boot-finished ]; do
|
||||
sleep 1
|
||||
done
|
||||
|
||||
# if [ -d "btcpayserver-docker" ] && [ "$EXISTING_BRANCH" != "master" ] && [ "$EXISTING_REMOTE" != "master" ]; then
|
||||
# echo "existing btcpayserver-docker folder found that did not match our specified fork. Moving. (Current branch: $EXISTING_BRANCH, Current remote: $EXISTING_REMOTE)";
|
||||
# mv "btcpayserver-docker" "btcpayserver-docker_$(date +%s)";
|
||||
# fi
|
||||
|
||||
# if [ -d "btcpayserver-docker" ] && [ "$EXISTING_BRANCH" == "master" ] && [ "$EXISTING_REMOTE" == "master" ]; then
|
||||
# echo "existing btcpayserver-docker folder found, pulling instead of cloning.";
|
||||
# git pull;
|
||||
# fi
|
||||
|
||||
if [ ! -d "btcpayserver-docker" ]; then
|
||||
echo "cloning btcpayserver-docker";
|
||||
git clone -b master https://github.com/btcpayserver/btcpayserver-docker btcpayserver-docker;
|
||||
fi
|
||||
|
||||
export BTCPAY_HOST="${FQDN}"
|
||||
export NBITCOIN_NETWORK="${BTC_CHAIN}"
|
||||
export LIGHTNING_ALIAS="${DOMAIN_NAME}"
|
||||
export LETSENCRYPT_EMAIL="${CERTIFICATE_EMAIL_ADDRESS}"
|
||||
export BTCPAYGEN_LIGHTNING="clightning"
|
||||
export BTCPAYGEN_CRYPTO1="btc"
|
||||
|
||||
# opt-save-storage keeps 1 year of blocks (prunes to 100 GB)
|
||||
# opt-add-btctransmuter adds transmuter software
|
||||
#
|
||||
export BTCPAYGEN_ADDITIONAL_FRAGMENTS="opt-save-storage;opt-add-btctransmuter;opt-add-configurator;opt-add-nostr-relay;opt-add-tor-relay"
|
||||
#export BTCPAYGEN_EXCLUDE_FRAGMENTS="nginx-https"
|
||||
export BTCPAY_ADDITIONAL_HOSTS="${BTCPAY_ADDITIONAL_HOSTNAMES}"
|
||||
export BTCPAYGEN_REVERSEPROXY="nginx"
|
||||
export BTCPAY_ENABLE_SSH=false
|
||||
|
||||
cd btcpayserver-docker
|
||||
|
||||
if [ "\$NBITCOIN_NETWORK" != regtest ]; then
|
||||
# run fast_sync if it's not been done before.
|
||||
if [ ! -f /home/ubuntu/fast_sync_completed ]; then
|
||||
cd ./contrib/FastSync
|
||||
./load-utxo-set.sh
|
||||
touch /home/ubuntu/fast_sync_completed
|
||||
cd -
|
||||
fi
|
||||
fi
|
||||
|
||||
# provision the btcpay server
|
||||
. ./btcpay-setup.sh -i
|
||||
|
||||
EOL
|
||||
|
||||
# send the setup script to the remote machine.
|
||||
scp "$SITE_PATH/btcpay.sh" "ubuntu@$FQDN:$REMOTE_HOME/btcpay_setup.sh"
|
||||
ssh "$FQDN" "chmod 0744 $REMOTE_HOME/btcpay_setup.sh"
|
||||
ssh "$FQDN" "sudo bash -c ./btcpay_setup.sh"
|
295
umbrel.sh
Normal file
295
umbrel.sh
Normal file
@ -0,0 +1,295 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Default options
|
||||
BOOTSTRAPPED="false"
|
||||
PRINT_DOCKER_WARNING="true"
|
||||
UPDATE_APT="true"
|
||||
INSTALL_APT_DEPS="true"
|
||||
INSTALL_AVAHI="true"
|
||||
INSTALL_YQ="true"
|
||||
INSTALL_DOCKER="true"
|
||||
INSTALL_DOCKER_COMPOSE="true"
|
||||
INSTALL_START_SCRIPT="true"
|
||||
INSTALL_UMBREL="true"
|
||||
UMBREL_VERSION="release"
|
||||
UMBREL_REPO="getumbrel/umbrel"
|
||||
UMBREL_INSTALL_PATH="$HOME/umbrel"
|
||||
|
||||
# Parse arguments
|
||||
arguments=${@:-}
|
||||
|
||||
if [[ "${arguments}" = *"--bootstrapped"* ]]
|
||||
then
|
||||
BOOTSTRAPPED="true"
|
||||
fi
|
||||
|
||||
if [[ "${arguments}" = *"--no-docker-warning"* ]]
|
||||
then
|
||||
PRINT_DOCKER_WARNING="false"
|
||||
fi
|
||||
|
||||
if [[ "${arguments}" = *"--no-install-avahi"* ]]
|
||||
then
|
||||
INSTALL_AVAHI="false"
|
||||
fi
|
||||
|
||||
if [[ "${arguments}" = *"--no-install-yq"* ]]
|
||||
then
|
||||
INSTALL_YQ="false"
|
||||
fi
|
||||
|
||||
if [[ "${arguments}" = *"--no-install-docker"* ]]
|
||||
then
|
||||
INSTALL_DOCKER="false"
|
||||
fi
|
||||
|
||||
if [[ "${arguments}" = *"--no-install-compose"* ]]
|
||||
then
|
||||
INSTALL_DOCKER_COMPOSE="false"
|
||||
fi
|
||||
|
||||
if [[ "${arguments}" = *"--no-install-start-script"* ]]
|
||||
then
|
||||
INSTALL_START_SCRIPT="false"
|
||||
fi
|
||||
|
||||
if [[ "${arguments}" = *"--no-install-umbrel"* ]]
|
||||
then
|
||||
INSTALL_UMBREL="false"
|
||||
fi
|
||||
|
||||
if [[ "${arguments}" = *"--no-install-deps"* ]]
|
||||
then
|
||||
UPDATE_APT="false"
|
||||
INSTALL_APT_DEPS="false"
|
||||
INSTALL_AVAHI="false"
|
||||
INSTALL_YQ="false"
|
||||
INSTALL_DOCKER="false"
|
||||
INSTALL_DOCKER_COMPOSE="false"
|
||||
INSTALL_UMBREL="true"
|
||||
fi
|
||||
|
||||
if [[ "${arguments}" = *"--version"* ]]
|
||||
then
|
||||
UMBREL_VERSION="$(echo "${arguments}" | sed 's/.*--version \([^ ]*\).*/\1/')"
|
||||
fi
|
||||
|
||||
if [[ "${arguments}" = *"--install-path"* ]]
|
||||
then
|
||||
UMBREL_INSTALL_PATH="$(echo "${arguments}" | sed 's/.*--install-path \([^ ]*\).*/\1/')"
|
||||
fi
|
||||
|
||||
get_umbrel_version() {
|
||||
version="${UMBREL_VERSION}"
|
||||
if [[ "${version}" = "release" ]]
|
||||
then
|
||||
version=$(curl --silent https://api.github.com/repos/${UMBREL_REPO}/releases/latest | sed -n 's/.*"tag_name": "\([^"]*\).*/\1/p')
|
||||
fi
|
||||
|
||||
echo $version
|
||||
}
|
||||
|
||||
bootstrap() {
|
||||
version=$(get_umbrel_version)
|
||||
curl --location --silent "https://raw.githubusercontent.com/${UMBREL_REPO}/${version}/scripts/install" | \
|
||||
bash -s -- --bootstrapped $arguments
|
||||
}
|
||||
|
||||
update_apt() {
|
||||
sudo apt-get update --yes
|
||||
}
|
||||
|
||||
install_apt_deps() {
|
||||
sudo apt-get install --yes fswatch jq rsync curl git gettext-base python3 gnupg
|
||||
}
|
||||
|
||||
install_avahi() {
|
||||
sudo apt-get install --yes avahi-daemon avahi-discover libnss-mdns
|
||||
}
|
||||
|
||||
install_yq() {
|
||||
# Define checksums for yq (4.24.5)
|
||||
declare -A yq_sha256
|
||||
yq_sha256["arm64"]="8879e61c0b3b70908160535ea358ec67989ac4435435510e1fcb2eda5d74a0e9"
|
||||
yq_sha256["amd64"]="c93a696e13d3076e473c3a43c06fdb98fafd30dc2f43bc771c4917531961c760"
|
||||
|
||||
yq_version="v4.24.5"
|
||||
system_arch=$(dpkg --print-architecture)
|
||||
yq_binary="yq_linux_${system_arch}"
|
||||
|
||||
# Download yq from GitHub
|
||||
yq_temp_file="/tmp/yq"
|
||||
curl -L "https://github.com/mikefarah/yq/releases/download/${yq_version}/${yq_binary}" -o "${yq_temp_file}"
|
||||
|
||||
# Check file matches checksum
|
||||
if [[ "$(sha256sum "${yq_temp_file}" | awk '{ print $1 }')" == "${yq_sha256[$system_arch]}" ]]; then
|
||||
sudo mv "${yq_temp_file}" /usr/bin/yq
|
||||
sudo chmod +x /usr/bin/yq
|
||||
|
||||
echo "yq installed successfully..."
|
||||
else
|
||||
echo "yq install failed. sha256sum mismatch"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
install_docker() {
|
||||
# Install Docker
|
||||
curl -fsSL https://get.docker.com | sudo sh
|
||||
}
|
||||
|
||||
install_docker_compose() {
|
||||
sudo apt-get install --yes python3-pip libffi-dev
|
||||
# We need to upgrade pip (via itself) because old pip versions in some OS repos fail to install deps.
|
||||
python3 -m pip install --upgrade pip
|
||||
sudo python3 -m pip install docker-compose
|
||||
}
|
||||
|
||||
install_umbrel() {
|
||||
version=$(get_umbrel_version)
|
||||
curl --location "https://api.github.com/repos/${UMBREL_REPO}/tarball/${version}" | \
|
||||
tar --extract --gzip --strip-components=1 --directory="${UMBREL_INSTALL_PATH}"
|
||||
}
|
||||
|
||||
install_systemd_service() {
|
||||
echo "
|
||||
[Unit]
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
Wants=docker.service
|
||||
After=docker.service
|
||||
|
||||
# This prevents us hitting restart rate limits and ensures we keep restarting
|
||||
# indefinitely.
|
||||
StartLimitInterval=0
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
TimeoutStartSec=infinity
|
||||
TimeoutStopSec=16min
|
||||
ExecStart=${UMBREL_INSTALL_PATH}/scripts/start
|
||||
ExecStop=${UMBREL_INSTALL_PATH}/scripts/stop
|
||||
User=root
|
||||
Group=root
|
||||
StandardOutput=syslog
|
||||
StandardError=syslog
|
||||
SyslogIdentifier=umbrel startup
|
||||
RemainAfterExit=yes
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target" | sudo tee "/etc/systemd/system/umbrel-startup.service"
|
||||
sudo chmod 644 "/etc/systemd/system/umbrel-startup.service"
|
||||
sudo systemctl enable "umbrel-startup.service"
|
||||
}
|
||||
|
||||
main() {
|
||||
if [[ "${BOOTSTRAPPED}" = "false" ]]
|
||||
then
|
||||
bootstrap
|
||||
exit
|
||||
fi
|
||||
|
||||
if [[ "${INSTALL_UMBREL}" = "true" ]]
|
||||
then
|
||||
echo "About to install Umbrel in \"${UMBREL_INSTALL_PATH}\"."
|
||||
echo "If you would like to install somewhere else you can specify a custom location with:"
|
||||
echo
|
||||
echo " curl -L https://umbrel.sh | bash -s -- --install-path /some/path"
|
||||
echo
|
||||
echo "Waiting for 10 seconds..."
|
||||
echo
|
||||
echo "You may press Ctrl+C now to abort the install."
|
||||
echo
|
||||
sleep 10
|
||||
fi
|
||||
|
||||
if [[ "${PRINT_DOCKER_WARNING}" = "true" ]] && [[ "${INSTALL_DOCKER}" = "true" ]] && command -v docker >/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
|
Loading…
Reference in New Issue
Block a user