#!/bin/bash set -eu cd "$(dirname "$0")" # 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. if [ "$(hostname)" = ss-mgmt ]; then echo "ERROR: This command is meant to be executed from the bare metal management machine -- not the SSME." exit 1 fi # the DISK variable here tells us which disk (partition) the admin wants to use for # lxd resources. By default, we provision the disk under / as a loop device. Admin # can override with CLI modifications. DISK="rpool/lxd" export DISK="$DISK" # install lxd snap and initialize it if ! snap list | grep -q lxd; then sudo snap install lxd --channel=latest/candidate sleep 5 # run lxd init cat <> "$HOME/.bashrc" ADDED_COMMAND=true fi wait-for-it -t 300 "$IP_V4_ADDRESS:22" > /dev/null 2>&1 # Let's remove any entry in our known_hosts, then add it back. # we are using IP address here so we don't have to rely on external DNS # configuration for the base image preparataion. ssh-keygen -R "$IP_V4_ADDRESS" ssh-keyscan -H -t ecdsa "$IP_V4_ADDRESS" >> "$SSH_HOME/known_hosts" ssh "ubuntu@$IP_V4_ADDRESS" sudo chown -R ubuntu:ubuntu /home/ubuntu 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 echo "NOTICE! You need to run 'source ~/.bashrc' before continuing. After that, type 'ss-manage' to enter your management environment." fi