Compare commits
4 Commits
golang
...
fd1ba7fbe0
Author | SHA1 | Date | |
---|---|---|---|
![]() |
fd1ba7fbe0 | ||
![]() |
5edf14695f | ||
![]() |
9a7b2fec72 | ||
![]() |
3a9bd7c6b3 |
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
Welcome! So excited you're here!
|
Welcome! So excited you're here!
|
||||||
|
|
||||||
_This project is massively in progress. It's not ready to be used yet (even though I am using it as I develop it). This is published publicly for transparency. If you want to help out, please get in touch._
|
_This project is massively in progress. It's not ready to be used yet (even though I am using it as I develop it). This is published publicly for transparency. If you want to help out, please [get in touch](https://forum.civilsociety.dev/c/wild-cloud/5)._
|
||||||
|
|
||||||
## Why Build Your Own Cloud?
|
## Why Build Your Own Cloud?
|
||||||
|
|
||||||
|
@@ -21,4 +21,13 @@ spec:
|
|||||||
env:
|
env:
|
||||||
- name: TZ
|
- name: TZ
|
||||||
value: "{{ .apps.redis.timezone }}"
|
value: "{{ .apps.redis.timezone }}"
|
||||||
|
- name: REDIS_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: redis-secrets
|
||||||
|
key: apps.redis.password
|
||||||
|
command:
|
||||||
|
- redis-server
|
||||||
|
- --requirepass
|
||||||
|
- $(REDIS_PASSWORD)
|
||||||
restartPolicy: Always
|
restartPolicy: Always
|
||||||
|
@@ -124,14 +124,14 @@ fi
|
|||||||
# Discover available disks
|
# Discover available disks
|
||||||
echo "Discovering available disks..." >&2
|
echo "Discovering available disks..." >&2
|
||||||
if [ "$TALOS_MODE" = "insecure" ]; then
|
if [ "$TALOS_MODE" = "insecure" ]; then
|
||||||
AVAILABLE_DISKS_RAW=$(talosctl -n "$NODE_IP" get disks --insecure -o json 2>/dev/null | \
|
DISKS_JSON=$(talosctl -n "$NODE_IP" get disks --insecure -o json 2>/dev/null | \
|
||||||
jq -s -r '.[] | select(.spec.size > 10000000000) | .metadata.id')
|
jq -s '[.[] | select(.spec.size > 10000000000) | {path: ("/dev/" + .metadata.id), size: .spec.size}]')
|
||||||
else
|
else
|
||||||
AVAILABLE_DISKS_RAW=$(talosctl -n "$NODE_IP" get disks -o json 2>/dev/null | \
|
DISKS_JSON=$(talosctl -n "$NODE_IP" get disks -o json 2>/dev/null | \
|
||||||
jq -s -r '.[] | select(.spec.size > 10000000000) | .metadata.id')
|
jq -s '[.[] | select(.spec.size > 10000000000) | {path: ("/dev/" + .metadata.id), size: .spec.size}]')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$AVAILABLE_DISKS_RAW" ]; then
|
if [ "$(echo "$DISKS_JSON" | jq 'length')" -eq 0 ]; then
|
||||||
echo "Error: No suitable disks found (must be >10GB)" >&2
|
echo "Error: No suitable disks found (must be >10GB)" >&2
|
||||||
echo "Available disks:" >&2
|
echo "Available disks:" >&2
|
||||||
if [ "$TALOS_MODE" = "insecure" ]; then
|
if [ "$TALOS_MODE" = "insecure" ]; then
|
||||||
@@ -142,11 +142,11 @@ if [ -z "$AVAILABLE_DISKS_RAW" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Convert to JSON array
|
# Use the disks with size info directly
|
||||||
AVAILABLE_DISKS=$(echo "$AVAILABLE_DISKS_RAW" | jq -R -s 'split("\n") | map(select(length > 0)) | map("/dev/" + .)')
|
AVAILABLE_DISKS="$DISKS_JSON"
|
||||||
|
|
||||||
# Select the first disk as default (largest first)
|
# Select the first disk as default
|
||||||
SELECTED_DISK=$(echo "$AVAILABLE_DISKS" | jq -r '.[0]')
|
SELECTED_DISK=$(echo "$AVAILABLE_DISKS" | jq -r '.[0].path')
|
||||||
|
|
||||||
echo "✅ Discovered $(echo "$AVAILABLE_DISKS" | jq -r 'length') suitable disks" >&2
|
echo "✅ Discovered $(echo "$AVAILABLE_DISKS" | jq -r 'length') suitable disks" >&2
|
||||||
echo "✅ Selected disk: $SELECTED_DISK" >&2
|
echo "✅ Selected disk: $SELECTED_DISK" >&2
|
||||||
|
@@ -260,7 +260,7 @@ if [ "${SKIP_HARDWARE}" = false ]; then
|
|||||||
# Parse JSON response
|
# Parse JSON response
|
||||||
INTERFACE=$(echo "$NODE_INFO" | jq -r '.interface')
|
INTERFACE=$(echo "$NODE_INFO" | jq -r '.interface')
|
||||||
SELECTED_DISK=$(echo "$NODE_INFO" | jq -r '.selected_disk')
|
SELECTED_DISK=$(echo "$NODE_INFO" | jq -r '.selected_disk')
|
||||||
AVAILABLE_DISKS=$(echo "$NODE_INFO" | jq -r '.disks | join(", ")')
|
AVAILABLE_DISKS=$(echo "$NODE_INFO" | jq -r '.disks[] | "\(.path) (\((.size / 1000000000) | floor)GB)"' | paste -sd, -)
|
||||||
|
|
||||||
print_success "Hardware detected:"
|
print_success "Hardware detected:"
|
||||||
print_info " - Interface: $INTERFACE"
|
print_info " - Interface: $INTERFACE"
|
||||||
@@ -272,9 +272,9 @@ if [ "${SKIP_HARDWARE}" = false ]; then
|
|||||||
read -p "Use selected disk '$SELECTED_DISK'? (Y/n): " -r use_disk
|
read -p "Use selected disk '$SELECTED_DISK'? (Y/n): " -r use_disk
|
||||||
if [[ $use_disk =~ ^[Nn]$ ]]; then
|
if [[ $use_disk =~ ^[Nn]$ ]]; then
|
||||||
echo "Available disks:"
|
echo "Available disks:"
|
||||||
echo "$NODE_INFO" | jq -r '.disks[]' | nl -w2 -s') '
|
echo "$NODE_INFO" | jq -r '.disks[] | "\(.path) (\((.size / 1000000000) | floor)GB)"' | nl -w2 -s') '
|
||||||
read -p "Enter disk number: " -r disk_num
|
read -p "Enter disk number: " -r disk_num
|
||||||
SELECTED_DISK=$(echo "$NODE_INFO" | jq -r ".disks[$((disk_num-1))]")
|
SELECTED_DISK=$(echo "$NODE_INFO" | jq -r ".disks[$((disk_num-1))].path")
|
||||||
if [ "$SELECTED_DISK" = "null" ] || [ -z "$SELECTED_DISK" ]; then
|
if [ "$SELECTED_DISK" = "null" ] || [ -z "$SELECTED_DISK" ]; then
|
||||||
print_error "Invalid disk selection"
|
print_error "Invalid disk selection"
|
||||||
continue
|
continue
|
||||||
@@ -359,6 +359,11 @@ if [ "${SKIP_HARDWARE}" = false ]; then
|
|||||||
read -p "Do you want to register a worker node? (y/N): " -r register_worker
|
read -p "Do you want to register a worker node? (y/N): " -r register_worker
|
||||||
|
|
||||||
if [[ $register_worker =~ ^[Yy]$ ]]; then
|
if [[ $register_worker =~ ^[Yy]$ ]]; then
|
||||||
|
# Find first available worker number
|
||||||
|
while [ -n "$(wild-config "cluster.nodes.active.\"${HOSTNAME_PREFIX}worker-${WORKER_COUNT}\".role" 2>/dev/null)" ] && [ "$(wild-config "cluster.nodes.active.\"${HOSTNAME_PREFIX}worker-${WORKER_COUNT}\".role" 2>/dev/null)" != "null" ]; do
|
||||||
|
WORKER_COUNT=$((WORKER_COUNT + 1))
|
||||||
|
done
|
||||||
|
|
||||||
NODE_NAME="${HOSTNAME_PREFIX}worker-${WORKER_COUNT}"
|
NODE_NAME="${HOSTNAME_PREFIX}worker-${WORKER_COUNT}"
|
||||||
read -p "Enter current IP for worker node $NODE_NAME: " -r WORKER_IP
|
read -p "Enter current IP for worker node $NODE_NAME: " -r WORKER_IP
|
||||||
|
|
||||||
@@ -388,7 +393,7 @@ if [ "${SKIP_HARDWARE}" = false ]; then
|
|||||||
# Parse JSON response
|
# Parse JSON response
|
||||||
INTERFACE=$(echo "$WORKER_INFO" | jq -r '.interface')
|
INTERFACE=$(echo "$WORKER_INFO" | jq -r '.interface')
|
||||||
SELECTED_DISK=$(echo "$WORKER_INFO" | jq -r '.selected_disk')
|
SELECTED_DISK=$(echo "$WORKER_INFO" | jq -r '.selected_disk')
|
||||||
AVAILABLE_DISKS=$(echo "$WORKER_INFO" | jq -r '.disks | join(", ")')
|
AVAILABLE_DISKS=$(echo "$WORKER_INFO" | jq -r '.disks[] | "\(.path) (\((.size / 1000000000) | floor)GB)"' | paste -sd, -)
|
||||||
|
|
||||||
print_success "Hardware detected for worker node $NODE_NAME:"
|
print_success "Hardware detected for worker node $NODE_NAME:"
|
||||||
print_info " - Interface: $INTERFACE"
|
print_info " - Interface: $INTERFACE"
|
||||||
@@ -400,9 +405,9 @@ if [ "${SKIP_HARDWARE}" = false ]; then
|
|||||||
read -p "Use selected disk '$SELECTED_DISK'? (Y/n): " -r use_disk
|
read -p "Use selected disk '$SELECTED_DISK'? (Y/n): " -r use_disk
|
||||||
if [[ $use_disk =~ ^[Nn]$ ]]; then
|
if [[ $use_disk =~ ^[Nn]$ ]]; then
|
||||||
echo "Available disks:"
|
echo "Available disks:"
|
||||||
echo "$WORKER_INFO" | jq -r '.disks[]' | nl -w2 -s') '
|
echo "$WORKER_INFO" | jq -r '.disks[] | "\(.path) (\((.size / 1000000000) | floor)GB)"' | nl -w2 -s') '
|
||||||
read -p "Enter disk number: " -r disk_num
|
read -p "Enter disk number: " -r disk_num
|
||||||
SELECTED_DISK=$(echo "$WORKER_INFO" | jq -r ".disks[$((disk_num-1))]")
|
SELECTED_DISK=$(echo "$WORKER_INFO" | jq -r ".disks[$((disk_num-1))].path")
|
||||||
if [ "$SELECTED_DISK" = "null" ] || [ -z "$SELECTED_DISK" ]; then
|
if [ "$SELECTED_DISK" = "null" ] || [ -z "$SELECTED_DISK" ]; then
|
||||||
print_error "Invalid disk selection"
|
print_error "Invalid disk selection"
|
||||||
continue
|
continue
|
||||||
|
@@ -10,16 +10,16 @@
|
|||||||
# #!/bin/bash
|
# #!/bin/bash
|
||||||
# set -e
|
# set -e
|
||||||
# set -o pipefail
|
# set -o pipefail
|
||||||
#
|
#
|
||||||
# # Source common utilities
|
# # Source common utilities
|
||||||
# source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/wild-common.sh"
|
# source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/wild-common.sh"
|
||||||
#
|
#
|
||||||
# # Initialize Wild Cloud environment
|
# # Initialize Wild Cloud environment
|
||||||
# init_wild_env
|
# init_wild_env
|
||||||
#
|
#
|
||||||
# AVAILABLE FUNCTIONS:
|
# AVAILABLE FUNCTIONS:
|
||||||
# - Print functions: print_header, print_info, print_warning, print_success, print_error
|
# - Print functions: print_header, print_info, print_warning, print_success, print_error
|
||||||
# - Config functions: prompt_with_default
|
# - Config functions: prompt_with_default
|
||||||
# - Config helpers: prompt_if_unset_config, prompt_if_unset_secret
|
# - Config helpers: prompt_if_unset_config, prompt_if_unset_secret
|
||||||
# - Validation: check_wild_directory
|
# - Validation: check_wild_directory
|
||||||
# - Utilities: command_exists, file_readable, dir_writable, generate_random_string
|
# - Utilities: command_exists, file_readable, dir_writable, generate_random_string
|
||||||
@@ -72,7 +72,7 @@ prompt_with_default() {
|
|||||||
local default="$2"
|
local default="$2"
|
||||||
local current_value="$3"
|
local current_value="$3"
|
||||||
local result
|
local result
|
||||||
|
|
||||||
if [ -n "${current_value}" ] && [ "${current_value}" != "null" ]; then
|
if [ -n "${current_value}" ] && [ "${current_value}" != "null" ]; then
|
||||||
printf "%s [current: %s]: " "${prompt}" "${current_value}" >&2
|
printf "%s [current: %s]: " "${prompt}" "${current_value}" >&2
|
||||||
read -r result
|
read -r result
|
||||||
@@ -99,7 +99,7 @@ prompt_with_default() {
|
|||||||
read -r result
|
read -r result
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "${result}"
|
echo "${result}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,10 +108,10 @@ prompt_if_unset_config() {
|
|||||||
local config_path="$1"
|
local config_path="$1"
|
||||||
local prompt="$2"
|
local prompt="$2"
|
||||||
local default="$3"
|
local default="$3"
|
||||||
|
|
||||||
local current_value
|
local current_value
|
||||||
current_value=$(wild-config "${config_path}")
|
current_value=$(wild-config "${config_path}")
|
||||||
|
|
||||||
if [ -z "${current_value}" ] || [ "${current_value}" = "null" ]; then
|
if [ -z "${current_value}" ] || [ "${current_value}" = "null" ]; then
|
||||||
local new_value
|
local new_value
|
||||||
new_value=$(prompt_with_default "${prompt}" "${default}" "")
|
new_value=$(prompt_with_default "${prompt}" "${default}" "")
|
||||||
@@ -127,10 +127,10 @@ prompt_if_unset_secret() {
|
|||||||
local secret_path="$1"
|
local secret_path="$1"
|
||||||
local prompt="$2"
|
local prompt="$2"
|
||||||
local default="$3"
|
local default="$3"
|
||||||
|
|
||||||
local current_value
|
local current_value
|
||||||
current_value=$(wild-secret "${secret_path}")
|
current_value=$(wild-secret "${secret_path}")
|
||||||
|
|
||||||
if [ -z "${current_value}" ] || [ "${current_value}" = "null" ]; then
|
if [ -z "${current_value}" ] || [ "${current_value}" = "null" ]; then
|
||||||
local new_value
|
local new_value
|
||||||
new_value=$(prompt_with_default "${prompt}" "${default}" "")
|
new_value=$(prompt_with_default "${prompt}" "${default}" "")
|
||||||
@@ -149,7 +149,7 @@ prompt_if_unset_secret() {
|
|||||||
# Returns the path to the project root, or empty string if not found
|
# Returns the path to the project root, or empty string if not found
|
||||||
find_wc_home() {
|
find_wc_home() {
|
||||||
local current_dir="$(pwd)"
|
local current_dir="$(pwd)"
|
||||||
|
|
||||||
while [ "$current_dir" != "/" ]; do
|
while [ "$current_dir" != "/" ]; do
|
||||||
if [ -d "$current_dir/.wildcloud" ]; then
|
if [ -d "$current_dir/.wildcloud" ]; then
|
||||||
echo "$current_dir"
|
echo "$current_dir"
|
||||||
@@ -157,7 +157,7 @@ find_wc_home() {
|
|||||||
fi
|
fi
|
||||||
current_dir="$(dirname "$current_dir")"
|
current_dir="$(dirname "$current_dir")"
|
||||||
done
|
done
|
||||||
|
|
||||||
# Not found
|
# Not found
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
@@ -169,7 +169,7 @@ init_wild_env() {
|
|||||||
echo "ERROR: WC_ROOT is not set."
|
echo "ERROR: WC_ROOT is not set."
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
|
|
||||||
# Check if WC_ROOT is a valid directory
|
# Check if WC_ROOT is a valid directory
|
||||||
if [ ! -d "${WC_ROOT}" ]; then
|
if [ ! -d "${WC_ROOT}" ]; then
|
||||||
echo "ERROR: WC_ROOT directory does not exist! Did you install the wild-cloud root?"
|
echo "ERROR: WC_ROOT directory does not exist! Did you install the wild-cloud root?"
|
||||||
|
Reference in New Issue
Block a user