Compare commits
No commits in common. "1c2511af21c76a19834a4c6711fadea591ba2563" and "1775f28cdbb12f12ec9da4b5ff47b0876ec85567" have entirely different histories.
1c2511af21
...
1775f28cdb
@ -74,11 +74,9 @@ export NOSTR_RELAY_IMAGE="scsibug/nostr-rs-relay"
|
|||||||
export WWW_SERVER_MAC_ADDRESS=
|
export WWW_SERVER_MAC_ADDRESS=
|
||||||
export BTCPAYSERVER_MAC_ADDRESS=
|
export BTCPAYSERVER_MAC_ADDRESS=
|
||||||
|
|
||||||
export SS_ROOT_PATH="$HOME/.ss"
|
export REMOTES_DIR="$HOME/ss-remotes"
|
||||||
|
export PROJECTS_DIR="$HOME/ss-projects"
|
||||||
export REMOTES_DIR="$SS_ROOT_PATH/remotes"
|
export SITES_PATH="$HOME/ss-sites"
|
||||||
export PROJECTS_DIR="$SS_ROOT_PATH/projects"
|
|
||||||
export SITES_PATH="$SS_ROOT_PATH/sites"
|
|
||||||
|
|
||||||
# The base VM image.
|
# The base VM image.
|
||||||
export LXD_UBUNTU_BASE_VERSION="jammy"
|
export LXD_UBUNTU_BASE_VERSION="jammy"
|
||||||
|
@ -5,10 +5,8 @@ You are in the Sovereign Stack Management Environment (SSME). From here, you can
|
|||||||
ss-deploy - Creates a deployment to your active LXD remote.
|
ss-deploy - Creates a deployment to your active LXD remote.
|
||||||
ss-destroy - Destroys the active deployment (WARNING: destructive).
|
ss-destroy - Destroys the active deployment (WARNING: destructive).
|
||||||
ss-update - brings an existing deployment up to the newest version of Sovereign Stack.
|
ss-update - brings an existing deployment up to the newest version of Sovereign Stack.
|
||||||
ss-reset - The opposite of ss-remote; deprovisions on the current remote.
|
|
||||||
ss-show - show the lxd resources associated with the current remote.
|
ss-show - show the lxd resources associated with the current remote.
|
||||||
|
|
||||||
For more infomation about all these topics, consult the Sovereign Stack website starting with:
|
For more infomation about all these topics, consult the Sovereign Stack website starting with:
|
||||||
|
|
||||||
- https://www.sovereign-stack.org/tag/instance-management/
|
- https://www.sovereign-stack.org/tag/instance-management/
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@ fi
|
|||||||
# install dependencies.
|
# install dependencies.
|
||||||
ssh -t "ubuntu@$FQDN" 'sudo apt update && sudo apt upgrade -y && sudo apt install htop dnsutils nano -y'
|
ssh -t "ubuntu@$FQDN" 'sudo apt update && sudo apt upgrade -y && sudo apt install htop dnsutils nano -y'
|
||||||
if ! ssh "ubuntu@$FQDN" snap list | grep -q lxd; then
|
if ! ssh "ubuntu@$FQDN" snap list | grep -q lxd; then
|
||||||
ssh -t "ubuntu@$FQDN" 'sudo snap install lxd'
|
ssh -t "ubuntu@$FQDN" 'sudo snap install lxd --channel=5.11/stable'
|
||||||
sleep 5
|
sleep 5
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
50
install.sh
50
install.sh
@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -exu
|
set -eu
|
||||||
cd "$(dirname "$0")"
|
cd "$(dirname "$0")"
|
||||||
|
|
||||||
# see https://www.sovereign-stack.org/management/
|
# see https://www.sovereign-stack.org/management/
|
||||||
@ -16,19 +16,19 @@ DISK="rpool/lxd"
|
|||||||
|
|
||||||
export DISK="$DISK"
|
export DISK="$DISK"
|
||||||
|
|
||||||
# let's check to ensure the management machine is on the Baseline ubuntu
|
# let's check to ensure the management machine is on the Baseline ubuntu 21.04
|
||||||
# TODO maybe remove this check; this theoretically should work on anything that support bash and lxd?
|
|
||||||
if ! lsb_release -d | grep -q "Ubuntu 22.04"; then
|
if ! lsb_release -d | grep -q "Ubuntu 22.04"; then
|
||||||
echo "ERROR: Your machine is not running the Ubuntu 22.04 LTS baseline OS on your management machine."
|
echo "ERROR: Your machine is not running the Ubuntu 22.04 LTS baseline OS on your management machine."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# install lxd snap and initialize it
|
# install snap
|
||||||
if ! snap list | grep -q lxd; then
|
if ! snap list | grep -q lxd; then
|
||||||
sudo snap install lxd
|
sudo snap install lxd --channel=5.11/stable
|
||||||
sleep 5
|
sleep 5
|
||||||
|
|
||||||
# run lxd init
|
# run lxd init on the remote server./dev/nvme1n1
|
||||||
|
#
|
||||||
cat <<EOF | lxd init --preseed
|
cat <<EOF | lxd init --preseed
|
||||||
config: {}
|
config: {}
|
||||||
networks:
|
networks:
|
||||||
@ -65,63 +65,53 @@ EOF
|
|||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SS_ROOT_PATH="$HOME/.ss"
|
# pull the vm image down if it's not there.
|
||||||
|
|
||||||
# pull the image down if it's not there.
|
|
||||||
if ! lxc image list | grep -q "$UBUNTU_BASE_IMAGE_NAME"; then
|
if ! lxc image list | grep -q "$UBUNTU_BASE_IMAGE_NAME"; then
|
||||||
lxc image copy "images:$BASE_LXC_IMAGE" local: --alias "$UBUNTU_BASE_IMAGE_NAME" --vm --auto-update
|
lxc image copy "images:$BASE_LXC_IMAGE" local: --alias "$UBUNTU_BASE_IMAGE_NAME" --vm --auto-update
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# if the ss-mgmt doesn't exist, create it.
|
|
||||||
if ! lxc list --format csv | grep -q ss-mgmt; then
|
if ! lxc list --format csv | grep -q ss-mgmt; then
|
||||||
lxc init "images:$BASE_LXC_IMAGE" ss-mgmt --vm -c limits.cpu=4 -c limits.memory=4GiB --profile=default
|
lxc init "images:$BASE_LXC_IMAGE" ss-mgmt --vm -c limits.cpu=4 -c limits.memory=4GiB --profile=default
|
||||||
|
|
||||||
# mount the pre-verified sovereign stack git repo into the new vm
|
# mount the pre-verified sovereign stack git repo into the new vm
|
||||||
lxc config device add ss-mgmt sscode disk source="$(pwd)" path=/home/ubuntu/sovereign-stack
|
lxc config device add ss-mgmt sscode disk source="$(pwd)" path=/home/ubuntu/sovereign-stack
|
||||||
|
|
||||||
# if the System Owner has a ~/.ss directory, then we'll mount it into the vm
|
|
||||||
# this allows the data to persist across ss-mgmt vms; ie. install/uninstall
|
|
||||||
if [ -d "$SS_ROOT_PATH" ]; then
|
|
||||||
lxc config device add ss-mgmt ssroot disk source="$SS_ROOT_PATH" path=/home/ubuntu/.ss
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# start the vm if it's not already running
|
|
||||||
if lxc list --format csv | grep -q "ss-mgmt,STOPPED"; then
|
if lxc list --format csv | grep -q "ss-mgmt,STOPPED"; then
|
||||||
lxc start ss-mgmt
|
lxc start ss-mgmt
|
||||||
sleep 10
|
sleep 20
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# wait for the vm to have an IP address
|
|
||||||
. ./management/wait_for_lxc_ip.sh
|
. ./management/wait_for_lxc_ip.sh
|
||||||
|
|
||||||
# wait for the VM to complete its default cloud-init.
|
|
||||||
while lxc exec ss-mgmt -- [ ! -f /var/lib/cloud/instance/boot-finished ]; do
|
# TODO wait for cloud-init to finish (but in the VM)
|
||||||
sleep 1
|
# while [ ! -f /var/lib/cloud/instance/boot-finished ]; do
|
||||||
done
|
# sleep 1
|
||||||
|
# done
|
||||||
|
|
||||||
SSH_PUBKEY_PATH="$HOME/.ssh/id_rsa.pub"
|
SSH_PUBKEY_PATH="$HOME/.ssh/id_rsa.pub"
|
||||||
if [ ! -f "$SSH_PUBKEY_PATH" ]; then
|
if [ ! -f "$SSH_PUBKEY_PATH" ]; then
|
||||||
ssh-keygen -f "$SSH_HOME/id_rsa" -t ecdsa -b 521 -N ""
|
ssh-keygen -f "$SSH_HOME/id_rsa" -t ecdsa -b 521 -N ""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# place the bare metal mgmt machine ssh pubkey on the remote host in the authorzed_keys section
|
# now run the mgmt provisioning script.
|
||||||
|
|
||||||
if [ -f "$SSH_PUBKEY_PATH" ]; then
|
if [ -f "$SSH_PUBKEY_PATH" ]; then
|
||||||
lxc file push "$SSH_PUBKEY_PATH" ss-mgmt/home/ubuntu/.ssh/authorized_keys
|
lxc file push "$SSH_PUBKEY_PATH" ss-mgmt/home/ubuntu/.ssh/authorized_keys
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# do some other preparations for user experience
|
|
||||||
lxc file push ./management/bash_profile ss-mgmt/home/ubuntu/.bash_profile
|
lxc file push ./management/bash_profile ss-mgmt/home/ubuntu/.bash_profile
|
||||||
lxc file push ./management/bashrc ss-mgmt/home/ubuntu/.bashrc
|
lxc file push ./management/bashrc ss-mgmt/home/ubuntu/.bashrc
|
||||||
lxc file push ./management/motd ss-mgmt/etc/update-motd.d/sovereign-stack
|
lxc file push ./management/motd ss-mgmt/etc/update-motd.d/sovereign-stack
|
||||||
|
|
||||||
# install SSH
|
|
||||||
lxc exec ss-mgmt apt-get update
|
lxc exec ss-mgmt apt-get update
|
||||||
lxc exec ss-mgmt -- apt-get install -y openssh-server
|
lxc exec ss-mgmt -- apt-get install -y openssh-server
|
||||||
lxc file push ./management/sshd_config ss-mgmt/etc/ssh/sshd_config
|
lxc file push ./management/sshd_config ss-mgmt/etc/ssh/sshd_config
|
||||||
lxc exec ss-mgmt -- sudo systemctl restart sshd
|
lxc exec ss-mgmt -- sudo systemctl restart sshd
|
||||||
|
|
||||||
# add 'ss-manage' to the bare metal ~/.bashrc
|
# make the Sovereign Stack commands available to the user via ~/.bashrc
|
||||||
|
# we use ~/.bashrc
|
||||||
ADDED_COMMAND=false
|
ADDED_COMMAND=false
|
||||||
if ! < "$HOME/.bashrc" grep -q "ss-manage"; then
|
if ! < "$HOME/.bashrc" grep -q "ss-manage"; then
|
||||||
echo "alias ss-manage='$(pwd)/manage.sh \$@'" >> "$HOME/.bashrc"
|
echo "alias ss-manage='$(pwd)/manage.sh \$@'" >> "$HOME/.bashrc"
|
||||||
@ -141,13 +131,13 @@ ssh "ubuntu@$IP_V4_ADDRESS" sudo chown -R ubuntu:ubuntu /home/ubuntu
|
|||||||
|
|
||||||
ssh "ubuntu@$IP_V4_ADDRESS" /home/ubuntu/sovereign-stack/management/provision.sh
|
ssh "ubuntu@$IP_V4_ADDRESS" /home/ubuntu/sovereign-stack/management/provision.sh
|
||||||
|
|
||||||
#lxc restart ss-mgmt
|
lxc restart ss-mgmt
|
||||||
|
|
||||||
if [ "$ADDED_COMMAND" = true ]; then
|
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."
|
echo "NOTICE! You need to run 'source ~/.bashrc' before continuing. After that, type 'ss-manage' to enter your management environment."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
. ./defaults.sh
|
|
||||||
# As part of the install script, we pull down any other sovereign-stack git repos
|
# As part of the install script, we pull down any other sovereign-stack git repos
|
||||||
PROJECTS_SCRIPTS_REPO_URL="https://git.sovereign-stack.org/ss/project"
|
PROJECTS_SCRIPTS_REPO_URL="https://git.sovereign-stack.org/ss/project"
|
||||||
PROJECTS_SCRIPTS_PATH="$(pwd)/deployment/project"
|
PROJECTS_SCRIPTS_PATH="$(pwd)/deployment/project"
|
||||||
@ -156,7 +146,5 @@ if [ ! -d "$PROJECTS_SCRIPTS_PATH" ]; then
|
|||||||
else
|
else
|
||||||
cd "$PROJECTS_SCRIPTS_PATH"
|
cd "$PROJECTS_SCRIPTS_PATH"
|
||||||
git pull origin main
|
git pull origin main
|
||||||
git checkout "$TARGET_PROJECT_GIT_COMMIT"
|
|
||||||
cd -
|
cd -
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -5,9 +5,9 @@ cd "$(dirname "$0")"
|
|||||||
|
|
||||||
# NOTE! This script MUST be executed as root.
|
# NOTE! This script MUST be executed as root.
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y ca-certificates curl gnupg lsb-release
|
sudo apt-get install -y gnupg ca-certificates curl lsb-release
|
||||||
|
|
||||||
sudo mkdir -m 0755 -p /etc/apt/keyrings
|
mkdir -p /etc/apt/keyrings
|
||||||
|
|
||||||
# add the docker gpg key to keyring for docker-ce-cli
|
# add the docker gpg key to keyring for docker-ce-cli
|
||||||
if [ ! -f /etc/apt/keyrings/docker.gpg ]; then
|
if [ ! -f /etc/apt/keyrings/docker.gpg ]; then
|
||||||
@ -17,24 +17,24 @@ fi
|
|||||||
|
|
||||||
# TODO REVIEW mgmt software requirements
|
# TODO REVIEW mgmt software requirements
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y wait-for-it dnsutils rsync sshfs apt-transport-https docker-ce-cli libcanberra-gtk-module snapd nano git
|
sudo apt-get install -y wait-for-it dnsutils rsync sshfs apt-transport-https docker-ce-cli \
|
||||||
|
libcanberra-gtk-module snapd nano git
|
||||||
|
|
||||||
|
sleep 1
|
||||||
|
|
||||||
sleep 10
|
#apt install python3-pip python3-dev libusb-1.0-0-dev libudev-dev pinentry-curses for trezor stuff
|
||||||
|
# for trezor installation
|
||||||
|
#pip3 install setuptools wheel
|
||||||
|
#pip3 install trezor_agent
|
||||||
|
|
||||||
# #apt install python3-pip python3-dev libusb-1.0-0-dev libudev-dev pinentry-curses for trezor stuff
|
# ensure the trezor-t udev rules are in place.
|
||||||
# # for trezor installation
|
# if [ ! -f /etc/udev/rules.d/51-trezor.rules ]; then
|
||||||
# #pip3 install setuptools wheel
|
# sudo cp ./51-trezor.rules /etc/udev/rules.d/51-trezor.rules
|
||||||
# #pip3 install trezor_agent
|
# fi
|
||||||
|
|
||||||
# # ensure the trezor-t udev rules are in place.
|
|
||||||
# # if [ ! -f /etc/udev/rules.d/51-trezor.rules ]; then
|
|
||||||
# # sudo cp ./51-trezor.rules /etc/udev/rules.d/51-trezor.rules
|
|
||||||
# # fi
|
|
||||||
|
|
||||||
# install snap
|
# install snap
|
||||||
if ! snap list | grep -q lxd; then
|
if ! snap list | grep -q lxd; then
|
||||||
sudo snap install lxd
|
sudo snap install lxd --channel=5.11/stable
|
||||||
sleep 6
|
sleep 6
|
||||||
|
|
||||||
# We just do an auto initialization. All we are using is the LXD client inside the management environment.
|
# We just do an auto initialization. All we are using is the LXD client inside the management environment.
|
||||||
|
86
uninstall.sh
86
uninstall.sh
@ -1,22 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -exu
|
set -eu
|
||||||
|
|
||||||
PURGE_LXD=false
|
|
||||||
|
|
||||||
# grab any modifications from the command line.
|
|
||||||
for i in "$@"; do
|
|
||||||
case $i in
|
|
||||||
--purge)
|
|
||||||
PURGE_LXD=true
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Unexpected option: $1"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
# this script undoes install.sh
|
# this script undoes install.sh
|
||||||
if ! command -v lxc >/dev/null 2>&1; then
|
if ! command -v lxc >/dev/null 2>&1; then
|
||||||
@ -26,45 +10,45 @@ fi
|
|||||||
|
|
||||||
. ./defaults.sh
|
. ./defaults.sh
|
||||||
|
|
||||||
if lxc list --format csv | grep -q "ss-mgmt"; then
|
if lxc list --format csv | grep -q ss-mgmt; then
|
||||||
|
|
||||||
if lxc list --format csv -q | grep -q "ss-mgmt,RUNNING"; then
|
if ! lxc list --format csv | grep ss-mgmt | grep -q "RUNNING"; then
|
||||||
lxc stop ss-mgmt
|
lxc stop ss-mgmt
|
||||||
fi
|
fi
|
||||||
|
|
||||||
lxc config device remove ss-mgmt sscode
|
lxc config device remove ss-mgmt sscode
|
||||||
|
lxc delete ss-mgmt -f
|
||||||
SS_ROOT_PATH="$HOME/.ss"
|
|
||||||
if [ -d "$SS_ROOT_PATH" ]; then
|
|
||||||
lxc config device remove ss-mgmt ssroot
|
|
||||||
fi
|
|
||||||
|
|
||||||
lxc delete ss-mgmt
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$PURGE_LXD" = true ]; then
|
if lxc profile device list default | grep -q root; then
|
||||||
|
lxc profile device remove default root
|
||||||
if lxc profile device list default | grep -q root; then
|
fi
|
||||||
lxc profile device remove default root
|
|
||||||
fi
|
if lxc profile device list default | grep -q enp5s0; then
|
||||||
|
lxc profile device remove default enp5s0
|
||||||
if lxc profile device list default | grep -q enp5s0; then
|
fi
|
||||||
lxc profile device remove default enp5s0
|
|
||||||
fi
|
if lxc network list | grep -q lxdbr0; then
|
||||||
|
lxc network delete lxdbr0
|
||||||
if lxc network list | grep -q lxdbr0; then
|
fi
|
||||||
lxc network delete lxdbr0
|
|
||||||
fi
|
if lxc image list | grep -q "$UBUNTU_BASE_IMAGE_NAME"; then
|
||||||
|
lxc image delete "$UBUNTU_BASE_IMAGE_NAME"
|
||||||
if lxc image list | grep -q "$UBUNTU_BASE_IMAGE_NAME"; then
|
fi
|
||||||
lxc image delete "$UBUNTU_BASE_IMAGE_NAME"
|
|
||||||
fi
|
if lxc storage list --format csv | grep -q sovereign-stack; then
|
||||||
|
lxc storage delete sovereign-stack
|
||||||
if lxc storage list --format csv | grep -q sovereign-stack; then
|
fi
|
||||||
lxc storage delete sovereign-stack
|
|
||||||
fi
|
if snap list | grep -q lxd; then
|
||||||
|
sudo snap remove lxd
|
||||||
if snap list | grep -q lxd; then
|
sleep 2
|
||||||
sudo snap remove lxd
|
fi
|
||||||
fi
|
|
||||||
|
if zfs list | grep -q sovereign-stack; then
|
||||||
|
sudo zfs destroy -r sovereign-stack
|
||||||
|
fi
|
||||||
|
|
||||||
|
if zfs list | grep -q "sovereign-stack"; then
|
||||||
|
sudo zfs destroy -r "rpool/lxd"
|
||||||
fi
|
fi
|
Loading…
Reference in New Issue
Block a user