1
1

Add controls over base image creation.

This commit is contained in:
Derek Smith 2023-09-15 19:28:48 -04:00
parent 7e76d5ca43
commit a44832c9ba
Signed by: farscapian
GPG Key ID: B443E530A14E1C90
3 changed files with 45 additions and 36 deletions

View File

@ -25,11 +25,19 @@ if lxc list --format csv -q | grep -q "$UBUNTU_BASE_IMAGE_NAME"; then
ssh-keygen -f "$SSH_HOME/known_hosts" -R "$BASE_IMAGE_VM_NAME" ssh-keygen -f "$SSH_HOME/known_hosts" -R "$BASE_IMAGE_VM_NAME"
fi fi
else else
# the base image is ubuntu:22.04.
lxc init --profile="$BASE_IMAGE_VM_NAME" "$UBUNTU_BASE_IMAGE_NAME" "$BASE_IMAGE_VM_NAME" --vm --project=default
if ! lxc list --project default | grep -q "$BASE_IMAGE_VM_NAME"; then
# the base image is ubuntu:22.04.
lxc init -q --profile="$BASE_IMAGE_VM_NAME" "$UBUNTU_BASE_IMAGE_NAME" "$BASE_IMAGE_VM_NAME" --vm --project=default
fi
if lxc info "$BASE_IMAGE_VM_NAME" | grep -q "Status: STOPPED"; then
# TODO move this sovereign-stack-base construction VM to separate dedicated IP # TODO move this sovereign-stack-base construction VM to separate dedicated IP
lxc config set "$BASE_IMAGE_VM_NAME" --project=default lxc config set "$BASE_IMAGE_VM_NAME" --project=default
lxc start "$BASE_IMAGE_VM_NAME" --project=default
sleep 15
fi
# for CHAIN in mainnet testnet; do # for CHAIN in mainnet testnet; do
# for DATA in blocks chainstate; do # for DATA in blocks chainstate; do
@ -37,9 +45,8 @@ else
# done # done
# done # done
lxc start "$BASE_IMAGE_VM_NAME" --project=default if lxc info "$BASE_IMAGE_VM_NAME" | grep -q "Status: RUNNING"; then
sleep 15
while lxc exec "$BASE_IMAGE_VM_NAME" --project=default -- [ ! -f /var/lib/cloud/instance/boot-finished ]; do while lxc exec "$BASE_IMAGE_VM_NAME" --project=default -- [ ! -f /var/lib/cloud/instance/boot-finished ]; do
sleep 1 sleep 1
done done
@ -71,6 +78,8 @@ else
# stop the VM and get a snapshot. # stop the VM and get a snapshot.
lxc stop "$BASE_IMAGE_VM_NAME" --project=default lxc stop "$BASE_IMAGE_VM_NAME" --project=default
fi
lxc snapshot "$BASE_IMAGE_VM_NAME" "$UBUNTU_BASE_IMAGE_NAME" --project=default lxc snapshot "$BASE_IMAGE_VM_NAME" "$UBUNTU_BASE_IMAGE_NAME" --project=default
fi fi

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
set -eu set -exu
cd "$(dirname "$0")" cd "$(dirname "$0")"
. ./base.sh . ./base.sh

@ -1 +1 @@
Subproject commit 13df5bf172846f9a5c9c799695cef7b5fa299a91 Subproject commit a8a6f7d289665cc20756ddf0e1ee1ead70668bd0