Compare commits
3 Commits
a6dcf6c232
...
fbc6e2b6e5
Author | SHA1 | Date | |
---|---|---|---|
fbc6e2b6e5 | |||
2855218b28 | |||
8da9e63f7f |
@ -1,9 +1,9 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -eu
|
set -exu
|
||||||
cd "$(dirname "$0")"
|
cd "$(dirname "$0")"
|
||||||
|
|
||||||
./stub_lxc_profile.sh "$BASE_IMAGE_VM_NAME"
|
bash -c "./stub_lxc_profile.sh --lxd-hostname=$BASE_IMAGE_VM_NAME"
|
||||||
|
|
||||||
# let's download our base image.
|
# let's download our base image.
|
||||||
if ! lxc image list --format csv --columns l | grep -q "$UBUNTU_BASE_IMAGE_NAME"; then
|
if ! lxc image list --format csv --columns l | grep -q "$UBUNTU_BASE_IMAGE_NAME"; then
|
||||||
|
56
deploy.sh
56
deploy.sh
@ -371,22 +371,19 @@ for VIRTUAL_MACHINE in www btcpayserver; do
|
|||||||
export VPS_HOSTNAME="$VPS_HOSTNAME"
|
export VPS_HOSTNAME="$VPS_HOSTNAME"
|
||||||
export FQDN="$VPS_HOSTNAME.$DOMAIN_NAME"
|
export FQDN="$VPS_HOSTNAME.$DOMAIN_NAME"
|
||||||
|
|
||||||
DDNS_HOST=
|
|
||||||
|
|
||||||
if [ "$VIRTUAL_MACHINE" = www ]; then
|
if [ "$VIRTUAL_MACHINE" = www ]; then
|
||||||
if [ "$SKIP_WWW" = true ]; then
|
if [ "$SKIP_WWW" = true ]; then
|
||||||
echo "INFO: Skipping WWW due to command line argument."
|
echo "INFO: Skipping WWW due to command line argument."
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
FQDN="$WWW_HOSTNAME.$DOMAIN_NAME"
|
||||||
VPS_HOSTNAME="$WWW_HOSTNAME"
|
VPS_HOSTNAME="$WWW_HOSTNAME"
|
||||||
MAC_ADDRESS_TO_PROVISION="$WWW_SERVER_MAC_ADDRESS"
|
MAC_ADDRESS_TO_PROVISION="$WWW_SERVER_MAC_ADDRESS"
|
||||||
DDNS_HOST="$WWW_HOSTNAME"
|
|
||||||
ROOT_DISK_SIZE_GB="$((ROOT_DISK_SIZE_GB + NEXTCLOUD_SPACE_GB))"
|
ROOT_DISK_SIZE_GB="$((ROOT_DISK_SIZE_GB + NEXTCLOUD_SPACE_GB))"
|
||||||
|
|
||||||
elif [ "$VIRTUAL_MACHINE" = btcpayserver ] || [ "$SKIP_BTCPAY" = true ]; then
|
elif [ "$VIRTUAL_MACHINE" = btcpayserver ] || [ "$SKIP_BTCPAY" = true ]; then
|
||||||
|
FQDN="$BTCPAY_HOSTNAME.$DOMAIN_NAME"
|
||||||
|
|
||||||
DDNS_HOST="$BTCPAY_HOSTNAME"
|
|
||||||
VPS_HOSTNAME="$BTCPAY_HOSTNAME"
|
VPS_HOSTNAME="$BTCPAY_HOSTNAME"
|
||||||
MAC_ADDRESS_TO_PROVISION="$BTCPAYSERVER_MAC_ADDRESS"
|
MAC_ADDRESS_TO_PROVISION="$BTCPAYSERVER_MAC_ADDRESS"
|
||||||
if [ "$BITCOIN_CHAIN" = mainnet ]; then
|
if [ "$BITCOIN_CHAIN" = mainnet ]; then
|
||||||
@ -396,32 +393,31 @@ for VIRTUAL_MACHINE in www btcpayserver; do
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
elif [ "$VIRTUAL_MACHINE" = "$BASE_IMAGE_VM_NAME" ]; then
|
elif [ "$VIRTUAL_MACHINE" = "$BASE_IMAGE_VM_NAME" ]; then
|
||||||
DDNS_HOST="$BASE_IMAGE_VM_NAME"
|
export FQDN="$BASE_IMAGE_VM_NAME"
|
||||||
ROOT_DISK_SIZE_GB=8
|
ROOT_DISK_SIZE_GB=8
|
||||||
else
|
else
|
||||||
echo "ERROR: VIRTUAL_MACHINE not within allowable bounds."
|
echo "ERROR: VIRTUAL_MACHINE not within allowable bounds."
|
||||||
exit
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
export FQDN="$FQDN"
|
||||||
|
export LXD_VM_NAME="${FQDN//./-}"
|
||||||
|
export REMOTE_CERT_DIR="$REMOTE_CERT_BASE_DIR/$FQDN"
|
||||||
|
export MAC_ADDRESS_TO_PROVISION="$MAC_ADDRESS_TO_PROVISION"
|
||||||
|
|
||||||
|
./deploy_vm.sh
|
||||||
|
|
||||||
|
if [ "$VIRTUAL_MACHINE" = www ]; then
|
||||||
|
# this tells our local docker client to target the remote endpoint via SSH
|
||||||
|
export DOCKER_HOST="ssh://ubuntu@$PRIMARY_WWW_FQDN"
|
||||||
|
|
||||||
|
# enable docker swarm mode so we can support docker stacks.
|
||||||
|
if docker info | grep -q "Swarm: inactive"; then
|
||||||
|
docker swarm init --advertise-addr enp6s0
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
export DDNS_HOST="$DDNS_HOST"
|
|
||||||
export FQDN="$DDNS_HOST.$DOMAIN_NAME"
|
done
|
||||||
export LXD_VM_NAME="${FQDN//./-}"
|
|
||||||
export VIRTUAL_MACHINE="$VIRTUAL_MACHINE"
|
|
||||||
export REMOTE_CERT_DIR="$REMOTE_CERT_BASE_DIR/$FQDN"
|
|
||||||
export MAC_ADDRESS_TO_PROVISION="$MAC_ADDRESS_TO_PROVISION"
|
|
||||||
|
|
||||||
./deploy_vms.sh
|
|
||||||
|
|
||||||
if [ "$VIRTUAL_MACHINE" = www ]; then
|
|
||||||
# this tells our local docker client to target the remote endpoint via SSH
|
|
||||||
export DOCKER_HOST="ssh://ubuntu@$PRIMARY_WWW_FQDN"
|
|
||||||
|
|
||||||
# enable docker swarm mode so we can support docker stacks.
|
|
||||||
if docker info | grep -q "Swarm: inactive"; then
|
|
||||||
docker swarm init --advertise-addr enp6s0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# let's stub out the rest of our site definitions, if any.
|
# let's stub out the rest of our site definitions, if any.
|
||||||
for DOMAIN_NAME in ${OTHER_SITES_LIST//,/ }; do
|
for DOMAIN_NAME in ${OTHER_SITES_LIST//,/ }; do
|
||||||
|
@ -30,7 +30,7 @@ if ! lxc list --format csv | grep -q "$LXD_VM_NAME"; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
./stub_lxc_profile.sh "$LXD_VM_NAME"
|
bash -c "./stub_lxc_profile.sh --vm=$VIRTUAL_MACHINE --lxd-hostname=$LXD_VM_NAME"
|
||||||
|
|
||||||
# now let's create a new VM to work with.
|
# now let's create a new VM to work with.
|
||||||
#lxc init --profile="$LXD_VM_NAME" "$BASE_IMAGE_VM_NAME" "$LXD_VM_NAME" --vm
|
#lxc init --profile="$LXD_VM_NAME" "$BASE_IMAGE_VM_NAME" "$LXD_VM_NAME" --vm
|
||||||
@ -43,7 +43,7 @@ if ! lxc list --format csv | grep -q "$LXD_VM_NAME"; then
|
|||||||
|
|
||||||
lxc start "$LXD_VM_NAME"
|
lxc start "$LXD_VM_NAME"
|
||||||
|
|
||||||
bash -c "./wait_for_lxc_ip.sh --lxc-name=$LXD_VM_NAME"
|
bash -c "./wait_for_lxc_ip.sh --lxd-name=$LXD_VM_NAME"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# scan the remote machine and install it's identity in our SSH known_hosts file.
|
# scan the remote machine and install it's identity in our SSH known_hosts file.
|
@ -1,9 +1,28 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -eu
|
set -exu
|
||||||
cd "$(dirname "$0")"
|
cd "$(dirname "$0")"
|
||||||
|
|
||||||
LXD_HOSTNAME="${1:-}"
|
VIRTUAL_MACHINE=
|
||||||
|
LXD_HOSTNAME=
|
||||||
|
|
||||||
|
# grab any modifications from the command line.
|
||||||
|
for i in "$@"; do
|
||||||
|
case $i in
|
||||||
|
--lxd-hostname=*)
|
||||||
|
LXD_HOSTNAME="${i#*=}"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--vm=*)
|
||||||
|
VIRTUAL_MACHINE="${i#*=}"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unexpected option: $1"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
# generate the custom cloud-init file. Cloud init installs and configures sshd
|
# generate the custom cloud-init file. Cloud init installs and configures sshd
|
||||||
SSH_AUTHORIZED_KEY=$(<"$SSH_PUBKEY_PATH")
|
SSH_AUTHORIZED_KEY=$(<"$SSH_PUBKEY_PATH")
|
||||||
@ -37,7 +56,8 @@ EOF
|
|||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$LXD_HOSTNAME" = "$BASE_IMAGE_VM_NAME" ]; then
|
# if VIRTUAL_MACHINE is undefined, then we doing the base image.
|
||||||
|
if [ -z "$VIRTUAL_MACHINE" ]; then
|
||||||
# this is for the base image only...
|
# this is for the base image only...
|
||||||
cat >> "$YAML_PATH" <<EOF
|
cat >> "$YAML_PATH" <<EOF
|
||||||
user.vendor-data: |
|
user.vendor-data: |
|
||||||
@ -132,7 +152,7 @@ EOF
|
|||||||
#- sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
#- sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
||||||
|
|
||||||
else
|
else
|
||||||
# all other machines.
|
# all other machines that are not the base image
|
||||||
cat >> "$YAML_PATH" <<EOF
|
cat >> "$YAML_PATH" <<EOF
|
||||||
user.vendor-data: |
|
user.vendor-data: |
|
||||||
#cloud-config
|
#cloud-config
|
||||||
@ -163,7 +183,7 @@ EOF
|
|||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If we are deploying the www, we attach the vm to the underlay via macvlan.
|
# All profiles get a root disk and cloud-init config.
|
||||||
cat >> "$YAML_PATH" <<EOF
|
cat >> "$YAML_PATH" <<EOF
|
||||||
description: Default LXD profile for ${FILENAME}
|
description: Default LXD profile for ${FILENAME}
|
||||||
devices:
|
devices:
|
||||||
@ -177,10 +197,8 @@ devices:
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Stub out the network piece for the base image.
|
# Stub out the network piece for the base image.
|
||||||
if [ "$LXD_HOSTNAME" = "$BASE_IMAGE_VM_NAME" ] ; then
|
if [ -z "$VIRTUAL_MACHINE" ]; then
|
||||||
|
cat >> "$YAML_PATH" <<EOF
|
||||||
#
|
|
||||||
cat >> "$YAML_PATH" <<EOF
|
|
||||||
enp6s0:
|
enp6s0:
|
||||||
name: enp6s0
|
name: enp6s0
|
||||||
network: lxdbr0
|
network: lxdbr0
|
||||||
@ -190,7 +208,7 @@ EOF
|
|||||||
|
|
||||||
else
|
else
|
||||||
# If we are deploying a VM that attaches to the network underlay.
|
# If we are deploying a VM that attaches to the network underlay.
|
||||||
cat >> "$YAML_PATH" <<EOF
|
cat >> "$YAML_PATH" <<EOF
|
||||||
enp5s0:
|
enp5s0:
|
||||||
nictype: macvlan
|
nictype: macvlan
|
||||||
parent: ${DATA_PLANE_MACVLAN_INTERFACE}
|
parent: ${DATA_PLANE_MACVLAN_INTERFACE}
|
||||||
|
@ -7,7 +7,7 @@ LXC_INSTANCE_NAME=
|
|||||||
# grab any modifications from the command line.
|
# grab any modifications from the command line.
|
||||||
for i in "$@"; do
|
for i in "$@"; do
|
||||||
case $i in
|
case $i in
|
||||||
--lxc-name=*)
|
--lxd-name=*)
|
||||||
LXC_INSTANCE_NAME="${i#*=}"
|
LXC_INSTANCE_NAME="${i#*=}"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
@ -21,7 +21,7 @@ for DOMAIN_NAME in ${DOMAIN_LIST//,/ }; do
|
|||||||
source ../../../../defaults.sh
|
source ../../../../defaults.sh
|
||||||
source "$SITE_PATH/site_definition"
|
source "$SITE_PATH/site_definition"
|
||||||
source ../../domain_env.sh
|
source ../../domain_env.sh
|
||||||
echo "after"
|
|
||||||
if [ $iteration = 0 ]; then
|
if [ $iteration = 0 ]; then
|
||||||
cat >>"$NGINX_CONF_PATH" <<EOL
|
cat >>"$NGINX_CONF_PATH" <<EOL
|
||||||
events {
|
events {
|
||||||
@ -250,7 +250,7 @@ EOL
|
|||||||
# Route everything to the real BTCPay server
|
# Route everything to the real BTCPay server
|
||||||
location / {
|
location / {
|
||||||
# URL of BTCPay Server
|
# URL of BTCPay Server
|
||||||
proxy_pass http://10.139.144.10:80;
|
proxy_pass http://$LXD_VM_NAME.lxd:80;
|
||||||
proxy_set_header Host \$http_host;
|
proxy_set_header Host \$http_host;
|
||||||
proxy_set_header X-Forwarded-Proto \$scheme;
|
proxy_set_header X-Forwarded-Proto \$scheme;
|
||||||
proxy_set_header X-Real-IP \$remote_addr;
|
proxy_set_header X-Real-IP \$remote_addr;
|
||||||
|
Loading…
Reference in New Issue
Block a user