From eb67ec10a757701381e0e9450f1cce3b6453a9b9 Mon Sep 17 00:00:00 2001 From: Derek Smith Date: Mon, 6 Mar 2023 15:42:17 -0500 Subject: [PATCH] Update debugging info. --- defaults.sh | 2 ++ deployment/checkout_old.sh | 5 +++++ deployment/cluster.sh | 2 +- deployment/cluster_env.sh | 2 -- deployment/destroy.sh | 2 +- deployment/migrate.sh | 42 ++++++++++++++++++++++++++++++++++++++ deployment/reset.sh | 2 +- install.sh | 14 +------------ publish.sh | 2 +- uninstall.sh | 2 +- 10 files changed, 55 insertions(+), 20 deletions(-) create mode 100644 deployment/checkout_old.sh diff --git a/defaults.sh b/defaults.sh index 69c0344..f11b771 100755 --- a/defaults.sh +++ b/defaults.sh @@ -98,3 +98,5 @@ export REMOTE_CERT_BASE_DIR="$REMOTE_HOME/.certs" export ROOT_DISK_SIZE_GB=20 export REGISTRY_URL="https://index.docker.io/v1/" export PRIMARY_DOMAIN= + +export TARGET_PROJECT_GIT_COMMIT=0701de580bdd6d32058852b0c6f290867d2d8ea2 \ No newline at end of file diff --git a/deployment/checkout_old.sh b/deployment/checkout_old.sh new file mode 100644 index 0000000..4f06359 --- /dev/null +++ b/deployment/checkout_old.sh @@ -0,0 +1,5 @@ +#!/bin/bash + + + +# purpose of script is to switch the ./project repo to the git commit as \ No newline at end of file diff --git a/deployment/cluster.sh b/deployment/cluster.sh index 5ad460f..cb49f6a 100755 --- a/deployment/cluster.sh +++ b/deployment/cluster.sh @@ -1,6 +1,6 @@ #!/bin/bash -set -ex +set -e cd "$(dirname "$0")" # This script is meant to be executed on the management machine. diff --git a/deployment/cluster_env.sh b/deployment/cluster_env.sh index 8309d50..f1af6a5 100755 --- a/deployment/cluster_env.sh +++ b/deployment/cluster_env.sh @@ -30,8 +30,6 @@ export CLUSTER_PATH="$CLUSTERS_DIR/$CURRENT_CLUSTER" CLUSTER_DEFINITION="$CLUSTER_PATH/cluster_definition" export CLUSTER_DEFINITION="$CLUSTER_DEFINITION" -echo "CLUSTER_DEFINITION: $CLUSTER_DEFINITION" - # ensure the cluster definition exists. if [ ! -f "$CLUSTER_DEFINITION" ]; then echo "ERROR: The cluster definition could not be found. You may need to run 'ss-cluster'." diff --git a/deployment/destroy.sh b/deployment/destroy.sh index 306bcac..a53bed5 100755 --- a/deployment/destroy.sh +++ b/deployment/destroy.sh @@ -1,6 +1,6 @@ #!/bin/bash -set -ex +set -e cd "$(dirname "$0")" # this script takes down all resources in the cluster. This script is DESTRUCTIVE of data, so make sure it's backed up first. diff --git a/deployment/migrate.sh b/deployment/migrate.sh index 78c5d28..947eba2 100755 --- a/deployment/migrate.sh +++ b/deployment/migrate.sh @@ -3,6 +3,15 @@ set -exu cd "$(dirname "$0")" + +# check if there are any uncommited changes. It's dangerous to +# alter production systems when you have commits to make or changes to stash. +if git update-index --refresh | grep -q "needs update"; then + echo "ERROR: You have uncommited changes! You MUST commit or stash all changes to continue." + exit 1 +fi + + USER_SAYS_YES=false for i in "$@"; do @@ -23,6 +32,19 @@ done . ./project_env.sh + +# deploy clams wallet. +PROJECTS_SCRIPTS_REPO_URL="https://git.sovereign-stack.org/ss/project" +PROJECTS_SCRIPTS_PATH="$(pwd)/deployment/project" +if [ ! -d "$PROJECTS_SCRIPTS_PATH" ]; then + git clone "$PROJECTS_SCRIPTS_REPO_URL" "$PROJECTS_SCRIPTS_PATH" +else + cd "$PROJECTS_SCRIPTS_PATH" + git pull + cd - +fi + + # Check to see if any of the VMs actually don't exist. # (we only migrate instantiated vms) for VM in www btcpayserver; do @@ -43,11 +65,31 @@ echo "INFO: The BTCPAY_RESTORE_ARCHIVE_PATH for this migration will be: $BTCPAY_ # the --stop flag ensures that services do NOT come back online. # by default, we grab a backup. +# first, let's grab the GIT commit from the remote machine. +export DOMAIN_NAME="$PRIMARY_DOMAIN" +export SITE_PATH="$SITES_PATH/$PRIMARY_DOMAIN" + +# source the site path so we know what features it has. +source ../defaults.sh +source "$SITE_PATH/site_definition" +source ./project/domain_env.sh + +GIT_COMMIT_ON_REMOTE_HOST="$(ssh ubuntu@$BTCPAY_FQDN cat /home/ubuntu/.ss-githead)" +cd project/ +git checkout "$GIT_COMMIT_ON_REMOTE_HOST" +cd - +sleep 5 + # run deploy which backups up everything, but doesnt restart any services. bash -c "./project/deploy.sh --stop --no-cert-renew --backup-archive-path=$BTCPAY_RESTORE_ARCHIVE_PATH" # call the destroy script. If user proceed, then user data is DESTROYED! USER_SAYS_YES="$USER_SAYS_YES" ./destroy.sh +cd project/ +git checkout "$TARGET_PROJECT_GIT_COMMIT" +cd - + +sleep 5 # Then we can run a restore operation and specify the backup archive at the CLI. bash -c "./project/deploy.sh -y --restore-www --restore-btcpay --backup-archive-path=$BTCPAY_RESTORE_ARCHIVE_PATH" diff --git a/deployment/reset.sh b/deployment/reset.sh index 199b978..0853342 100755 --- a/deployment/reset.sh +++ b/deployment/reset.sh @@ -1,7 +1,7 @@ #!/bin/bash -set -ex +set -e cd "$(dirname "$0")" source ../defaults.sh diff --git a/install.sh b/install.sh index b1cb684..9604255 100755 --- a/install.sh +++ b/install.sh @@ -1,6 +1,6 @@ #!/bin/bash -set -exu +set -eu cd "$(dirname "$0")" # see https://www.sovereign-stack.org/management/ @@ -138,15 +138,3 @@ if [ "$ADDED_COMMAND" = true ]; then echo "NOTICE! You need to run 'source ~/.bashrc' before continuing. After that, type 'ss-manage' to enter your management environment." fi - -# deploy clams wallet. -PROJECTS_SCRIPTS_REPO_URL="https://git.sovereign-stack.org/ss/project" -PROJECTS_SCRIPTS_PATH="$(pwd)/deployment/project" -if [ ! -d "$PROJECTS_SCRIPTS_PATH" ]; then - git clone "$PROJECTS_SCRIPTS_REPO_URL" "$PROJECTS_SCRIPTS_PATH" -else - cd "$PROJECTS_SCRIPTS_PATH" - git config --global pull.rebase false - git pull - cd - -fi diff --git a/publish.sh b/publish.sh index 2c2f30d..6d4a624 100755 --- a/publish.sh +++ b/publish.sh @@ -1,6 +1,6 @@ #!/bin/bash -set -exu +set -eu cd "$(dirname "$0")" # this script will tag the repo then push it to origin diff --git a/uninstall.sh b/uninstall.sh index 9f75ebb..a9d3d52 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -1,6 +1,6 @@ #!/bin/bash -set -exu +set -eu # this script undoes install.sh if ! command -v lxc >/dev/null 2>&1; then