Add controls over base image creation.
This commit is contained in:
parent
7e76d5ca43
commit
a44832c9ba
@ -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
|
|
||||||
|
|
||||||
# TODO move this sovereign-stack-base construction VM to separate dedicated IP
|
if ! lxc list --project default | grep -q "$BASE_IMAGE_VM_NAME"; then
|
||||||
lxc config set "$BASE_IMAGE_VM_NAME" --project=default
|
# 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
|
||||||
|
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,40 +45,41 @@ 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
|
|
||||||
|
|
||||||
# ensure the ssh service is listening at localhost
|
# ensure the ssh service is listening at localhost
|
||||||
lxc exec "$BASE_IMAGE_VM_NAME" --project=default -- wait-for-it -t 100 127.0.0.1:22
|
lxc exec "$BASE_IMAGE_VM_NAME" --project=default -- wait-for-it -t 100 127.0.0.1:22
|
||||||
|
|
||||||
# # If we have any chaninstate or blocks in our SSME, let's push them to the
|
# # If we have any chaninstate or blocks in our SSME, let's push them to the
|
||||||
# # remote host as a zfs volume that way deployments can share a common history
|
# # remote host as a zfs volume that way deployments can share a common history
|
||||||
# # of chainstate/blocks.
|
# # of chainstate/blocks.
|
||||||
# for CHAIN in testnet mainnet; do
|
# for CHAIN in testnet mainnet; do
|
||||||
# for DATA in blocks chainstate; do
|
# for DATA in blocks chainstate; do
|
||||||
# # if the storage snapshot doesn't yet exist, create it.
|
# # if the storage snapshot doesn't yet exist, create it.
|
||||||
# if ! lxc storage volume list ss-base -q --format csv -c n | grep -q "$CHAIN-$DATA/snap0"; then
|
# if ! lxc storage volume list ss-base -q --format csv -c n | grep -q "$CHAIN-$DATA/snap0"; then
|
||||||
# DATA_PATH="/home/ubuntu/.ss/cache/bitcoin/$CHAIN/$DATA"
|
# DATA_PATH="/home/ubuntu/.ss/cache/bitcoin/$CHAIN/$DATA"
|
||||||
# if [ -d "$DATA_PATH" ]; then
|
# if [ -d "$DATA_PATH" ]; then
|
||||||
# COMPLETE_FILE_PATH="$DATA_PATH/complete"
|
# COMPLETE_FILE_PATH="$DATA_PATH/complete"
|
||||||
# if lxc exec "$BASE_IMAGE_VM_NAME" -- [ ! -f "$COMPLETE_FILE_PATH" ]; then
|
# if lxc exec "$BASE_IMAGE_VM_NAME" -- [ ! -f "$COMPLETE_FILE_PATH" ]; then
|
||||||
# lxc file push --recursive --project=default "$DATA_PATH/" "$BASE_IMAGE_VM_NAME""$DATA_PATH/"
|
# lxc file push --recursive --project=default "$DATA_PATH/" "$BASE_IMAGE_VM_NAME""$DATA_PATH/"
|
||||||
# lxc exec "$BASE_IMAGE_VM_NAME" -- su ubuntu - bash -c "echo $(date) > $COMPLETE_FILE_PATH"
|
# lxc exec "$BASE_IMAGE_VM_NAME" -- su ubuntu - bash -c "echo $(date) > $COMPLETE_FILE_PATH"
|
||||||
# lxc exec "$BASE_IMAGE_VM_NAME" -- chown -R 999:999 "$DATA_PATH/$DATA"
|
# lxc exec "$BASE_IMAGE_VM_NAME" -- chown -R 999:999 "$DATA_PATH/$DATA"
|
||||||
# else
|
# else
|
||||||
# echo "INFO: it appears as though $CHAIN/$DATA has already been initialized. Continuing."
|
# echo "INFO: it appears as though $CHAIN/$DATA has already been initialized. Continuing."
|
||||||
# fi
|
# fi
|
||||||
# fi
|
# fi
|
||||||
# fi
|
# fi
|
||||||
# done
|
# done
|
||||||
# done
|
# done
|
||||||
|
|
||||||
# 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
|
||||||
|
@ -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
|
Loading…
Reference in New Issue
Block a user