From 782d4d9dc5bc817d36c4ac521e5531fec30363ae Mon Sep 17 00:00:00 2001 From: Derek Smith Date: Fri, 22 Apr 2022 15:20:53 -0400 Subject: [PATCH] Added initial Umbrel support. Signed-off-by: Derek Smith --- defaults.sh | 2 ++ deploy.sh | 13 +++++++++++-- domain_init.sh | 2 ++ go_umbrel.sh | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ lxc_profile.yml | 6 ++++++ shared.sh | 4 +++- 6 files changed, 75 insertions(+), 3 deletions(-) create mode 100755 go_umbrel.sh diff --git a/defaults.sh b/defaults.sh index e0370f6..dfee58e 100644 --- a/defaults.sh +++ b/defaults.sh @@ -4,6 +4,7 @@ set -eu export DEPLOY_WWW_SERVER=true export DEPLOY_BTCPPAY_SERVER=false +export DEPLOY_UMBREL_VPS=false # if true, then we deploy a VPS with Jitsi/Matrix export DEPLOY_GHOST=true @@ -14,6 +15,7 @@ export DEPLOY_GITEA=false export WWW_HOSTNAME="www" export BTCPAY_HOSTNAME="btcpay" +export UMBREL_HOSTNAME="umbrel" export NEXTCLOUD_HOSTNAME="nextcloud" export MATRIX_HOSTNAME="chat" export GITEA_HOSTNAME="git" diff --git a/deploy.sh b/deploy.sh index 42157c9..be2890a 100755 --- a/deploy.sh +++ b/deploy.sh @@ -91,7 +91,8 @@ source ./defaults.sh # iterate over all our server endpoints and provision them if needed. # www -for APP_TO_DEPLOY in btcpay www; do +VPS_HOSTNAME= +for APP_TO_DEPLOY in btcpay www umbrel; do FQDN= export APP_TO_DEPLOY="$APP_TO_DEPLOY" # shellcheck disable=SC1091 @@ -113,7 +114,15 @@ for APP_TO_DEPLOY in btcpay www; do fi fi - export FQDN="$FQDN" + # skip umbrel if + if [ "$APP_TO_DEPLOY" = umbrel ]; then + VPS_HOSTNAME="$UMBREL_HOSTNAME" + MAC_ADDRESS_TO_PROVISION="$UMBREL_MAC_ADDRESS" + if [ "$DEPLOY_UMBREL_VPS" = false ]; then + continue + fi + fi + # generate the docker yaml and nginx configs. ./stub_docker_yml.sh diff --git a/domain_init.sh b/domain_init.sh index f9f019b..da18d44 100755 --- a/domain_init.sh +++ b/domain_init.sh @@ -77,6 +77,8 @@ if [ "$APP_TO_DEPLOY" = www ]; then ./go_www.sh elif [ "$APP_TO_DEPLOY" = btcpay ]; then ./go_btcpay.sh +elif [ "$APP_TO_DEPLOY" = umbrel ]; then + ./go_umbrel.sh elif [ "$APP_TO_DEPLOY" = certonly ]; then # renew the certs; certbot takes care of seeing if we need to actually renew. if [ "$RUN_CERT_RENEWAL" = true ]; then diff --git a/go_umbrel.sh b/go_umbrel.sh new file mode 100755 index 0000000..7c2af8d --- /dev/null +++ b/go_umbrel.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +set -exu + +ssh "$FQDN" " + set -x + + cd /home/ubuntu + + # first, lets make sure we have the latest code. We use git over HTTPS and store it in ~/umbrel + # ~/umbrel is the only folder we need to backup + if [ ! -d ./umbrel ]; then + git clone https://github.com/getumbrel/umbrel.git ./umbrel + else + + if [ -f ./umbrel/scripts/stop ]; then + sudo ./umbrel/scripts/stop + fi + fi +" + +# # DO SOME BACKUP OPERATION + +# ssh "$FQDN" " +# set -x + +# mkdir -p /home/ubuntu/backup + +# sudo PASSPHRASE=${DUPLICITY_BACKUP_PASSPHRASE} duplicity --exclude ${REMOTE_HOME}/umbrel/bitcoin/blocks ${REMOTE_HOME}/umbrel file://${REMOTE_BACKUP_PATH} +# sudo chown -R ubuntu:ubuntu ${REMOTE_BACKUP_PATH} +# " + +# Start services back up. +ssh "$FQDN" " + set -ex + cd /home/ubuntu/umbrel + + git config pull.rebase true + git fetch --all --tags + git checkout master + git pull + git checkout tags/v0.4.17 + + # To use Umbrel on mainnet, run: + sudo NETWORK=$BTC_CHAIN /home/ubuntu/umbrel/scripts/start +" + +# we wait for lightning to comone line too. +wait-for-it -t -60 "$FQDN:80" + +xdg-open "http://$FQDN" diff --git a/lxc_profile.yml b/lxc_profile.yml index 8e4bad1..0063812 100644 --- a/lxc_profile.yml +++ b/lxc_profile.yml @@ -25,6 +25,10 @@ config: - rsync - duplicity - sshfs + - fswatch + - jq + - git + - nano groups: - docker @@ -124,6 +128,8 @@ config: - sudo apt-get update - sudo apt-get install -y docker-ce docker-ce-cli containerd.io - echo "alias ll='ls -lah'" >> ${REMOTE_HOME}/.bash_profile + - sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose + - sudo chmod +x /usr/local/bin/docker-compose - sudo apt-get install -y openssh-server description: Default LXD profile for ${DOMAIN_NAME} diff --git a/shared.sh b/shared.sh index 24b251d..6aa2d28 100755 --- a/shared.sh +++ b/shared.sh @@ -35,11 +35,13 @@ export MATRIX_DB_PASSWORD="$(new_pass)" export MATRIX_SHARED_SECRET="$(new_pass)" export MATRIX_ADMIN_PASSWORD="$(new_pass)" export DUPLICITY_BACKUP_PASSPHRASE="$(new_pass)" +#export DEPLOY_UMBREL_VPS=false export DEPLOY_GHOST=true export DEPLOY_MATRIX=true export DEPLOY_NEXTCLOUD=true export DEPLOY_ONION_SITE=false -#export DEPLOY_BTCPAY_SERVER=true +# valid options: 'testnet' and 'mainnet' +#export BTC_CHAIN=testnet #export WWW_INSTANCE_TYPE="t2.medium" #export BTCPAY_ADDITIONAL_HOSTNAMES="pay.domain.tld" #export DEV_WWW_MAC_ADDRESS="00:16:3E:AD:25:2C"