From 493946c1f5b2ed3d7b47ff19f8e9e87470bcfc45 Mon Sep 17 00:00:00 2001 From: Derek Smith Date: Thu, 9 Mar 2023 09:55:40 -0500 Subject: [PATCH] Rename cluster to remote. --- defaults.sh | 2 +- deployment/destroy.sh | 4 +- deployment/help.txt | 2 +- deployment/migrate.sh | 2 +- deployment/project_env.sh | 2 +- deployment/{cluster.sh => remote.sh} | 79 ++++++++++---------- deployment/{cluster_env.sh => remote_env.sh} | 20 ++--- install.sh | 1 - management/bash_profile | 2 +- 9 files changed, 55 insertions(+), 59 deletions(-) rename deployment/{cluster.sh => remote.sh} (71%) mode change 100755 => 100644 rename deployment/{cluster_env.sh => remote_env.sh} (54%) diff --git a/defaults.sh b/defaults.sh index b557b1a..767cf0e 100755 --- a/defaults.sh +++ b/defaults.sh @@ -74,7 +74,7 @@ export NOSTR_RELAY_IMAGE="scsibug/nostr-rs-relay" export WWW_SERVER_MAC_ADDRESS= export BTCPAYSERVER_MAC_ADDRESS= -export CLUSTERS_DIR="$HOME/ss-clusters" +export REMOTES_DIR="$HOME/ss-remotes" export PROJECTS_DIR="$HOME/ss-projects" export SITES_PATH="$HOME/ss-sites" diff --git a/deployment/destroy.sh b/deployment/destroy.sh index a53bed5..5da21b9 100755 --- a/deployment/destroy.sh +++ b/deployment/destroy.sh @@ -2,7 +2,7 @@ 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. +# this script takes down all resources in the remote. This script is DESTRUCTIVE of data, so make sure it's backed up first. if lxc remote get-default | grep -q "local"; then @@ -19,7 +19,7 @@ fi . ../defaults.sh -. ./cluster_env.sh +. ./remote_env.sh . ./project_env.sh diff --git a/deployment/help.txt b/deployment/help.txt index 2b9e2fc..e90b390 100644 --- a/deployment/help.txt +++ b/deployment/help.txt @@ -3,7 +3,7 @@ Sovereign Stack Help. You are in the Sovereign Stack management environment. From here, you can issue several commands: - ss-cluster - Take a remote SSH endpoint under management of Sovereign Stack. + ss-remote - Take a remote SSH endpoint under management of Sovereign Stack. ss-deploy - Creates an deployment to your active LXD remote (lxc remote get-default). ss-destroy - Destroys the active deployment (Warning: this action is DESTRUCTUVE of user data). ss-migrate - migrates an existing deployment to the newest version of Sovereign Stack. diff --git a/deployment/migrate.sh b/deployment/migrate.sh index 132464a..ba9b16d 100755 --- a/deployment/migrate.sh +++ b/deployment/migrate.sh @@ -28,7 +28,7 @@ done . ../defaults.sh -. ./cluster_env.sh +. ./remote_env.sh . ./project_env.sh diff --git a/deployment/project_env.sh b/deployment/project_env.sh index 62446a3..9569101 100755 --- a/deployment/project_env.sh +++ b/deployment/project_env.sh @@ -20,6 +20,6 @@ export PRIMARY_SITE_DEFINITION_PATH="$SITES_PATH/$PRIMARY_DOMAIN/site_definition source "$PRIMARY_SITE_DEFINITION_PATH" if [ -z "$PRIMARY_DOMAIN" ]; then - echo "ERROR: The PRIMARY_DOMAIN is not specified. Check your cluster definition." + echo "ERROR: The PRIMARY_DOMAIN is not specified. Check your remote definition." exit 1 fi diff --git a/deployment/cluster.sh b/deployment/remote.sh old mode 100755 new mode 100644 similarity index 71% rename from deployment/cluster.sh rename to deployment/remote.sh index cb49f6a..b2c7fc9 --- a/deployment/cluster.sh +++ b/deployment/remote.sh @@ -1,6 +1,6 @@ #!/bin/bash -set -e +set -ex cd "$(dirname "$0")" # This script is meant to be executed on the management machine. @@ -10,57 +10,57 @@ cd "$(dirname "$0")" DATA_PLANE_MACVLAN_INTERFACE= DISK_TO_USE= -# override the cluster name. -CLUSTER_NAME="${1:-}" -if [ -z "$CLUSTER_NAME" ]; then - echo "ERROR: The cluster name was not provided. Syntax is: 'ss-cluster CLUSTER_NAME SSH_HOST_FQDN'" - echo " for example: 'ss-cluster dev clusterhost01.domain.tld" +# override the remote name. +REMOTE_NAME="${1:-}" +if [ -z "$REMOTE_NAME" ]; then + echo "ERROR: The remote name was not provided. Syntax is: 'ss-remote REMOTE_NAME SSH_HOST_FQDN'" + echo " for example: 'ss-remote dev host01.domain.tld" exit 1 fi #shellcheck disable=SC1091 source ../defaults.sh -export CLUSTER_PATH="$CLUSTERS_DIR/$CLUSTER_NAME" -CLUSTER_DEFINITION="$CLUSTER_PATH/cluster_definition" -export CLUSTER_DEFINITION="$CLUSTER_DEFINITION" +export REMOTE_PATH="$REMOTES_DIR/$REMOTE_NAME" +REMOTE_DEFINITION="$REMOTE_PATH/remote_definition" +export REMOTE_DEFINITION="$REMOTE_DEFINITION" -mkdir -p "$CLUSTER_PATH" -if [ ! -f "$CLUSTER_DEFINITION" ]; then - # stub out a cluster_definition. - cat >"$CLUSTER_DEFINITION" <"$REMOTE_DEFINITION" <> /etc/sudoers' + # if the disk is loop-based, then we assume the / path exists. if [ "$DISK_TO_USE" != loop ]; then # ensure we actually have that disk/partition on the system. @@ -135,9 +138,9 @@ IP_OF_MGMT_MACHINE="$(ssh ubuntu@"$FQDN" env | grep SSH_CLIENT | cut -d " " -f 1 IP_OF_MGMT_MACHINE="${IP_OF_MGMT_MACHINE#*=}" IP_OF_MGMT_MACHINE="$(echo "$IP_OF_MGMT_MACHINE" | cut -d: -f1)" -# error out if the cluster password is unset. -if [ -z "$LXD_CLUSTER_PASSWORD" ]; then - echo "ERROR: LXD_CLUSTER_PASSWORD must be set in your cluster_definition." +# error out if the remote password is unset. +if [ -z "$LXD_REMOTE_PASSWORD" ]; then + echo "ERROR: LXD_REMOTE_PASSWORD must be set in your remote_definition." exit 1 fi @@ -155,10 +158,7 @@ if ! command -v lxc >/dev/null 2>&1; then fi # install dependencies. -ssh "ubuntu@$FQDN" sudo apt-get update && sudo apt-get upgrade -y && sudo apt install htop dnsutils nano -y if ! ssh "ubuntu@$FQDN" snap list | grep -q lxd; then - ssh "ubuntu@$FQDN" sudo snap install lxd --channel=5.10/stable - sleep 10 fi # if the DATA_PLANE_MACVLAN_INTERFACE is not specified, then we 'll @@ -169,12 +169,11 @@ fi export DATA_PLANE_MACVLAN_INTERFACE="$DATA_PLANE_MACVLAN_INTERFACE" -echo "DATA_PLANE_MACVLAN_INTERFACE: $DATA_PLANE_MACVLAN_INTERFACE" # run lxd init on the remote server. cat <