Compare commits
24 Commits
441eff3f26
...
be69d5774d
Author | SHA1 | Date | |
---|---|---|---|
be69d5774d | |||
e4a19010c6 | |||
9c0e29f772 | |||
54be0f6b3c | |||
bf5ff6903e | |||
a3b29e129a | |||
6a0255a326 | |||
a1c50b083d | |||
0f65419d55 | |||
cae11df6a5 | |||
18bff0d2e9 | |||
425bfd8069 | |||
b82813231c | |||
f2b02e474d | |||
5a54400831 | |||
69ab9d0a42 | |||
35afd1bbd4 | |||
a44ce22e00 | |||
33a855e801 | |||
69161e726e | |||
622741ce06 | |||
a4301c0a1c | |||
d786227a5f | |||
7d839e9724 |
30
defaults.sh
30
defaults.sh
@ -4,7 +4,7 @@ set -e
|
|||||||
|
|
||||||
export DEPLOY_GHOST=true
|
export DEPLOY_GHOST=true
|
||||||
export DEPLOY_CLAMS=false
|
export DEPLOY_CLAMS=false
|
||||||
|
export DEPLOY_NOSTR=false
|
||||||
export DEPLOY_NEXTCLOUD=false
|
export DEPLOY_NEXTCLOUD=false
|
||||||
export DEPLOY_GITEA=false
|
export DEPLOY_GITEA=false
|
||||||
|
|
||||||
@ -71,13 +71,13 @@ export GITEA_DB_IMAGE="$DEFAULT_DB_IMAGE"
|
|||||||
|
|
||||||
export NOSTR_RELAY_IMAGE="scsibug/nostr-rs-relay"
|
export NOSTR_RELAY_IMAGE="scsibug/nostr-rs-relay"
|
||||||
|
|
||||||
export WWW_SERVER_MAC_ADDRESS=
|
export WWW_SERVER_MAC_A DDRESS=
|
||||||
export BTCPAYSERVER_MAC_ADDRESS=
|
export BTCPAYSERVER_MAC_ADDRESS=
|
||||||
|
|
||||||
export SS_ROOT_PATH="$HOME/.ss"
|
export SS_ROOT_PATH="$HOME/ss"
|
||||||
|
|
||||||
export REMOTES_DIR="$SS_ROOT_PATH/remotes"
|
export REMOTES_PATH="$SS_ROOT_PATH/remotes"
|
||||||
export PROJECTS_DIR="$SS_ROOT_PATH/projects"
|
export PROJECTS_PATH="$SS_ROOT_PATH/projects"
|
||||||
export SITES_PATH="$SS_ROOT_PATH/sites"
|
export SITES_PATH="$SS_ROOT_PATH/sites"
|
||||||
|
|
||||||
# mount into ss-mgmt/home/ubuntu/snap/lxd/common/config
|
# mount into ss-mgmt/home/ubuntu/snap/lxd/common/config
|
||||||
@ -96,19 +96,29 @@ export OTHER_SITES_LIST=
|
|||||||
export BTCPAY_ALT_NAMES=
|
export BTCPAY_ALT_NAMES=
|
||||||
export BITCOIN_CHAIN=regtest
|
export BITCOIN_CHAIN=regtest
|
||||||
export REMOTE_HOME="/home/ubuntu"
|
export REMOTE_HOME="/home/ubuntu"
|
||||||
|
export REMOTE_DATA_PATH="$REMOTE_HOME/ss-data"
|
||||||
|
export REMOTE_DATA_PATH_LETSENCRYPT="$REMOTE_DATA_PATH/letsencrypt"
|
||||||
|
export REMOTE_BACKUP_PATH="$REMOTE_HOME/backups"
|
||||||
|
export BTCPAY_SERVER_APPPATH="$REMOTE_DATA_PATH/btcpayserver-docker"
|
||||||
|
|
||||||
export BTCPAY_SERVER_APPPATH="$REMOTE_HOME/btcpayserver-docker"
|
# this space is for OS, docker images, etc
|
||||||
export REMOTE_CERT_BASE_DIR="$REMOTE_HOME/.certs"
|
# values here are fine for regtest generally. Later scripts adjust
|
||||||
|
# these values based on testnet/mainnet
|
||||||
|
export WWW_SSDATA_DISK_SIZE_GB=20
|
||||||
|
export WWW_BACKUP_DISK_SIZE_GB=50
|
||||||
|
export WWW_DOCKER_DISK_SIZE_GB=30
|
||||||
|
|
||||||
|
export BTCPAYSERVER_SSDATA_DISK_SIZE_GB=20
|
||||||
|
export BTCPAYSERVER_BACKUP_DISK_SIZE_GB=5
|
||||||
|
export BTCPAYSERVER_DOCKER_DISK_SIZE_GB=30
|
||||||
|
|
||||||
# this space is for OS, docker images, etc. DOES NOT INCLUDE USER DATA.
|
|
||||||
export ROOT_DISK_SIZE_GB=20
|
|
||||||
export REGISTRY_URL="https://index.docker.io/v1"
|
export REGISTRY_URL="https://index.docker.io/v1"
|
||||||
export PRIMARY_DOMAIN=
|
export PRIMARY_DOMAIN=
|
||||||
|
|
||||||
# this is the git commit of the project/ sub git repo.
|
# this is the git commit of the project/ sub git repo.
|
||||||
# used in the migration script to switch into past for backup
|
# used in the migration script to switch into past for backup
|
||||||
# then back to present (TARGET_PROJECT_GIT_COMMIT) for restore.
|
# then back to present (TARGET_PROJECT_GIT_COMMIT) for restore.
|
||||||
export TARGET_PROJECT_GIT_COMMIT=7a710d09162f98fa38e4c60fa00c87c8bcbeb5e9
|
export TARGET_PROJECT_GIT_COMMIT=f05daa9bfb11242eab920fdc4dd490d9bfdd6fbb
|
||||||
|
|
||||||
#
|
#
|
||||||
export TESTNET_BLOCK_HASH=00000000d8277ba1ca66b40b3e3476629e6f0f97c5b8cfaeabfe402e55db223a
|
export TESTNET_BLOCK_HASH=00000000d8277ba1ca66b40b3e3476629e6f0f97c5b8cfaeabfe402e55db223a
|
||||||
|
@ -1,102 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -e
|
|
||||||
cd "$(dirname "$0")"
|
|
||||||
|
|
||||||
# this script destroys all resources in the current project.
|
|
||||||
|
|
||||||
if lxc remote get-default | grep -q "local"; then
|
|
||||||
echo "ERROR: you are on the local lxc remote. Nothing to destroy"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "WARNING: This will DESTROY any existing VMs!"
|
|
||||||
|
|
||||||
RESPONSE=
|
|
||||||
read -r -p "Are you sure you want to continue (y/n): ": RESPONSE
|
|
||||||
if [ "$RESPONSE" != "y" ]; then
|
|
||||||
echo "STOPPING."
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
USER_TARGET_PROJECT=
|
|
||||||
|
|
||||||
# grab any modifications from the command line.
|
|
||||||
for i in "$@"; do
|
|
||||||
case $i in
|
|
||||||
--project=*)
|
|
||||||
USER_TARGET_PROJECT="${i#*=}"
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
echo "Unexpected option: $1"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
. ../defaults.sh
|
|
||||||
|
|
||||||
. ./remote_env.sh
|
|
||||||
|
|
||||||
for PROJECT_CHAIN in ${DEPLOYMENT_STRING//,/ }; do
|
|
||||||
NO_PARENS="${PROJECT_CHAIN:1:${#PROJECT_CHAIN}-2}"
|
|
||||||
PROJECT_PREFIX=$(echo "$NO_PARENS" | cut -d'|' -f1)
|
|
||||||
BITCOIN_CHAIN=$(echo "$NO_PARENS" | cut -d'|' -f2)
|
|
||||||
|
|
||||||
PROJECT_NAME="$PROJECT_PREFIX-$BITCOIN_CHAIN"
|
|
||||||
PROJECT_PATH="$PROJECTS_DIR/$PROJECT_NAME"
|
|
||||||
|
|
||||||
# if the user sets USER_TARGET_PROJECT, let's ensure the project exists.
|
|
||||||
if [ -n "$USER_TARGET_PROJECT" ]; then
|
|
||||||
if [ "$PROJECT_NAME" != "$USER_TARGET_PROJECT" ]; then
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
export PROJECT_NAME="$PROJECT_NAME"
|
|
||||||
export PROJECT_PATH="$PROJECT_PATH"
|
|
||||||
|
|
||||||
. ./project_env.sh
|
|
||||||
|
|
||||||
if ! lxc info | grep "project:" | grep -q "$PROJECT_NAME"; then
|
|
||||||
if lxc project list | grep -q "$PROJECT_NAME"; then
|
|
||||||
lxc project switch "$PROJECT_NAME"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
for VM in www btcpayserver; do
|
|
||||||
LXD_NAME="$VM-${DOMAIN_NAME//./-}"
|
|
||||||
|
|
||||||
if lxc list | grep -q "$LXD_NAME"; then
|
|
||||||
lxc delete -f "$LXD_NAME"
|
|
||||||
|
|
||||||
# remove the ssh known endpoint else we get warnings.
|
|
||||||
ssh-keygen -f "$SSH_HOME/known_hosts" -R "$LXD_NAME"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if lxc profile list | grep -q "$LXD_NAME"; then
|
|
||||||
lxc profile delete "$LXD_NAME"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if lxc network list -q | grep -q ss-ovn; then
|
|
||||||
lxc network delete ss-ovn
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! lxc info | grep "project:" | grep -q default; then
|
|
||||||
lxc project switch default
|
|
||||||
fi
|
|
||||||
|
|
||||||
if lxc project list | grep -q "$PROJECT_NAME"; then
|
|
||||||
lxc project delete "$PROJECT_NAME"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# delete the base image so it can be created.
|
|
||||||
if lxc list | grep -q "$BASE_IMAGE_VM_NAME"; then
|
|
||||||
lxc delete -f "$BASE_IMAGE_VM_NAME"
|
|
||||||
# remove the ssh known endpoint else we get warnings.
|
|
||||||
ssh-keygen -f "$SSH_HOME/known_hosts" -R "$LXD_NAME"
|
|
||||||
fi
|
|
||||||
done
|
|
95
deployment/down.sh
Executable file
95
deployment/down.sh
Executable file
@ -0,0 +1,95 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# https://www.sovereign-stack.org/ss-down/
|
||||||
|
|
||||||
|
set -exu
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
|
||||||
|
if lxc remote get-default -q | grep -q "local"; then
|
||||||
|
echo "ERROR: you are on the local lxc remote. Nothing to take down"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
KEEP_DOCKER_VOLUME=true
|
||||||
|
|
||||||
|
# grab any modifications from the command line.
|
||||||
|
for i in "$@"; do
|
||||||
|
case $i in
|
||||||
|
--destroy)
|
||||||
|
KEEP_DOCKER_VOLUME=false
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unexpected option: $1"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
. ../defaults.sh
|
||||||
|
|
||||||
|
. ./remote_env.sh
|
||||||
|
|
||||||
|
. ./project_env.sh
|
||||||
|
|
||||||
|
|
||||||
|
# let's bring down services on the remote deployment if necessary.
|
||||||
|
export DOMAIN_NAME="$PRIMARY_DOMAIN"
|
||||||
|
export SITE_PATH="$SITES_PATH/$PRIMARY_DOMAIN"
|
||||||
|
|
||||||
|
source "$SITE_PATH/site.conf"
|
||||||
|
source ./project/domain_env.sh
|
||||||
|
|
||||||
|
SKIP=btcpayserver
|
||||||
|
for VIRTUAL_MACHINE in www btcpayserver; do
|
||||||
|
LXD_NAME="$VIRTUAL_MACHINE-${PRIMARY_DOMAIN//./-}"
|
||||||
|
|
||||||
|
if lxc list | grep -q "$LXD_NAME"; then
|
||||||
|
bash -c "./project/deploy.sh --stop --skip-$SKIP"
|
||||||
|
|
||||||
|
lxc stop "$LXD_NAME"
|
||||||
|
|
||||||
|
lxc delete "$LXD_NAME"
|
||||||
|
|
||||||
|
# remove the ssh known endpoint else we get warnings.
|
||||||
|
ssh-keygen -f "$SSH_HOME/known_hosts" -R "$LXD_NAME"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if lxc profile list | grep -q "$LXD_NAME"; then
|
||||||
|
lxc profile delete "$LXD_NAME"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$KEEP_DOCKER_VOLUME" = false ]; then
|
||||||
|
# destroy the docker volume
|
||||||
|
VM_ID=w
|
||||||
|
if [ "$VIRTUAL_MACHINE" = btcpayserver ]; then
|
||||||
|
VM_ID="b"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# d for docker; b for backup; s for ss-data
|
||||||
|
for DATA in d b s; do
|
||||||
|
VOLUME_NAME="$PRIMARY_DOMAIN_IDENTIFIER-$VM_ID""$DATA"
|
||||||
|
if lxc storage volume list ss-base -q | grep -q "$VOLUME_NAME"; then
|
||||||
|
RESPONSE=
|
||||||
|
read -r -p "Are you sure you want to delete the '$VOLUME_NAME' volume intended for '$LXD_NAME'?": RESPONSE
|
||||||
|
|
||||||
|
if [ "$RESPONSE" = "y" ]; then
|
||||||
|
lxc storage volume delete ss-base "$VOLUME_NAME"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
SKIP=www
|
||||||
|
done
|
||||||
|
|
||||||
|
if lxc network list -q | grep -q ss-ovn; then
|
||||||
|
lxc network delete ss-ovn
|
||||||
|
fi
|
||||||
|
|
||||||
|
# delete the base image so it can be created.
|
||||||
|
if lxc list | grep -q "$BASE_IMAGE_VM_NAME"; then
|
||||||
|
lxc delete -f "$BASE_IMAGE_VM_NAME" --project default
|
||||||
|
# remove the ssh known endpoint else we get warnings.
|
||||||
|
ssh-keygen -f "$SSH_HOME/known_hosts" -R "$BASE_IMAGE_VM_NAME"
|
||||||
|
fi
|
@ -2,12 +2,13 @@
|
|||||||
You are in the Sovereign Stack Management Environment (SSME). From here, you can issue several commands:
|
You are in the Sovereign Stack Management Environment (SSME). From here, you can issue several commands:
|
||||||
|
|
||||||
ss-remote - Take a remote SSH endpoint under management of Sovereign Stack.
|
ss-remote - Take a remote SSH endpoint under management of Sovereign Stack.
|
||||||
ss-deploy - Deploys Sovereign Stack instances to your currenty remote according to your
|
ss-reset - The opposite of ss-remote; de-provisions an existing remote.
|
||||||
|
ss-up - Instantiate a deployment to your active project according to your
|
||||||
various remote.conf, project.conf, and site.conf files.
|
various remote.conf, project.conf, and site.conf files.
|
||||||
|
ss-down - Reverses ss-up. Takes the active project down. Non-destructive of user data,
|
||||||
|
unless you provide the --destroy flag.
|
||||||
|
ss-update - This is just ss-down then ss-up.
|
||||||
ss-show - show the lxd resources associated with the current remote.
|
ss-show - show the lxd resources associated with the current remote.
|
||||||
ss-update - brings an existing deployment up to the newest version of Sovereign Stack.
|
|
||||||
ss-destroy - Destroys the active deployment (WARNING: destructive).
|
|
||||||
ss-reset - The opposite of ss-remote; deprovisions on the current remote.
|
|
||||||
|
|
||||||
For more infomation about all these topics, consult the Sovereign Stack website starting with:
|
For more infomation about all these topics, consult the Sovereign Stack website starting with:
|
||||||
|
|
||||||
|
@ -1,8 +1,19 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -eu
|
set -eu
|
||||||
cd "$(dirname "$0")"
|
|
||||||
|
|
||||||
|
PROJECT_NAME="$(lxc info | grep "project:" | awk '{print $2}')"
|
||||||
|
export PROJECT_NAME="$PROJECT_NAME"
|
||||||
|
|
||||||
|
if [ "$PROJECT_NAME" = default ]; then
|
||||||
|
echo "ERROR: You are on the default project. Use 'lxc project list' and 'lxc project switch <project>'."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
BITCOIN_CHAIN=$(echo "$PROJECT_NAME" | cut -d'-' -f2)
|
||||||
|
|
||||||
|
export PROJECT_PATH="$PROJECTS_PATH/$PROJECT_NAME"
|
||||||
|
export BITCOIN_CHAIN="$BITCOIN_CHAIN"
|
||||||
|
|
||||||
PROJECT_DEFINITION_PATH="$PROJECT_PATH/project.conf"
|
PROJECT_DEFINITION_PATH="$PROJECT_PATH/project.conf"
|
||||||
|
|
||||||
@ -27,8 +38,13 @@ fi
|
|||||||
|
|
||||||
source "$PRIMARY_SITE_DEFINITION_PATH"
|
source "$PRIMARY_SITE_DEFINITION_PATH"
|
||||||
|
|
||||||
if ! lxc info | grep "project:" | grep -q "$PROJECT_NAME"; then
|
SHASUM_OF_PRIMARY_DOMAIN="$(echo -n "$PRIMARY_DOMAIN" | sha256sum | awk '{print $1;}' )"
|
||||||
if lxc project list | grep -q "$PROJECT_NAME"; then
|
export PRIMARY_DOMAIN_IDENTIFIER="${SHASUM_OF_PRIMARY_DOMAIN: -6}"
|
||||||
lxc project switch "$PROJECT_NAME"
|
|
||||||
fi
|
export WWW_SSDATA_DISK_SIZE_GB="$WWW_SSDATA_DISK_SIZE_GB"
|
||||||
fi
|
export WWW_BACKUP_DISK_SIZE_GB="$WWW_BACKUP_DISK_SIZE_GB"
|
||||||
|
export WWW_DOCKER_DISK_SIZE_GB="$WWW_DOCKER_DISK_SIZE_GB"
|
||||||
|
|
||||||
|
export BTCPAYSERVER_SSDATA_DISK_SIZE_GB="$BTCPAYSERVER_SSDATA_DISK_SIZE_GB"
|
||||||
|
export BTCPAYSERVER_BACKUP_DISK_SIZE_GB="$BTCPAYSERVER_BACKUP_DISK_SIZE_GB"
|
||||||
|
export BTCPAYSERVER_DOCKER_DISK_SIZE_GB="$BTCPAYSERVER_DOCKER_DISK_SIZE_GB"
|
||||||
|
@ -21,7 +21,7 @@ fi
|
|||||||
#shellcheck disable=SC1091
|
#shellcheck disable=SC1091
|
||||||
source ../defaults.sh
|
source ../defaults.sh
|
||||||
|
|
||||||
export REMOTE_PATH="$REMOTES_DIR/$REMOTE_NAME"
|
export REMOTE_PATH="$REMOTES_PATH/$REMOTE_NAME"
|
||||||
REMOTE_DEFINITION="$REMOTE_PATH/remote.conf"
|
REMOTE_DEFINITION="$REMOTE_PATH/remote.conf"
|
||||||
export REMOTE_DEFINITION="$REMOTE_DEFINITION"
|
export REMOTE_DEFINITION="$REMOTE_DEFINITION"
|
||||||
|
|
||||||
@ -88,13 +88,15 @@ if ! lxc remote list | grep -q "$REMOTE_NAME"; then
|
|||||||
ssh-copy-id -i "$HOME/.ssh/id_rsa.pub" "ubuntu@$FQDN"
|
ssh-copy-id -i "$HOME/.ssh/id_rsa.pub" "ubuntu@$FQDN"
|
||||||
|
|
||||||
if [ -z "$DISK_TO_USE" ]; then
|
if [ -z "$DISK_TO_USE" ]; then
|
||||||
echo "INFO: It looks like the DISK_TO_USE has not been set. Enter it now."
|
if ! ssh "ubuntu@$FQDN" lxc storage list -q | grep -q ss-base; then
|
||||||
echo ""
|
echo "INFO: It looks like the DISK_TO_USE has not been set. Enter it now."
|
||||||
|
echo ""
|
||||||
|
|
||||||
ssh "ubuntu@$FQDN" lsblk --paths
|
ssh "ubuntu@$FQDN" lsblk --paths
|
||||||
|
|
||||||
echo "Please enter the disk or partition that Sovereign Stack will use to store data: "
|
echo "Please enter the disk or partition that Sovereign Stack will use to store data: "
|
||||||
read -r DISK_TO_USE
|
read -r DISK_TO_USE
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
@ -129,14 +131,14 @@ if ! command -v lxc >/dev/null 2>&1; then
|
|||||||
sleep 1
|
sleep 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if lxc network list --format csv | grep -q lxdbr0; then
|
if lxc network list --format csv -q --project default | grep -q lxdbr0; then
|
||||||
lxc network delete lxdbr0
|
lxc network delete lxdbr0 --project default
|
||||||
sleep 1
|
sleep 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
if lxc network list --format csv | grep -q lxdbr1; then
|
if lxc network list --format csv -q project default | grep -q lxdbr1; then
|
||||||
lxc network delete lxdbr1
|
lxc network delete lxdbr1 --project default
|
||||||
sleep 1
|
sleep 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -150,9 +152,7 @@ if ! ssh "ubuntu@$FQDN" snap list | grep -q lxd; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# install OVN for the project-specific bridge networks
|
# install OVN for the project-specific bridge networks
|
||||||
ssh -t "ubuntu@$FQDN" "sudo apt-get install -y ovn-host ovn-central"
|
ssh -t "ubuntu@$FQDN" "sudo apt-get install -y ovn-host ovn-central && sudo ovs-vsctl set open_vswitch . external_ids:ovn-remote=unix:/var/run/ovn/ovnsb_db.sock external_ids:ovn-encap-type=geneve external_ids:ovn-encap-ip=127.0.0.1"
|
||||||
|
|
||||||
ssh -t "ubuntu@$FQDN" "sudo ovs-vsctl set open_vswitch . external_ids:ovn-remote=unix:/var/run/ovn/ovnsb_db.sock external_ids:ovn-encap-type=geneve external_ids:ovn-encap-ip=127.0.0.1"
|
|
||||||
|
|
||||||
# if the user did not specify the interface, we just use whatever is used for the default route.
|
# if the user did not specify the interface, we just use whatever is used for the default route.
|
||||||
if [ -z "$DATA_PLANE_MACVLAN_INTERFACE" ]; then
|
if [ -z "$DATA_PLANE_MACVLAN_INTERFACE" ]; then
|
||||||
@ -240,14 +240,14 @@ if ! lxc storage list --format csv | grep -q ss-base; then
|
|||||||
lxc storage create ss-base zfs
|
lxc storage create ss-base zfs
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# create the testnet/mainnet blocks/chainstate subvolumes.
|
# # create the testnet/mainnet blocks/chainstate subvolumes.
|
||||||
for CHAIN in mainnet testnet; do
|
# for CHAIN in mainnet testnet; do
|
||||||
for DATA in blocks chainstate; do
|
# for DATA in blocks chainstate; do
|
||||||
if ! lxc storage volume list ss-base | grep -q "$CHAIN-$DATA"; then
|
# if ! lxc storage volume list ss-base | grep -q "$CHAIN-$DATA"; then
|
||||||
lxc storage volume create ss-base "$CHAIN-$DATA" --type=filesystem
|
# lxc storage volume create ss-base "$CHAIN-$DATA" --type=filesystem
|
||||||
fi
|
# fi
|
||||||
done
|
# done
|
||||||
done
|
# done
|
||||||
|
|
||||||
else
|
else
|
||||||
echo "WARNING! The host '$FQDN' appears to have Sovereign Stack worksloads already provisioned. Proceed with care."
|
echo "WARNING! The host '$FQDN' appears to have Sovereign Stack worksloads already provisioned. Proceed with care."
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -eu
|
set -eu
|
||||||
cd "$(dirname "$0")"
|
|
||||||
|
|
||||||
CURRENT_REMOTE="$(lxc remote get-default)"
|
CURRENT_REMOTE="$(lxc remote get-default)"
|
||||||
|
|
||||||
@ -26,7 +25,7 @@ if echo "$CURRENT_REMOTE" | grep -q "production"; then
|
|||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export REMOTE_PATH="$REMOTES_DIR/$CURRENT_REMOTE"
|
export REMOTE_PATH="$REMOTES_PATH/$CURRENT_REMOTE"
|
||||||
REMOTE_DEFINITION="$REMOTE_PATH/remote.conf"
|
REMOTE_DEFINITION="$REMOTE_PATH/remote.conf"
|
||||||
export REMOTE_DEFINITION="$REMOTE_DEFINITION"
|
export REMOTE_DEFINITION="$REMOTE_DEFINITION"
|
||||||
|
|
||||||
@ -38,3 +37,50 @@ if [ ! -f "$REMOTE_DEFINITION" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
source "$REMOTE_DEFINITION"
|
source "$REMOTE_DEFINITION"
|
||||||
|
|
||||||
|
# ensure our projects are provisioned according to DEPLOYMENT_STRING
|
||||||
|
for PROJECT_CHAIN in ${DEPLOYMENT_STRING//,/ }; do
|
||||||
|
NO_PARENS="${PROJECT_CHAIN:1:${#PROJECT_CHAIN}-2}"
|
||||||
|
PROJECT_PREFIX=$(echo "$NO_PARENS" | cut -d'|' -f1)
|
||||||
|
BITCOIN_CHAIN=$(echo "$NO_PARENS" | cut -d'|' -f2)
|
||||||
|
PROJECT_NAME="$PROJECT_PREFIX-$BITCOIN_CHAIN"
|
||||||
|
|
||||||
|
# create the lxc project as specified by PROJECT_NAME
|
||||||
|
if ! lxc project list | grep -q "$PROJECT_NAME"; then
|
||||||
|
lxc project create "$PROJECT_NAME"
|
||||||
|
lxc project set "$PROJECT_NAME" features.networks=true features.images=false features.storage.volumes=true
|
||||||
|
lxc project switch "$PROJECT_NAME"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# default values are already at regtest mode.
|
||||||
|
if [ "$BITCOIN_CHAIN" = testnet ]; then
|
||||||
|
|
||||||
|
WWW_SSDATA_DISK_SIZE_GB=30
|
||||||
|
WWW_BACKUP_DISK_SIZE_GB=30
|
||||||
|
WWW_DOCKER_DISK_SIZE_GB=50
|
||||||
|
|
||||||
|
BTCPAYSERVER_SSDATA_DISK_SIZE_GB=30
|
||||||
|
BTCPAYSERVER_BACKUP_DISK_SIZE_GB=30
|
||||||
|
BTCPAYSERVER_DOCKER_DISK_SIZE_GB=100
|
||||||
|
|
||||||
|
elif [ "$BITCOIN_CHAIN" = mainnet ]; then
|
||||||
|
|
||||||
|
WWW_SSDATA_DISK_SIZE_GB=40
|
||||||
|
WWW_BACKUP_DISK_SIZE_GB=40
|
||||||
|
WWW_DOCKER_DISK_SIZE_GB=1000
|
||||||
|
|
||||||
|
BTCPAYSERVER_SSDATA_DISK_SIZE_GB=30
|
||||||
|
BTCPAYSERVER_BACKUP_DISK_SIZE_GB=30
|
||||||
|
BTCPAYSERVER_DOCKER_DISK_SIZE_GB=500
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
export WWW_SSDATA_DISK_SIZE_GB="$WWW_SSDATA_DISK_SIZE_GB"
|
||||||
|
export WWW_BACKUP_DISK_SIZE_GB="$WWW_BACKUP_DISK_SIZE_GB"
|
||||||
|
export WWW_DOCKER_DISK_SIZE_GB="$WWW_DOCKER_DISK_SIZE_GB"
|
||||||
|
|
||||||
|
export BTCPAYSERVER_SSDATA_DISK_SIZE_GB="$BTCPAYSERVER_SSDATA_DISK_SIZE_GB"
|
||||||
|
export BTCPAYSERVER_BACKUP_DISK_SIZE_GB="$BTCPAYSERVER_BACKUP_DISK_SIZE_GB"
|
||||||
|
export BTCPAYSERVER_DOCKER_DISK_SIZE_GB="$BTCPAYSERVER_DOCKER_DISK_SIZE_GB"
|
||||||
|
|
||||||
|
done
|
@ -23,7 +23,7 @@ done
|
|||||||
|
|
||||||
source ../defaults.sh
|
source ../defaults.sh
|
||||||
|
|
||||||
./destroy.sh
|
./down.sh
|
||||||
|
|
||||||
# these only get initialzed upon creation, so we MUST delete here so they get recreated.
|
# these only get initialzed upon creation, so we MUST delete here so they get recreated.
|
||||||
if lxc profile list | grep -q "$BASE_IMAGE_VM_NAME"; then
|
if lxc profile list | grep -q "$BASE_IMAGE_VM_NAME"; then
|
||||||
@ -55,22 +55,22 @@ if [ "$PURGE_LXD" = true ]; then
|
|||||||
lxc profile device remove default eth0
|
lxc profile device remove default eth0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if lxc network list --format csv | grep -q lxdbr0; then
|
if lxc network list --format csv -q --project default | grep -q lxdbr0; then
|
||||||
lxc network delete lxdbr0
|
lxc network delete lxdbr0 --project default
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if lxc network list --format csv | grep -q lxdbr1; then
|
if lxc network list --format csv -q --project default | grep -q lxdbr1; then
|
||||||
lxc network delete lxdbr1
|
lxc network delete lxdbr1 --project default
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# create the testnet/mainnet blocks/chainstate subvolumes.
|
# # create the testnet/mainnet blocks/chainstate subvolumes.
|
||||||
for CHAIN in mainnet testnet; do
|
# for CHAIN in mainnet testnet; do
|
||||||
for DATA in blocks chainstate; do
|
# for DATA in blocks chainstate; do
|
||||||
if lxc storage volume list ss-base | grep -q "$CHAIN-$DATA"; then
|
# if lxc storage volume list ss-base | grep -q "$CHAIN-$DATA"; then
|
||||||
lxc storage volume delete ss-base "$CHAIN-$DATA"
|
# lxc storage volume delete ss-base "$CHAIN-$DATA"
|
||||||
fi
|
# fi
|
||||||
done
|
# done
|
||||||
done
|
# done
|
||||||
|
|
||||||
if lxc storage list --format csv | grep -q ss-base; then
|
if lxc storage list --format csv | grep -q ss-base; then
|
||||||
lxc storage delete ss-base
|
lxc storage delete ss-base
|
||||||
|
@ -7,39 +7,36 @@ cd "$(dirname "$0")"
|
|||||||
|
|
||||||
. ./remote_env.sh
|
. ./remote_env.sh
|
||||||
|
|
||||||
|
|
||||||
echo "Global Settings:"
|
echo "Global Settings:"
|
||||||
|
|
||||||
lxc image list
|
lxc image list
|
||||||
lxc storage list
|
lxc storage list
|
||||||
|
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo
|
||||||
|
|
||||||
|
PROJECT_NAME="$(lxc info | grep "project:" | awk '{print $2}')"
|
||||||
|
export export="$PROJECT_NAME"
|
||||||
|
export PROJECT_PATH="$PROJECTS_PATH/$PROJECT_NAME"
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo
|
||||||
|
echo "Active project: $PROJECT_NAME"
|
||||||
|
echo "----------------------------------------------------------"
|
||||||
|
|
||||||
|
echo " Networks:"
|
||||||
|
lxc network list
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo " Storage Volumes:"
|
||||||
lxc storage volume list ss-base
|
lxc storage volume list ss-base
|
||||||
|
|
||||||
echo
|
echo
|
||||||
|
echo " Profiles:"
|
||||||
|
lxc profile list
|
||||||
|
|
||||||
|
|
||||||
echo
|
echo
|
||||||
|
echo " Instances (VMs):"
|
||||||
for PROJECT_CHAIN in ${DEPLOYMENT_STRING//,/ }; do
|
lxc list
|
||||||
NO_PARENS="${PROJECT_CHAIN:1:${#PROJECT_CHAIN}-2}"
|
|
||||||
PROJECT_PREFIX=$(echo "$NO_PARENS" | cut -d'|' -f1)
|
|
||||||
BITCOIN_CHAIN=$(echo "$NO_PARENS" | cut -d'|' -f2)
|
|
||||||
PROJECT_NAME="$PROJECT_PREFIX-$BITCOIN_CHAIN"
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo
|
|
||||||
echo "Project: $PROJECT_NAME"
|
|
||||||
echo "----------------------------------------------------------"
|
|
||||||
if ! lxc info | grep "project:" | grep -q "$PROJECT_NAME"; then
|
|
||||||
if lxc project list | grep -q "$PROJECT_NAME"; then
|
|
||||||
lxc project switch "$PROJECT_NAME"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo " Networks:"
|
|
||||||
lxc network list
|
|
||||||
echo
|
|
||||||
echo " Profiles:"
|
|
||||||
lxc profile list
|
|
||||||
echo
|
|
||||||
echo " Instances (VMs):"
|
|
||||||
lxc list
|
|
||||||
echo "----------------------------------------------------------"
|
|
||||||
done
|
|
||||||
|
@ -22,108 +22,71 @@ if [ "$RESPONSE" != "y" ]; then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
USER_TARGET_PROJECT=
|
|
||||||
|
|
||||||
# grab any modifications from the command line.
|
|
||||||
for i in "$@"; do
|
|
||||||
case $i in
|
|
||||||
--project=*)
|
|
||||||
USER_TARGET_PROJECT="${i#*=}"
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
echo "Unexpected option: $1"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
|
|
||||||
. ../defaults.sh
|
. ../defaults.sh
|
||||||
|
|
||||||
. ./remote_env.sh
|
. ./remote_env.sh
|
||||||
|
|
||||||
for PROJECT_CHAIN in ${DEPLOYMENT_STRING//,/ }; do
|
. ./project_env.sh
|
||||||
NO_PARENS="${PROJECT_CHAIN:1:${#PROJECT_CHAIN}-2}"
|
|
||||||
PROJECT_PREFIX=$(echo "$NO_PARENS" | cut -d'|' -f1)
|
|
||||||
BITCOIN_CHAIN=$(echo "$NO_PARENS" | cut -d'|' -f2)
|
|
||||||
export PROJECT_PREFIX="$PROJECT_PREFIX"
|
|
||||||
export BITCOIN_CHAIN="$BITCOIN_CHAIN"
|
|
||||||
|
|
||||||
PROJECT_NAME="$PROJECT_PREFIX-$BITCOIN_CHAIN"
|
# Check to see if any of the VMs actually don't exist.
|
||||||
PROJECT_PATH="$PROJECTS_DIR/$PROJECT_NAME"
|
# (we only migrate instantiated vms)
|
||||||
|
for VM in www btcpayserver; do
|
||||||
|
LXD_NAME="$VM-${DOMAIN_NAME//./-}"
|
||||||
|
|
||||||
# if the user sets USER_TARGET_PROJECT, let's ensure the project exists.
|
# if the VM doesn't exist, the we emit an error message and hard quit.
|
||||||
if [ -n "$USER_TARGET_PROJECT" ]; then
|
if ! lxc list --format csv | grep -q "$LXD_NAME"; then
|
||||||
if ! lxc project list | grep -q "$USER_TARGET_PROJECT"; then
|
echo "ERROR: there is no VM named '$LXD_NAME'. You probably need to run ss-deploy again."
|
||||||
echo "ERROR: the project does not exist! Nothing to update."
|
exit 1
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$PROJECT_NAME" != "$USER_TARGET_PROJECT" ]; then
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
export PROJECT_NAME="$PROJECT_NAME"
|
BTCPAY_RESTORE_ARCHIVE_PATH="$SITES_PATH/$PRIMARY_DOMAIN/backups/btcpayserver/$(date +%s).tar.gz"
|
||||||
export PROJECT_PATH="$PROJECT_PATH"
|
echo "INFO: The BTCPAY_RESTORE_ARCHIVE_PATH for this migration will be: $BTCPAY_RESTORE_ARCHIVE_PATH"
|
||||||
|
|
||||||
. ./project_env.sh
|
# first we run ss-deploy --stop
|
||||||
|
# this grabs a backup of all data (backups are on by default) and saves them to the management machine
|
||||||
|
# the --stop flag ensures that services do NOT come back online.
|
||||||
|
# by default, we grab a backup.
|
||||||
|
|
||||||
# Check to see if any of the VMs actually don't exist.
|
# first, let's grab the GIT commit from the remote machine.
|
||||||
# (we only migrate instantiated vms)
|
export DOMAIN_NAME="$PRIMARY_DOMAIN"
|
||||||
for VM in www btcpayserver; do
|
export SITE_PATH="$SITES_PATH/$PRIMARY_DOMAIN"
|
||||||
LXD_NAME="$VM-${DOMAIN_NAME//./-}"
|
|
||||||
|
|
||||||
# if the VM doesn't exist, the we emit an error message and hard quit.
|
# source the site path so we know what features it has.
|
||||||
if ! lxc list --format csv | grep -q "$LXD_NAME"; then
|
source ../defaults.sh
|
||||||
echo "ERROR: there is no VM named '$LXD_NAME'. You probably need to run ss-deploy again."
|
source "$SITE_PATH/site.conf"
|
||||||
exit 1
|
source ./project/domain_env.sh
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
BTCPAY_RESTORE_ARCHIVE_PATH="$SITES_PATH/$PRIMARY_DOMAIN/backups/btcpayserver/$(date +%s).tar.gz"
|
# now we want to switch the git HEAD of the project subdirectory to the
|
||||||
echo "INFO: The BTCPAY_RESTORE_ARCHIVE_PATH for this migration will be: $BTCPAY_RESTORE_ARCHIVE_PATH"
|
# version of code that was last used
|
||||||
|
GIT_COMMIT_ON_REMOTE_HOST="$(ssh ubuntu@$BTCPAY_FQDN cat /home/ubuntu/.ss-githead)"
|
||||||
|
cd project/
|
||||||
|
echo "INFO: switch the 'project' repo to commit prior commit '$GIT_COMMIT_ON_REMOTE_HOST'"
|
||||||
|
echo " This allows Sovereign Stack to can grab a backup using the version of the code"
|
||||||
|
echo " that was used when the deployment was created."
|
||||||
|
git checkout "$GIT_COMMIT_ON_REMOTE_HOST"
|
||||||
|
cd -
|
||||||
|
|
||||||
# first we run ss-deploy --stop
|
# run deploy which backups up everything, but doesnt restart any services.
|
||||||
# this grabs a backup of all data (backups are on by default) and saves them to the management machine
|
bash -c "./project/deploy.sh --stop --backup-archive-path=$BTCPAY_RESTORE_ARCHIVE_PATH --backup-www --backup-btcpayserver"
|
||||||
# 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.
|
# call the down script (be default it is non-destructuve of user data.)
|
||||||
export DOMAIN_NAME="$PRIMARY_DOMAIN"
|
./down.sh
|
||||||
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.conf"
|
|
||||||
source ./project/domain_env.sh
|
|
||||||
|
|
||||||
# now we want to switch the git HEAD of the project subdirectory to the
|
# next we switch back to the current version of Sovereign Stack scripts for bringin up the new version.
|
||||||
# version of code that was last used
|
cd project/
|
||||||
GIT_COMMIT_ON_REMOTE_HOST="$(ssh ubuntu@$BTCPAY_FQDN cat /home/ubuntu/.ss-githead)"
|
echo "INFO: switching the 'project' repo back to the most recent commit '$TARGET_PROJECT_GIT_COMMIT'"
|
||||||
cd project/
|
echo " That way new deployments will be instantiated using the latest codebase."
|
||||||
echo "INFO: switch the 'project' repo to commit prior commit '$GIT_COMMIT_ON_REMOTE_HOST'"
|
git checkout "$TARGET_PROJECT_GIT_COMMIT"
|
||||||
echo " This allows Sovereign Stack to can grab a backup using the version of the code"
|
cd -
|
||||||
echo " that was used when the deployment was created."
|
|
||||||
git checkout "$GIT_COMMIT_ON_REMOTE_HOST"
|
|
||||||
cd -
|
|
||||||
|
|
||||||
# run deploy which backups up everything, but doesnt restart any services.
|
|
||||||
bash -c "./project/deploy.sh --project=$PROJECT_NAME --stop --no-cert-renew --backup-archive-path=$BTCPAY_RESTORE_ARCHIVE_PATH"
|
|
||||||
|
|
||||||
# call the destroy script. If user proceed, then user data is DESTROYED!
|
# TODO we can do some additional logic here. FOr example if the user wants to provide a source/target project/remote,
|
||||||
bash -c "./destroy.sh --project=$PROJECT_NAME"
|
# we can backup the source remote+project and restore it to the target remote+project. This will facilitate cross-device migrations
|
||||||
|
|
||||||
cd project/
|
# However, if the source and target project/remote are the same, we don't really
|
||||||
echo "INFO: switching the 'project' repo back to the most recent commit '$TARGET_PROJECT_GIT_COMMIT'"
|
# need to do any restorations (or backups for that matter, though we still grab one);
|
||||||
echo " That way new deployments will be instantiated using the latest codebase."
|
# we simply mount the existing data. That's the more common case where the user is simply upgrading the system in-place.
|
||||||
git checkout "$TARGET_PROJECT_GIT_COMMIT"
|
|
||||||
cd -
|
|
||||||
|
|
||||||
# Then we can run a restore operation and specify the backup archive at the CLI.
|
./project/deploy.sh
|
||||||
bash -c "./project/deploy.sh --project=$PROJECT_NAME -y --restore-www --restore-btcpay --backup-archive-path=$BTCPAY_RESTORE_ARCHIVE_PATH"
|
|
||||||
|
|
||||||
done
|
|
||||||
|
113
install.sh
113
install.sh
@ -1,9 +1,9 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -exu
|
set -eu
|
||||||
cd "$(dirname "$0")"
|
cd "$(dirname "$0")"
|
||||||
|
|
||||||
# see https://www.sovereign-stack.org/management/
|
# https://www.sovereign-stack.org/install/
|
||||||
|
|
||||||
# this script is not meant to be executed from the SSME; Let's let's check and abort if so.
|
# this script is not meant to be executed from the SSME; Let's let's check and abort if so.
|
||||||
if [ "$(hostname)" = ss-mgmt ]; then
|
if [ "$(hostname)" = ss-mgmt ]; then
|
||||||
@ -19,13 +19,6 @@ fi
|
|||||||
DISK="rpool/lxd"
|
DISK="rpool/lxd"
|
||||||
export DISK="$DISK"
|
export DISK="$DISK"
|
||||||
|
|
||||||
# let's check to ensure the management machine is on the Baseline ubuntu
|
|
||||||
# TODO maybe remove this check; this theoretically should work on anything that support bash and lxd?
|
|
||||||
if ! lsb_release -d | grep -q "Ubuntu 22.04"; then
|
|
||||||
echo "ERROR: Your machine is not running the Ubuntu 22.04 LTS baseline OS on your management machine."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# install lxd snap and initialize it
|
# install lxd snap and initialize it
|
||||||
if ! snap list | grep -q lxd; then
|
if ! snap list | grep -q lxd; then
|
||||||
sudo snap install lxd --channel=latest/candidate
|
sudo snap install lxd --channel=latest/candidate
|
||||||
@ -79,55 +72,75 @@ if ! lxc image list | grep -q "$UBUNTU_BASE_IMAGE_NAME"; then
|
|||||||
lxc image import "$METADATA_FILE" "$IMAGE_FILE" --alias "$UBUNTU_BASE_IMAGE_NAME"
|
lxc image import "$METADATA_FILE" "$IMAGE_FILE" --alias "$UBUNTU_BASE_IMAGE_NAME"
|
||||||
else
|
else
|
||||||
lxc image copy "images:$BASE_LXC_IMAGE" local: --alias "$UBUNTU_BASE_IMAGE_NAME" --vm --auto-update
|
lxc image copy "images:$BASE_LXC_IMAGE" local: --alias "$UBUNTU_BASE_IMAGE_NAME" --vm --auto-update
|
||||||
mkdir -p "$SS_JAMMY_PATH"
|
mkdir -p "$SS_JAMMY_PATH"
|
||||||
lxc image export "$UBUNTU_BASE_IMAGE_NAME" "$SS_JAMMY_PATH" --vm
|
lxc image export "$UBUNTU_BASE_IMAGE_NAME" "$SS_JAMMY_PATH" --vm
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# if the ss-mgmt doesn't exist, create it.
|
# if the ss-mgmt doesn't exist, create it.
|
||||||
SSH_PUBKEY_PATH="$HOME/.ssh/id_rsa.pub"
|
SSH_PUBKEY_PATH="$HOME/.ssh/id_rsa.pub"
|
||||||
|
FROM_BUILT_IMAGE=false
|
||||||
if ! lxc list --format csv | grep -q ss-mgmt; then
|
if ! lxc list --format csv | grep -q ss-mgmt; then
|
||||||
lxc init "images:$BASE_LXC_IMAGE" ss-mgmt --vm -c limits.cpu=4 -c limits.memory=4GiB --profile=default
|
|
||||||
|
|
||||||
# mount the pre-verified sovereign stack git repo into the new vm
|
# TODO check to see if there's an existing ss-mgmt image to spawn from, otherwise do this.
|
||||||
|
if lxc image list | grep -q ss-mgmt; then
|
||||||
|
FROM_BUILT_IMAGE=true
|
||||||
|
lxc init ss-mgmt ss-mgmt --vm -c limits.cpu=4 -c limits.memory=4GiB --profile=default
|
||||||
|
else
|
||||||
|
lxc init "images:$BASE_LXC_IMAGE" ss-mgmt --vm -c limits.cpu=4 -c limits.memory=4GiB --profile=default
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
# mount the pre-verified sovereign stack git repo into the new vm
|
||||||
|
if ! lxc config device show ss-mgmt | grep -q ss-code; then
|
||||||
lxc config device add ss-mgmt ss-code disk source="$(pwd)" path=/home/ubuntu/sovereign-stack
|
lxc config device add ss-mgmt ss-code disk source="$(pwd)" path=/home/ubuntu/sovereign-stack
|
||||||
|
fi
|
||||||
|
|
||||||
# create the ~/.ss path and mount it into the vm.
|
# create the ~/ss path and mount it into the vm.
|
||||||
mkdir -p "$SS_ROOT_PATH"
|
mkdir -p "$SS_ROOT_PATH"
|
||||||
lxc config device add ss-mgmt ss-root disk source="$SS_ROOT_PATH" path=/home/ubuntu/.ss
|
|
||||||
|
|
||||||
# if a ~/.bitcoin/testnet3/blocks direrectory exists, mount it in.
|
if ! lxc config device show ss-mgmt | grep -q ss-root; then
|
||||||
BITCOIN_DIR="$HOME/.bitcoin"
|
lxc config device add ss-mgmt ss-root disk source="$SS_ROOT_PATH" path=/home/ubuntu/ss
|
||||||
REMOTE_BITCOIN_CACHE_PATH="/home/ubuntu/.ss/cache/bitcoin"
|
fi
|
||||||
BITCOIN_TESTNET_BLOCKS_PATH="$BITCOIN_DIR/testnet3/blocks"
|
|
||||||
if [ -d "$BITCOIN_TESTNET_BLOCKS_PATH" ]; then
|
|
||||||
lxc config device add ss-mgmt ss-testnet-blocks disk source="$BITCOIN_TESTNET_BLOCKS_PATH" path=$REMOTE_BITCOIN_CACHE_PATH/testnet/blocks
|
|
||||||
fi
|
|
||||||
|
|
||||||
# if a ~/.bitcoin/testnet3/blocks direrectory exists, mount it in.
|
# # if a ~/.bitcoin/testnet3/blocks direrectory exists, mount it in.
|
||||||
BITCOIN_TESTNET_CHAINSTATE_PATH="$BITCOIN_DIR/testnet3/chainstate"
|
# BITCOIN_DIR="$HOME/.bitcoin"
|
||||||
if [ -d "$BITCOIN_TESTNET_CHAINSTATE_PATH" ]; then
|
# REMOTE_BITCOIN_CACHE_PATH="/home/ubuntu/ss/cache/bitcoin"
|
||||||
lxc config device add ss-mgmt ss-testnet-chainstate disk source="$BITCOIN_TESTNET_CHAINSTATE_PATH" path=$REMOTE_BITCOIN_CACHE_PATH/testnet/chainstate
|
# BITCOIN_TESTNET_BLOCKS_PATH="$BITCOIN_DIR/testnet3/blocks"
|
||||||
fi
|
# if [ -d "$BITCOIN_TESTNET_BLOCKS_PATH" ]; then
|
||||||
|
# if ! lxc config device show ss-mgmt | grep -q ss-testnet-blocks; then
|
||||||
|
# lxc config device add ss-mgmt ss-testnet-blocks disk source="$BITCOIN_TESTNET_BLOCKS_PATH" path=$REMOTE_BITCOIN_CACHE_PATH/testnet/blocks
|
||||||
|
# fi
|
||||||
|
# fi
|
||||||
|
|
||||||
# if a ~/.bitcoin/blocks dir exists, mount it in.
|
# # if a ~/.bitcoin/testnet3/blocks direrectory exists, mount it in.
|
||||||
BITCOIN_MAINNET_BLOCKS_PATH="$BITCOIN_DIR/blocks"
|
# BITCOIN_TESTNET_CHAINSTATE_PATH="$BITCOIN_DIR/testnet3/chainstate"
|
||||||
if [ -d "$BITCOIN_MAINNET_BLOCKS_PATH" ]; then
|
# if [ -d "$BITCOIN_TESTNET_CHAINSTATE_PATH" ]; then
|
||||||
lxc config device add ss-mgmt ss-mainnet-blocks disk source="$BITCOIN_MAINNET_BLOCKS_PATH" path=$REMOTE_BITCOIN_CACHE_PATH/mainnet/blocks
|
# if ! lxc config device show ss-mgmt | grep -q ss-testnet-chainstate; then
|
||||||
else
|
# lxc config device add ss-mgmt ss-testnet-chainstate disk source="$BITCOIN_TESTNET_CHAINSTATE_PATH" path=$REMOTE_BITCOIN_CACHE_PATH/testnet/chainstate
|
||||||
echo "INFO: the blocks directory was not found for mainnet. It will NOT be mounted into ss-mgmt."
|
# fi
|
||||||
fi
|
# fi
|
||||||
|
|
||||||
# if a ~/.bitcoin/testnet3/blocks direrectory exists, mount it in.
|
# # if a ~/.bitcoin/blocks dir exists, mount it in.
|
||||||
BITCOIN_MAINNET_CHAINSTATE_PATH="$BITCOIN_DIR/chainstate"
|
# BITCOIN_MAINNET_BLOCKS_PATH="$BITCOIN_DIR/blocks"
|
||||||
if [ -d "$BITCOIN_MAINNET_CHAINSTATE_PATH" ]; then
|
# if [ -d "$BITCOIN_MAINNET_BLOCKS_PATH" ]; then
|
||||||
lxc config device add ss-mgmt ss-mainnet-chainstate disk source="$BITCOIN_MAINNET_CHAINSTATE_PATH" path=$REMOTE_BITCOIN_CACHE_PATH/mainnet/chainstate
|
# if ! lxc config device show ss-mgmt | grep -q ss-mainnet-blocks; then
|
||||||
else
|
# lxc config device add ss-mgmt ss-mainnet-blocks disk source="$BITCOIN_MAINNET_BLOCKS_PATH" path=$REMOTE_BITCOIN_CACHE_PATH/mainnet/blocks
|
||||||
echo "INFO: the chainstate directory was not found for mainnet. It will NOT be mounted into ss-mgmt."
|
# fi
|
||||||
fi
|
# fi
|
||||||
|
|
||||||
# mount the ssh directory in there.
|
# # if a ~/.bitcoin/testnet3/blocks direrectory exists, mount it in.
|
||||||
if [ -f "$SSH_PUBKEY_PATH" ]; then
|
# BITCOIN_MAINNET_CHAINSTATE_PATH="$BITCOIN_DIR/chainstate"
|
||||||
|
# if [ -d "$BITCOIN_MAINNET_CHAINSTATE_PATH" ]; then
|
||||||
|
# if ! lxc config device show ss-mgmt | grep -q ss-mainnet-blocks; then
|
||||||
|
# lxc config device add ss-mgmt ss-mainnet-chainstate disk source="$BITCOIN_MAINNET_CHAINSTATE_PATH" path=$REMOTE_BITCOIN_CACHE_PATH/mainnet/chainstate
|
||||||
|
# fi
|
||||||
|
# fi
|
||||||
|
|
||||||
|
# mount the ssh directory in there.
|
||||||
|
if [ -f "$SSH_PUBKEY_PATH" ]; then
|
||||||
|
if ! lxc config device show ss-mgmt | grep -q ss-ssh; then
|
||||||
lxc config device add ss-mgmt ss-ssh disk source="$HOME/.ssh" path=/home/ubuntu/.ssh
|
lxc config device add ss-mgmt ss-ssh disk source="$HOME/.ssh" path=/home/ubuntu/.ssh
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -176,15 +189,25 @@ ssh-keyscan -H -t ecdsa "$IP_V4_ADDRESS" >> "$SSH_HOME/known_hosts"
|
|||||||
|
|
||||||
ssh "ubuntu@$IP_V4_ADDRESS" sudo chown -R ubuntu:ubuntu /home/ubuntu
|
ssh "ubuntu@$IP_V4_ADDRESS" sudo chown -R ubuntu:ubuntu /home/ubuntu
|
||||||
|
|
||||||
ssh "ubuntu@$IP_V4_ADDRESS" /home/ubuntu/sovereign-stack/management/provision.sh
|
|
||||||
|
|
||||||
#lxc restart ss-mgmt
|
if [ "$FROM_BUILT_IMAGE" = false ]; then
|
||||||
|
ssh "ubuntu@$IP_V4_ADDRESS" /home/ubuntu/sovereign-stack/management/provision.sh
|
||||||
|
|
||||||
|
lxc stop ss-mgmt
|
||||||
|
|
||||||
|
if ! lxc image list | grep -q "ss-mgmt"; then
|
||||||
|
lxc publish ss-mgmt --alias=ss-mgmt
|
||||||
|
fi
|
||||||
|
|
||||||
|
lxc start ss-mgmt
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$ADDED_COMMAND" = true ]; then
|
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."
|
echo "NOTICE! You need to run 'source ~/.bashrc' before continuing. After that, type 'ss-manage' to enter your management environment."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
. ./defaults.sh
|
. ./defaults.sh
|
||||||
|
|
||||||
# As part of the install script, we pull down any other sovereign-stack git repos
|
# As part of the install script, we pull down any other sovereign-stack git repos
|
||||||
PROJECTS_SCRIPTS_REPO_URL="https://git.sovereign-stack.org/ss/project"
|
PROJECTS_SCRIPTS_REPO_URL="https://git.sovereign-stack.org/ss/project"
|
||||||
PROJECTS_SCRIPTS_PATH="$(pwd)/deployment/project"
|
PROJECTS_SCRIPTS_PATH="$(pwd)/deployment/project"
|
||||||
|
@ -1,8 +1,16 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# https://www.sovereign-stack.org/ss-manage/
|
||||||
|
|
||||||
set -eu
|
set -eu
|
||||||
cd "$(dirname "$0")"
|
cd "$(dirname "$0")"
|
||||||
|
|
||||||
|
# check to ensure dependencies are met.
|
||||||
|
if ! command -v lxc >/dev/null 2>&1; then
|
||||||
|
echo "This script requires 'lxd/lxc' to be installed. Please run 'install.sh'."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
if ! lxc remote get-default | grep -q "local"; then
|
if ! lxc remote get-default | grep -q "local"; then
|
||||||
lxc remote switch "local"
|
lxc remote switch "local"
|
||||||
fi
|
fi
|
||||||
|
@ -5,7 +5,7 @@ alias ss-remote='/home/ubuntu/sovereign-stack/deployment/remote.sh $@'
|
|||||||
alias ss-show='/home/ubuntu/sovereign-stack/deployment/show.sh $@'
|
alias ss-show='/home/ubuntu/sovereign-stack/deployment/show.sh $@'
|
||||||
alias ss-reset='/home/ubuntu/sovereign-stack/deployment/reset.sh $@'
|
alias ss-reset='/home/ubuntu/sovereign-stack/deployment/reset.sh $@'
|
||||||
alias ss-update='/home/ubuntu/sovereign-stack/deployment/update.sh $@'
|
alias ss-update='/home/ubuntu/sovereign-stack/deployment/update.sh $@'
|
||||||
alias ss-destroy='/home/ubuntu/sovereign-stack/deployment/destroy.sh $@'
|
alias ss-down='/home/ubuntu/sovereign-stack/deployment/down.sh $@'
|
||||||
alias ss-help='cat /home/ubuntu/sovereign-stack/deployment/help.txt'
|
alias ss-help='cat /home/ubuntu/sovereign-stack/deployment/help.txt'
|
||||||
|
|
||||||
alias ll='ls -lah'
|
alias ll='ls -lah'
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -exu
|
set -eu
|
||||||
|
|
||||||
PURGE_LXD=false
|
PURGE_LXD=false
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ if [ "$PURGE_LXD" = true ]; then
|
|||||||
lxc profile device remove default enp5s0
|
lxc profile device remove default enp5s0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if lxc network list | grep -q lxdbr0; then
|
if lxc network list --project default | grep -q lxdbr0; then
|
||||||
lxc network delete lxdbr0
|
lxc network delete lxdbr0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user