diff --git a/deployment/project_env.sh b/deployment/project_env.sh index f5c2596..381c4f9 100755 --- a/deployment/project_env.sh +++ b/deployment/project_env.sh @@ -1,7 +1,19 @@ #!/bin/bash set -eu -cd "$(dirname "$0")" + +export PROJECT_NAME="$(lxc info | grep "project:" | awk '{print $2}')" + +if [ "$PROJECT_NAME" = default ]; then + echo "ERROR: You are on the default project. Use 'lxc project list' and 'lxc project switch '." + exit 1 +fi + +PROJECT_PREFIX=$(echo "$PROJECT_NAME" | cut -d'-' -f1) +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" @@ -26,12 +38,6 @@ fi source "$PRIMARY_SITE_DEFINITION_PATH" -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 - SHASUM_OF_PRIMARY_DOMAIN="$(echo -n "$PRIMARY_DOMAIN" | sha256sum | awk '{print $1;}' )" export PRIMARY_DOMAIN_IDENTIFIER="${SHASUM_OF_PRIMARY_DOMAIN: -6}" diff --git a/deployment/remote.sh b/deployment/remote.sh index c12f9da..31e23a9 100755 --- a/deployment/remote.sh +++ b/deployment/remote.sh @@ -129,14 +129,14 @@ if ! command -v lxc >/dev/null 2>&1; then sleep 1 fi - if lxc network list --format csv | grep -q lxdbr0; then - lxc network delete lxdbr0 + if lxc network list --format csv -q --project default | grep -q lxdbr0; then + lxc network delete lxdbr0 --project default sleep 1 fi - if lxc network list --format csv | grep -q lxdbr1; then - lxc network delete lxdbr1 + if lxc network list --format csv -q project default | grep -q lxdbr1; then + lxc network delete lxdbr1 --project default sleep 1 fi diff --git a/deployment/remote_env.sh b/deployment/remote_env.sh index 1da5cd4..ce141eb 100755 --- a/deployment/remote_env.sh +++ b/deployment/remote_env.sh @@ -38,3 +38,50 @@ if [ ! -f "$REMOTE_DEFINITION" ]; then fi 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=false + fi + + + # default values are already at regtest mode. + if [ "$BITCOIN_CHAIN" = testnet ]; then + + WWW_SSDATA_DISK_SIZE_GB=30 + WWW_BACKUP_DISK_SIZE_GB=80 + WWW_DOCKER_DISK_SIZE_GB=50 + + BTCPAYSERVER_SSDATA_DISK_SIZE_GB=30 + BTCPAYSERVER_BACKUP_DISK_SIZE_GB=5 + BTCPAYSERVER_DOCKER_DISK_SIZE_GB=50 + + elif [ "$BITCOIN_CHAIN" = mainnet ]; then + + WWW_SSDATA_DISK_SIZE_GB=40 + WWW_BACKUP_DISK_SIZE_GB=80 + WWW_DOCKER_DISK_SIZE_GB=40 + + BTCPAYSERVER_SSDATA_DISK_SIZE_GB=30 + BTCPAYSERVER_BACKUP_DISK_SIZE_GB=10 + BTCPAYSERVER_DOCKER_DISK_SIZE_GB=300 + + 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 \ No newline at end of file diff --git a/deployment/reset.sh b/deployment/reset.sh index dfe9743..8a1d444 100755 --- a/deployment/reset.sh +++ b/deployment/reset.sh @@ -55,12 +55,12 @@ if [ "$PURGE_LXD" = true ]; then lxc profile device remove default eth0 fi - if lxc network list --format csv | grep -q lxdbr0; then - lxc network delete lxdbr0 + if lxc network list --format csv -q --project default | grep -q lxdbr0; then + lxc network delete lxdbr0 --project default fi - if lxc network list --format csv | grep -q lxdbr1; then - lxc network delete lxdbr1 + if lxc network list --format csv -q --project default | grep -q lxdbr1; then + lxc network delete lxdbr1 --project default fi # create the testnet/mainnet blocks/chainstate subvolumes.