From e38172dd2d6681c82a4554a0a6930b48f0b4b5ab Mon Sep 17 00:00:00 2001 From: Derek Smith Date: Mon, 15 Aug 2022 09:37:13 -0400 Subject: [PATCH] Whitespace, formatting, control udpates. --- .vscode/settings.json | 4 ++-- cluster.sh | 10 ++++++---- deployment/btcpayserver/go.sh | 16 +++++++++++++--- deployment/create_lxc_base.sh | 6 ++---- deployment/domain_init.sh | 3 +-- deployment/wait_for_lxc_ip.sh | 2 ++ 6 files changed, 26 insertions(+), 15 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 601c1df..6bcd5fc 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -13,8 +13,8 @@ "shellcheck.customArgs": [], "shellcheck.ignorePatterns": {}, "shellcheck.exclude": [ - "SC1090", - "SC1091", + // "SC1090", + // "SC1091", "SC2029" ], "terminal.integrated.fontFamily": "monospace", diff --git a/cluster.sh b/cluster.sh index da7a16d..b998b68 100755 --- a/cluster.sh +++ b/cluster.sh @@ -3,9 +3,9 @@ set -eux cd "$(dirname "$0")" -# NOTE This script is meant to be executed on your LXD bare metal servers. This script -# ensures that the LXD daemon is installed via snap package, then initialize the daemon -# to operate in clustered mode +# This script is meant to be executed on the management machine. +# it reaches out to an SSH endpoint and provisions that machine +# to use LXD. COMMAND="${1:-}" DATA_PLANE_MACVLAN_INTERFACE= @@ -15,6 +15,7 @@ if [ "$COMMAND" = create ]; then # override the cluster name. CLUSTER_NAME="${2:-}" + if [ -z "$CLUSTER_NAME" ]; then echo "ERROR: The cluster name was not provided." @@ -61,6 +62,7 @@ EOL if ! lxc remote list | grep -q "$CLUSTER_NAME"; then FQDN="${3:-}" + shift if [ -z "$FQDN" ]; then echo "ERROR: The Fully Qualified Domain Name of the new cluster member was not set." @@ -85,7 +87,7 @@ EOL shift ;; *) - # unknown option + ;; esac done diff --git a/deployment/btcpayserver/go.sh b/deployment/btcpayserver/go.sh index 8b50d84..ad9aad8 100755 --- a/deployment/btcpayserver/go.sh +++ b/deployment/btcpayserver/go.sh @@ -14,10 +14,13 @@ if [ "$UPDATE_BTCPAY" = true ]; then # btcpay-update.sh brings services back up, but does not take them down. ssh "$FQDN" "sudo bash -c $BTCPAY_SERVER_APPPATH/btcpay-update.sh" + sleep 20 + elif [ "$RESTORE_BTCPAY" = true ]; then # run the update. ssh "$FQDN" "bash -c $BTCPAY_SERVER_APPPATH/btcpay-down.sh" - + sleep 10 + ./restore.sh RUN_BACKUP=false @@ -54,7 +57,14 @@ if [ "$RUN_SERVICES" = true ]; then fi if [ "$OPEN_URL" = true ]; then - if wait-for-it -t 5 "$FQDN:443"; then - xdg-open "https://$FQDN" > /dev/null 2>&1 + + if [ "$VPS_HOSTING_TARGET" = lxd ]; then + if wait-for-it -t 5 "$WWW_FQDN:443"; then + xdg-open "https://$WWW_FQDN" > /dev/null 2>&1 + fi + else + if wait-for-it -t 5 "$FQDN:443"; then + xdg-open "https://$FQDN" > /dev/null 2>&1 + fi fi fi diff --git a/deployment/create_lxc_base.sh b/deployment/create_lxc_base.sh index 7328273..363e216 100755 --- a/deployment/create_lxc_base.sh +++ b/deployment/create_lxc_base.sh @@ -49,9 +49,7 @@ if ! lxc image list --format csv "$VM_NAME" | grep -q "$VM_NAME"; then lxc config set "$VM_NAME" "volatile.enp5s0.hwaddr=$SOVEREIGN_STACK_MAC_ADDRESS" lxc start "$VM_NAME" - - # let's wait a minimum of 15 seconds before we start checking for an IP address. - sleep 15 + sleep 10 # let's wait for the LXC vm remote machine to get an IP address. ./wait_for_lxc_ip.sh "$VM_NAME" @@ -59,5 +57,5 @@ if ! lxc image list --format csv "$VM_NAME" | grep -q "$VM_NAME"; then # stop the VM and get a snapshot. lxc stop "$VM_NAME" lxc publish "$CLUSTER_NAME:$VM_NAME" --alias "$VM_NAME" --public - lxc delete "$VM_NAME" + fi diff --git a/deployment/domain_init.sh b/deployment/domain_init.sh index d395965..746e8ea 100755 --- a/deployment/domain_init.sh +++ b/deployment/domain_init.sh @@ -3,7 +3,6 @@ set -eux cd "$(dirname "$0")" - # let's make sure we have an ssh keypair. We just use ~/.ssh/id_rsa # TODO convert this to SSH private key held on Trezor. THus trezor-T required for # login operations. This should be configurable of course. @@ -83,4 +82,4 @@ export DOCKER_HOST="ssh://ubuntu@$FQDN" # the following scripts take responsibility for the rest of the provisioning depending on the app you're deploying. bash -c "./$VIRTUAL_MACHINE/go.sh" -echo "Successfull deployed '$DOMAIN_NAME' with git commit '$(cat ./.git/refs/heads/master)' VPS_HOSTING_TARGET=$VPS_HOSTING_TARGET;" +echo "Successfully deployed '$DOMAIN_NAME' with git commit '$(cat ./.git/refs/heads/master)' VPS_HOSTING_TARGET=$VPS_HOSTING_TARGET;" diff --git a/deployment/wait_for_lxc_ip.sh b/deployment/wait_for_lxc_ip.sh index 7785825..cef8d96 100755 --- a/deployment/wait_for_lxc_ip.sh +++ b/deployment/wait_for_lxc_ip.sh @@ -22,5 +22,7 @@ done # we are using IP address here so we don't have to rely on external DNS # configuration for the base image preparataion. ssh-keygen -R "$IP_V4_ADDRESS" + ssh-keyscan -H -t ecdsa "$IP_V4_ADDRESS" >> "$SSH_HOME/known_hosts" + ssh "ubuntu@$IP_V4_ADDRESS" sudo chown -R ubuntu:ubuntu /home/ubuntu