From 68f487a5dcc6efdf8b57f26d5bed92eed0ceb673 Mon Sep 17 00:00:00 2001 From: Derek Smith Date: Sun, 20 Aug 2023 20:47:27 -0400 Subject: [PATCH] Update to latest project head. --- README.md | 2 +- deployment/down.sh | 13 +++++- deployment/project | 2 +- deployment/reset.sh | 8 ++-- deployment/restore.sh | 4 ++ deployment/stop.sh | 7 +++- deployment/up.sh | 27 ++++++++----- deployment/update.sh | 89 ----------------------------------------- management/bash_aliases | 13 +++--- 9 files changed, 49 insertions(+), 116 deletions(-) create mode 100755 deployment/restore.sh delete mode 100755 deployment/update.sh diff --git a/README.md b/README.md index a9ad2c1..b494f38 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # Documentation -All documentation for this project can be found at [sovereign-stack.org](https://www.sovereign-stack.org). +All documentation for this project can be found at [sovereign-stack.org](https://www.sovereign-stack.org). To get started with this code, check out [this post](https://www.sovereign-stack.org/get/). \ No newline at end of file diff --git a/deployment/down.sh b/deployment/down.sh index 1051138..43377bc 100755 --- a/deployment/down.sh +++ b/deployment/down.sh @@ -2,7 +2,7 @@ # https://www.sovereign-stack.org/ss-down/ -set -eu +set -exu cd "$(dirname "$0")" if lxc remote get-default -q | grep -q "local"; then @@ -15,6 +15,7 @@ OTHER_SITES_LIST= SKIP_BTCPAYSERVER=false SKIP_WWW=false SKIP_CLAMSSERVER=false +BACKUP_WWW_APPS=true # grab any modifications from the command line. for i in "$@"; do @@ -77,6 +78,14 @@ for VIRTUAL_MACHINE in $SERVERS; do if lxc list | grep -q "$LXD_NAME"; then bash -c "./stop.sh --server=$VIRTUAL_MACHINE" + if [ "$VIRTUAL_MACHINE" = www ] && [ "$BACKUP_WWW_APPS" = true ]; then + APP_LIST="letsencrypt ghost nextcloud gitea nostr" + echo "INFO: Backing up WWW apps." + for APP in $APP_LIST; do + bash -c "$(pwd)/project/www/backup_www.sh --app=$APP" + done + fi + lxc stop "$LXD_NAME" lxc delete "$LXD_NAME" @@ -119,4 +128,4 @@ done if lxc network list -q | grep -q ss-ovn; then lxc network delete ss-ovn -fi \ No newline at end of file +fi diff --git a/deployment/project b/deployment/project index 56e0e05..9eceb40 160000 --- a/deployment/project +++ b/deployment/project @@ -1 +1 @@ -Subproject commit 56e0e057a612fce1150c36b29932c2e6ccf64542 +Subproject commit 9eceb40dba3946011723321d059614c9d9acf8fe diff --git a/deployment/reset.sh b/deployment/reset.sh index 31a1e94..4f22e26 100755 --- a/deployment/reset.sh +++ b/deployment/reset.sh @@ -4,7 +4,6 @@ set -e cd "$(dirname "$0")" - PURGE_LXD=false # grab any modifications from the command line. @@ -72,9 +71,10 @@ if [ "$PURGE_LXD" = true ]; then # done # done - if lxc storage list --format csv | grep -q ss-base; then - lxc storage delete ss-base - fi + echo "WARNING: ss-basae NOT DELETED. NEED TO TEST THIS SCRIPT" + # if lxc storage list --format csv | grep -q ss-base; then + # lxc storage delete ss-base + # fi CURRENT_REMOTE="$(lxc remote get-default)" if ! lxc remote get-default | grep -q "local"; then diff --git a/deployment/restore.sh b/deployment/restore.sh new file mode 100755 index 0000000..52bb390 --- /dev/null +++ b/deployment/restore.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +set -exu + diff --git a/deployment/stop.sh b/deployment/stop.sh index fcf62b8..606aba5 100755 --- a/deployment/stop.sh +++ b/deployment/stop.sh @@ -53,7 +53,12 @@ if [ "$SERVER_TO_STOP" = www ]; then fi if [ "$SERVER_TO_STOP" = btcpayserver ]; then - ssh "$BTCPAY_SERVER_FQDN" "bash -c $BTCPAY_SERVER_APPPATH/btcpay-down.sh" + if wait-for-it -t 5 "$BTCPAY_SERVER_FQDN":22; then + ssh "$BTCPAY_SERVER_FQDN" "bash -c $BTCPAY_SERVER_APPPATH/btcpay-down.sh" + else + echo "ERROR: the remote BTCPAY Server is not available on ssh." + exit 1 + fi fi if [ "$SERVER_TO_STOP" = clamsserver ]; then diff --git a/deployment/up.sh b/deployment/up.sh index dcf0a5a..7c770b7 100755 --- a/deployment/up.sh +++ b/deployment/up.sh @@ -38,13 +38,13 @@ OTHER_SITES_LIST= PRIMARY_DOMAIN= RUN_CERT_RENEWAL=true SKIP_BASE_IMAGE_CREATION=false +RESTORE_WWW=false RESTORE_CERTS=false BACKUP_CERTS=true BACKUP_BTCPAY=true SKIP_BTCPAYSERVER=false SKIP_WWW=false SKIP_CLAMSSERVER=false -BACKUP_WWW_APPS=true BACKUP_BTCPAY_ARCHIVE_PATH= RESTORE_BTCPAY=false UPDATE_BTCPAY=false @@ -62,6 +62,10 @@ for i in "$@"; do RESTORE_CERTS=true shift ;; + --restore-wwwserver) + RESTORE_WWW=true + shift + ;; --restore-btcpay) RESTORE_BTCPAY=true shift @@ -124,6 +128,7 @@ fi export REGISTRY_DOCKER_IMAGE="registry:2" export BACKUP_CERTS="$BACKUP_CERTS" export RESTORE_BTCPAY="$RESTORE_BTCPAY" +export RESTORE_WWW="$RESTORE_WWW" export BACKUP_BTCPAY="$BACKUP_BTCPAY" export RUN_CERT_RENEWAL="$RUN_CERT_RENEWAL" export REMOTE_NAME="$REMOTE_NAME" @@ -131,7 +136,6 @@ export REMOTE_PATH="$REMOTES_PATH/$REMOTE_NAME" export USER_SAYS_YES="$USER_SAYS_YES" export BACKUP_BTCPAY_ARCHIVE_PATH="$BACKUP_BTCPAY_ARCHIVE_PATH" export RESTORE_CERTS="$RESTORE_CERTS" -export BACKUP_WWW_APPS="$BACKUP_WWW_APPS" # todo convert this to Trezor-T SSH_PUBKEY_PATH="$SSH_HOME/id_rsa.pub" @@ -430,25 +434,26 @@ if [ "$SKIP_CLAMSSERVER" = false ]; then if [ -n "$CLAMS_SERVER_MAC_ADDRESS" ]; then export DOCKER_HOST="ssh://ubuntu@$CLAMS_SERVER_FQDN" - # enable docker swarm mode so we can support docker stacks. - if docker info | grep -q "Swarm: inactive"; then - docker swarm init - fi - # set the active env to our CLAMS_FQDN cat >./project/clams-server/active_env.txt < ./project/clams-server/environments/"$CLAMS_SERVER_FQDN" < "$CLAMS_ENV_FILE" <