1
1
sovereign-stack/manage.sh

40 lines
1.2 KiB
Bash
Raw Normal View History

2023-02-01 19:44:05 +00:00
#!/bin/bash
2023-04-04 15:33:50 +00:00
# https://www.sovereign-stack.org/ss-manage/
2023-08-12 16:25:23 +00:00
set -eu
2023-02-01 19:44:05 +00:00
cd "$(dirname "$0")"
2023-04-04 15:33:50 +00:00
# check to ensure dependencies are met.
2023-09-22 23:46:07 +00:00
if ! command -v incus >/dev/null 2>&1; then
echo "This script requires incus to be installed. Please run 'install.sh'."
2023-04-04 15:33:50 +00:00
exit 1
fi
2023-09-22 23:46:07 +00:00
if ! incus remote get-default | grep -q "local"; then
incus remote switch "local"
2023-02-01 19:44:05 +00:00
fi
2023-09-22 23:46:07 +00:00
if ! incus list -q --format csv | grep -q ss-mgmt; then
2023-03-19 20:42:48 +00:00
echo "ERROR: the 'ss-mgmt' VM does not exist. You may need to run install.sh"
exit 1
fi
2023-02-01 19:44:05 +00:00
# if the mgmt machine doesn't exist, then warn the user to perform ./install.sh
2023-09-22 23:46:07 +00:00
if ! incus list --format csv | grep -q "ss-mgmt"; then
2023-02-01 19:44:05 +00:00
echo "ERROR: the management machine VM does not exist. You probably need to run './install.sh'."
echo "INFO: check out https://www.sovereign-stack.org/tag/code-lifecycle-management/ for more information."
fi
# if the machine does exist, let's make sure it's RUNNING.
2023-09-22 23:46:07 +00:00
if incus list --format csv | grep -q "ss-mgmt,STOPPED"; then
2023-04-14 17:17:42 +00:00
echo "INFO: The SSME was in a STOPPED state. Starting the environment. Please wait."
2023-09-22 23:46:07 +00:00
incus start ss-mgmt
2023-02-01 19:44:05 +00:00
sleep 30
fi
2023-09-22 23:46:07 +00:00
. ./management/wait_for_ip.sh
2023-02-01 19:44:05 +00:00
2023-03-02 14:46:17 +00:00
# let's ensure ~/.ssh/ssh_config is using the correct IP address for ss-mgmt.
2023-02-01 19:44:05 +00:00
ssh ubuntu@"$IP_V4_ADDRESS"