Standard env init.

This commit is contained in:
2025-06-30 09:16:21 -07:00
parent 8f513235e2
commit 58097f7831
36 changed files with 294 additions and 327 deletions

View File

@@ -45,15 +45,13 @@ if [ -z "${APP_NAME}" ]; then
exit 1 exit 1
fi fi
if [ ! -d ".wildcloud" ]; then # Initialize Wild-Cloud environment
echo "Error: .wildcloud directory not found in current directory" if [ -z "${WC_ROOT}" ]; then
echo "This script must be run from a directory that contains a .wildcloud directory" print "WC_ROOT is not set."
exit 1
fi
if [ ! -f ".wildcloud/config.yaml" ]; then
echo "Error: .wildcloud/config.yaml not found"
exit 1 exit 1
else
source "${WC_ROOT}/scripts/common.sh"
init_wild_env
fi fi
CACHE_APP_DIR=".wildcloud/cache/apps/${APP_NAME}" CACHE_APP_DIR=".wildcloud/cache/apps/${APP_NAME}"

View File

@@ -61,6 +61,15 @@ if [ ! -d "apps/${APP_NAME}" ]; then
exit 1 exit 1
fi fi
# Initialize Wild-Cloud environment
if [ -z "${WC_ROOT}" ]; then
print "WC_ROOT is not set."
exit 1
else
source "${WC_ROOT}/scripts/common.sh"
init_wild_env
fi
# Confirmation prompt (unless --force or --dry-run) # Confirmation prompt (unless --force or --dry-run)
if [ "${FORCE}" != true ] && [ "${DRY_RUN:-}" != "--dry-run=client" ]; then if [ "${FORCE}" != true ] && [ "${DRY_RUN:-}" != "--dry-run=client" ]; then
echo "WARNING: This will delete all resources for app '${APP_NAME}'" echo "WARNING: This will delete all resources for app '${APP_NAME}'"

View File

@@ -43,6 +43,15 @@ if [ ! -d "apps/${APP_NAME}" ]; then
exit 1 exit 1
fi fi
# Initialize Wild-Cloud environment
if [ -z "${WC_ROOT}" ]; then
print "WC_ROOT is not set."
exit 1
else
source "${WC_ROOT}/scripts/common.sh"
init_wild_env
fi
# Function to deploy secrets for an app # Function to deploy secrets for an app
deploy_secrets() { deploy_secrets() {
local app_name="$1" local app_name="$1"

View File

@@ -7,13 +7,6 @@ KEEP_RESOURCES=false
FOLLOW_LOGS=false FOLLOW_LOGS=false
TIMEOUT=120 TIMEOUT=120
# Source environment variables from load-env.sh
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_DIR="$(dirname "$SCRIPT_DIR")"
if [ -f "$REPO_DIR/load-env.sh" ]; then
source "$REPO_DIR/load-env.sh"
fi
function show_help { function show_help {
echo "Usage: $0 APP_NAME [options]" echo "Usage: $0 APP_NAME [options]"
echo "" echo ""
@@ -85,6 +78,15 @@ if [[ -z "$APP_NAME" ]]; then
show_help show_help
fi fi
# Initialize Wild-Cloud environment
if [ -z "${WC_ROOT}" ]; then
print "WC_ROOT is not set."
exit 1
else
source "${WC_ROOT}/scripts/common.sh"
init_wild_env
fi
# Check if doctor directory exists # Check if doctor directory exists
DOCTOR_DIR="$REPO_DIR/apps/$APP_NAME/doctor" DOCTOR_DIR="$REPO_DIR/apps/$APP_NAME/doctor"
if [[ ! -d "$DOCTOR_DIR" ]]; then if [[ ! -d "$DOCTOR_DIR" ]]; then

View File

@@ -45,25 +45,16 @@ if [ -z "${APP_NAME}" ]; then
exit 1 exit 1
fi fi
if [ ! -d ".wildcloud" ]; then # Initialize Wild-Cloud environment
echo "Error: .wildcloud directory not found in current directory" if [ -z "${WC_ROOT}" ]; then
echo "This script must be run from a directory that contains a .wildcloud directory" print "WC_ROOT is not set."
exit 1 exit 1
else
source "${WC_ROOT}/scripts/common.sh"
init_wild_env
fi fi
if [ ! -f ".wildcloud/config.yaml" ]; then SOURCE_APP_DIR="${WC_ROOT}/apps/${APP_NAME}"
echo "Error: .wildcloud/config.yaml not found"
exit 1
fi
WILDCLOUD_REPO=$(yq eval '.wildcloud.repository' .wildcloud/config.yaml)
if [ -z "${WILDCLOUD_REPO}" ] || [ "${WILDCLOUD_REPO}" = "null" ]; then
echo "Error: wildcloud.config not found in .wildcloud/config.yaml"
exit 1
fi
SOURCE_APP_DIR="${WILDCLOUD_REPO}/apps/${APP_NAME}"
if [ ! -d "${SOURCE_APP_DIR}" ]; then if [ ! -d "${SOURCE_APP_DIR}" ]; then
echo "Error: App '${APP_NAME}' not found at ${SOURCE_APP_DIR}" echo "Error: App '${APP_NAME}' not found at ${SOURCE_APP_DIR}"
exit 1 exit 1

View File

@@ -48,11 +48,16 @@ while [[ $# -gt 0 ]]; do
esac esac
done done
# Get the path to the Wild-Cloud repository (where this script is located) # Initialize Wild-Cloud environment
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" if [ -z "${WC_ROOT}" ]; then
WILDCLOUD_REPO="$(dirname "${SCRIPT_DIR}")" print "WC_ROOT is not set."
APPS_DIR="${WILDCLOUD_REPO}/apps" exit 1
else
source "${WC_ROOT}/scripts/common.sh"
init_wild_env
fi
APPS_DIR="${WC_ROOT}/apps"
if [ ! -d "${APPS_DIR}" ]; then if [ ! -d "${APPS_DIR}" ]; then
echo "Error: Apps directory not found at ${APPS_DIR}" echo "Error: Apps directory not found at ${APPS_DIR}"
exit 1 exit 1

View File

@@ -3,12 +3,6 @@
set -e set -e
set -o pipefail set -o pipefail
# Source common utilities
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/wild-common.sh"
# Initialize Wild-Cloud environment
init_wild_env
# Usage function # Usage function
usage() { usage() {
echo "Usage: wild-cluster-config-generate [options]" echo "Usage: wild-cluster-config-generate [options]"
@@ -55,18 +49,13 @@ while [[ $# -gt 0 ]]; do
esac esac
done done
# Check if we're in a wild-cloud directory # Initialize Wild-Cloud environment
if [ ! -d ".wildcloud" ]; then if [ -z "${WC_ROOT}" ]; then
print_error "You must run this script from a wild-cloud directory" print "WC_ROOT is not set."
print_info "Run 'wild-setup' or 'wild-init' first to initialize a wild-cloud project"
exit 1
fi
# Check if talosctl is available
if ! command -v talosctl >/dev/null 2>&1; then
print_error "talosctl not found in PATH"
print_info "Please install talosctl to generate cluster configurations"
exit 1 exit 1
else
source "${WC_ROOT}/scripts/common.sh"
init_wild_env
fi fi
# ============================================================================= # =============================================================================

View File

@@ -3,12 +3,6 @@
set -e set -e
set -o pipefail set -o pipefail
# Source common utilities
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/wild-common.sh"
# Initialize Wild-Cloud environment
init_wild_env
# Usage function # Usage function
usage() { usage() {
echo "Usage: wild-cluster-node-image-create [options]" echo "Usage: wild-cluster-node-image-create [options]"
@@ -48,11 +42,13 @@ while [[ $# -gt 0 ]]; do
esac esac
done done
# Check if we're in a wild-cloud directory # Initialize Wild-Cloud environment
if [ ! -d ".wildcloud" ]; then if [ -z "${WC_ROOT}" ]; then
print_error "You must run this script from a wild-cloud directory" print "WC_ROOT is not set."
print_info "Run 'wild-setup' or 'wild-init' first to initialize a wild-cloud project"
exit 1 exit 1
else
source "${WC_ROOT}/scripts/common.sh"
init_wild_env
fi fi
# Configure basic settings if needed # Configure basic settings if needed

View File

@@ -3,12 +3,6 @@
set -e set -e
set -o pipefail set -o pipefail
# Source common utilities
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/wild-common.sh"
# Initialize Wild-Cloud environment
init_wild_env
# Usage function # Usage function
usage() { usage() {
echo "Usage: wild-cluster-node-machine-config-generate <node-ip>" echo "Usage: wild-cluster-node-machine-config-generate <node-ip>"
@@ -72,7 +66,14 @@ if [ -z "$NODE_IP" ]; then
exit 1 exit 1
fi fi
check_wild_directory # Initialize Wild-Cloud environment
if [ -z "${WC_ROOT}" ]; then
print "WC_ROOT is not set."
exit 1
else
source "${WC_ROOT}/scripts/common.sh"
init_wild_env
fi
# Check required configuration # Check required configuration
if [ -z "$(get_current_config "cluster.name")" ]; then if [ -z "$(get_current_config "cluster.name")" ]; then

View File

@@ -3,12 +3,6 @@
set -e set -e
set -o pipefail set -o pipefail
# Source common utilities
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/wild-common.sh"
# Initialize Wild-Cloud environment
init_wild_env
# Usage function # Usage function
usage() { usage() {
echo "Usage: wild-cluster-node-up <node-ip> [options]" echo "Usage: wild-cluster-node-up <node-ip> [options]"
@@ -84,8 +78,14 @@ if [ -z "$NODE_IP" ]; then
exit 1 exit 1
fi fi
# Check if we're in a wild-cloud directory # Initialize Wild-Cloud environment
check_wild_directory if [ -z "${WC_ROOT}" ]; then
print "WC_ROOT is not set."
exit 1
else
source "${WC_ROOT}/scripts/common.sh"
init_wild_env
fi
# Check required configuration # Check required configuration
if [ -z "$(get_current_config "cluster.name")" ]; then if [ -z "$(get_current_config "cluster.name")" ]; then

View File

@@ -3,13 +3,6 @@
set -e set -e
set -o pipefail set -o pipefail
# Source common utilities
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/wild-common.sh"
# Initialize Wild-Cloud environment
init_wild_env
# Usage function # Usage function
usage() { usage() {
echo "Usage: wild-cluster-services-generate [options]" echo "Usage: wild-cluster-services-generate [options]"
@@ -56,18 +49,13 @@ while [[ $# -gt 0 ]]; do
esac esac
done done
# Check if we're in a wild-cloud directory # Initialize Wild-Cloud environment
if [ ! -d ".wildcloud" ]; then if [ -z "${WC_ROOT}" ]; then
print_error "You must run this script from a wild-cloud directory" print "WC_ROOT is not set."
print_info "Run 'wild-setup' or 'wild-init' first to initialize a wild-cloud project"
exit 1
fi
# Check if basic configuration exists
if [ ! -f "${WC_HOME}/config.yaml" ]; then
print_error "Configuration file not found: ${WC_HOME}/config.yaml"
print_info "Run 'wild-setup' first to configure your cluster"
exit 1 exit 1
else
source "${WC_ROOT}/scripts/common.sh"
init_wild_env
fi fi
# ============================================================================= # =============================================================================

View File

@@ -3,13 +3,6 @@
set -e set -e
set -o pipefail set -o pipefail
# Source common utilities
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/wild-common.sh"
# Initialize Wild-Cloud environment
init_wild_env
# Usage function # Usage function
usage() { usage() {
echo "Usage: wild-cluster-services-up [options] [service...]" echo "Usage: wild-cluster-services-up [options] [service...]"
@@ -70,11 +63,13 @@ while [[ $# -gt 0 ]]; do
esac esac
done done
# Check if we're in a wild-cloud directory # Initialize Wild-Cloud environment
if [ ! -d ".wildcloud" ]; then if [ -z "${WC_ROOT}" ]; then
print_error "You must run this script from a wild-cloud directory" print "WC_ROOT is not set."
print_info "Run 'wild-setup' or 'wild-init' first to initialize a wild-cloud project"
exit 1 exit 1
else
source "${WC_ROOT}/scripts/common.sh"
init_wild_env
fi fi
CLUSTER_SETUP_DIR="${WC_HOME}/setup/cluster" CLUSTER_SETUP_DIR="${WC_HOME}/setup/cluster"

View File

@@ -37,10 +37,13 @@ while [[ $# -gt 0 ]]; do
esac esac
done done
# Check if WC_HOME is set # Initialize Wild-Cloud environment
if [ -z "${WC_HOME:-}" ]; then if [ -z "${WC_ROOT}" ]; then
echo "Error: WC_HOME environment variable not set" >&2 print "WC_ROOT is not set."
exit 1 exit 1
else
source "${WC_ROOT}/scripts/common.sh"
init_wild_env
fi fi
CONFIG_FILE="${WC_HOME}/config.yaml" CONFIG_FILE="${WC_HOME}/config.yaml"

View File

@@ -54,7 +54,6 @@ fi
source_dir="$1" source_dir="$1"
dest_dir="${2:-${source_dir}_compiled}" dest_dir="${2:-${source_dir}_compiled}"
# Validate source directory # Validate source directory
if [[ ! -d "$source_dir" ]]; then if [[ ! -d "$source_dir" ]]; then
echo "Error: Source directory does not exist: $source_dir" >&2 echo "Error: Source directory does not exist: $source_dir" >&2

View File

@@ -49,10 +49,13 @@ if [ -z "${KEY_PATH}" ]; then
exit 1 exit 1
fi fi
# Check if WC_HOME is set # Initialize Wild-Cloud environment
if [ -z "${WC_HOME:-}" ]; then if [ -z "${WC_ROOT}" ]; then
echo "Error: WC_HOME environment variable not set" >&2 print "WC_ROOT is not set."
exit 1 exit 1
else
source "${WC_ROOT}/scripts/common.sh"
init_wild_env
fi fi
CONFIG_FILE="${WC_HOME}/config.yaml" CONFIG_FILE="${WC_HOME}/config.yaml"

View File

@@ -57,10 +57,13 @@ if [ -z "${VALUE}" ]; then
exit 1 exit 1
fi fi
# Check if WC_HOME is set # Initialize Wild-Cloud environment
if [ -z "${WC_HOME:-}" ]; then if [ -z "${WC_ROOT}" ]; then
echo "Error: WC_HOME environment variable not set" >&2 print "WC_ROOT is not set."
exit 1 exit 1
else
source "${WC_ROOT}/scripts/common.sh"
init_wild_env
fi fi
CONFIG_FILE="${WC_HOME}/config.yaml" CONFIG_FILE="${WC_HOME}/config.yaml"

View File

@@ -17,14 +17,15 @@ while [[ $# -gt 0 ]]; do
esac esac
done done
# Check if WC_HOME is set # Initialize Wild-Cloud environment
if [ -z "${WC_HOME:-}" ]; then if [ -z "${WC_ROOT}" ]; then
echo "Error: WC_HOME environment variable not set. Run \`source ./env.sh\`." print "WC_ROOT is not set."
exit 1 exit 1
else
source "${WC_ROOT}/scripts/common.sh"
init_wild_env
fi fi
WC_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
# --- # ---
SOURCE_DIR="${WC_ROOT}/setup/dnsmasq" SOURCE_DIR="${WC_ROOT}/setup/dnsmasq"

View File

@@ -49,10 +49,13 @@ if [ -z "${KEY_PATH}" ]; then
exit 1 exit 1
fi fi
# Check if WC_HOME is set # Initialize Wild-Cloud environment
if [ -z "${WC_HOME:-}" ]; then if [ -z "${WC_ROOT}" ]; then
echo "Error: WC_HOME environment variable not set" >&2 print "WC_ROOT is not set."
exit 1 exit 1
else
source "${WC_ROOT}/scripts/common.sh"
init_wild_env
fi fi
SECRETS_FILE="${WC_HOME}/secrets.yaml" SECRETS_FILE="${WC_HOME}/secrets.yaml"

View File

@@ -57,10 +57,13 @@ if [ -z "${VALUE}" ]; then
exit 1 exit 1
fi fi
# Check if WC_HOME is set # Initialize Wild-Cloud environment
if [ -z "${WC_HOME:-}" ]; then if [ -z "${WC_ROOT}" ]; then
echo "Error: WC_HOME environment variable not set" >&2 print "WC_ROOT is not set."
exit 1 exit 1
else
source "${WC_ROOT}/scripts/common.sh"
init_wild_env
fi fi
SECRETS_FILE="${WC_HOME}/secrets.yaml" SECRETS_FILE="${WC_HOME}/secrets.yaml"

View File

@@ -3,18 +3,12 @@
set -e set -e
set -o pipefail set -o pipefail
# Source common utilities # Parse arguments
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/wild-common.sh"
# Initialize Wild-Cloud environment
init_wild_env
# Phase tracking variables
SKIP_SCAFFOLD=false SKIP_SCAFFOLD=false
SKIP_CLUSTER=false SKIP_CLUSTER=false
SKIP_SERVICES=false SKIP_SERVICES=false
# Parse arguments
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
case $1 in case $1 in
--skip-scaffold) --skip-scaffold)
@@ -71,31 +65,37 @@ while [[ $# -gt 0 ]]; do
esac esac
done done
# Set up cloud directory (WC_HOME is where user's cloud will be) # Initialize Wild-Cloud environment
WC_HOME="$(pwd)"
export WC_HOME
print_header "Wild-Cloud Complete Setup" if [ -z "${WC_ROOT}" ]; then
print_info "Running complete Wild-Cloud setup using modular components" print "WC_ROOT is not set."
exit 1
else
source "${WC_ROOT}/scripts/common.sh"
init_wild_env
fi
print_header "Wild-Cloud Setup"
print_info "Running complete Wild-Cloud setup."
echo "" echo ""
# ============================================================================= # =============================================================================
# SCAFFOLD SETUP # WC_HOME SCAFFOLDING
# ============================================================================= # =============================================================================
if [ "${SKIP_SCAFFOLD}" = false ]; then if [ "${SKIP_SCAFFOLD}" = false ]; then
print_header "Component 1: Scaffold Setup" print_header "Cloud Home Setup"
print_info "Running wild-setup-scaffold..." print_info "Scaffolding your cloud home..."
if wild-setup-scaffold; then if wild-setup-scaffold; then
print_success "Component 1 completed: Scaffold setup" print_success "Cloud home setup completed"
else else
print_error "Component 1 failed: Scaffold setup" print_error "Cloud home setup failed"
exit 1 exit 1
fi fi
echo "" echo ""
else else
print_info "Skipping Component 1: Scaffold Setup" print_info "Skipping Component 1: Cloud Home Setup"
fi fi
# ============================================================================= # =============================================================================
@@ -103,13 +103,13 @@ fi
# ============================================================================= # =============================================================================
if [ "${SKIP_CLUSTER}" = false ]; then if [ "${SKIP_CLUSTER}" = false ]; then
print_header "Component 2: Cluster Setup" print_header "Cluster Setup"
print_info "Running wild-setup-cluster..." print_info "Running wild-setup-cluster..."
if wild-setup-cluster; then if wild-setup-cluster; then
print_success "Component 2 completed: Cluster setup" print_success "Cluster setup completed"
else else
print_error "Component 2 failed: Cluster setup" print_error "Cluster setup failed"
exit 1 exit 1
fi fi
echo "" echo ""
@@ -122,13 +122,13 @@ fi
# ============================================================================= # =============================================================================
if [ "${SKIP_SERVICES}" = false ]; then if [ "${SKIP_SERVICES}" = false ]; then
print_header "Component 3: Services Setup" print_header "Services Setup"
print_info "Running wild-setup-services..." print_info "Running wild-setup-services..."
if wild-setup-services; then if wild-setup-services; then
print_success "Component 3 completed: Services setup" print_success "Services setup completed"
else else
print_error "Component 3 failed: Services setup" print_error "Services setup failed"
exit 1 exit 1
fi fi
echo "" echo ""
@@ -142,34 +142,6 @@ fi
print_header "Wild-Cloud Complete Setup Finished!" print_header "Wild-Cloud Complete Setup Finished!"
print_success "All components completed successfully!"
echo ""
print_info "What was accomplished:"
if [ "${SKIP_SCAFFOLD}" = false ]; then
print_info "✅ Component 1: Scaffold setup (cloud initialization)"
else
print_info "⏸️ Component 1: Scaffold setup (skipped)"
fi
if [ "${SKIP_CLUSTER}" = false ]; then
print_info "✅ Component 2: Cluster setup (Phases 1-3)"
else
print_info "⏸️ Component 2: Cluster setup (skipped)"
fi
if [ "${SKIP_SERVICES}" = false ]; then
print_info "✅ Component 3: Services setup (Phase 4)"
else
print_info "⏸️ Component 3: Services setup (skipped)"
fi
echo ""
print_info "Individual components can be run separately:"
echo " - wild-setup-scaffold # Cloud initialization"
echo " - wild-setup-cluster # Cluster infrastructure"
echo " - wild-setup-services # Cluster services"
echo "" echo ""
if [ "${SKIP_SERVICES}" = false ] && command -v kubectl >/dev/null 2>&1; then if [ "${SKIP_SERVICES}" = false ] && command -v kubectl >/dev/null 2>&1; then
if [ -f "${WC_HOME}/config.yaml" ]; then if [ -f "${WC_HOME}/config.yaml" ]; then

View File

@@ -3,18 +3,12 @@
set -e set -e
set -o pipefail set -o pipefail
# Source common utilities # Parse arguments
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/wild-common.sh"
# Initialize Wild-Cloud environment
init_wild_env
# Phase tracking variables
SKIP_INSTALLER=false SKIP_INSTALLER=false
SKIP_HARDWARE=false SKIP_HARDWARE=false
SKIP_CONFIGS=false SKIP_CONFIGS=false
# Parse arguments
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
case $1 in case $1 in
--skip-installer) --skip-installer)
@@ -62,8 +56,15 @@ while [[ $# -gt 0 ]]; do
esac esac
done done
# Check if we're in a wild-cloud directory # Initialize Wild-Cloud environment
check_wild_directory
if [ -z "${WC_ROOT}" ]; then
print "WC_ROOT is not set."
exit 1
else
source "${WC_ROOT}/scripts/common.sh"
init_wild_env
fi
# Check basic configuration # Check basic configuration
check_basic_config check_basic_config
@@ -103,25 +104,11 @@ if [ "${SKIP_HARDWARE}" = false ]; then
GATEWAY_IP=$(ip route | grep default | awk '{print $3; exit}' 2>/dev/null || echo "192.168.1.1") GATEWAY_IP=$(ip route | grep default | awk '{print $3; exit}' 2>/dev/null || echo "192.168.1.1")
SUBNET_PREFIX=$(echo "${CURRENT_IP}" | cut -d. -f1-3) SUBNET_PREFIX=$(echo "${CURRENT_IP}" | cut -d. -f1-3)
current_router_ip=$(get_current_config "cloud.router.ip") prompt_if_unset_config "cloud.router.ip" "Router/Gateway IP" "${GATEWAY_IP}"
router_ip=$(prompt_with_default "Router/Gateway IP" "${GATEWAY_IP}" "${current_router_ip}") prompt_if_unset_config "cloud.dns.ip" "DNS server IP (dnsmasq machine)" "${SUBNET_PREFIX}.50"
wild-config-set "cloud.router.ip" "${router_ip}" prompt_if_unset_config "cloud.dhcpRange" "DHCP range for dnsmasq" "${SUBNET_PREFIX}.100,${SUBNET_PREFIX}.200"
prompt_if_unset_config "cloud.dnsmasq.interface" "Network interface for dnsmasq" "eth0"
current_dns_ip=$(get_current_config "cloud.dns.ip") prompt_if_unset_config "cloud.dns.externalResolver" "External DNS resolver" "1.1.1.1"
dns_ip=$(prompt_with_default "DNS server IP (dnsmasq machine)" "${SUBNET_PREFIX}.50" "${current_dns_ip}")
wild-config-set "cloud.dns.ip" "${dns_ip}"
current_dhcp_range=$(get_current_config "cloud.dhcpRange")
dhcp_range=$(prompt_with_default "DHCP range for dnsmasq" "${SUBNET_PREFIX}.100,${SUBNET_PREFIX}.200" "${current_dhcp_range}")
wild-config-set "cloud.dhcpRange" "${dhcp_range}"
current_interface=$(get_current_config "cloud.dnsmasq.interface")
interface=$(prompt_with_default "Network interface for dnsmasq" "eth0" "${current_interface}")
wild-config-set "cloud.dnsmasq.interface" "${interface}"
current_external_resolver=$(get_current_config "cloud.dns.externalResolver")
external_resolver=$(prompt_with_default "External DNS resolver" "1.1.1.1" "${current_external_resolver}")
wild-config-set "cloud.dns.externalResolver" "${external_resolver}"
print_success "Network configuration completed" print_success "Network configuration completed"
echo "" echo ""
@@ -134,24 +121,14 @@ if [ "${SKIP_HARDWARE}" = false ]; then
SUBNET_PREFIX=$(echo "${CURRENT_IP}" | cut -d. -f1-3) SUBNET_PREFIX=$(echo "${CURRENT_IP}" | cut -d. -f1-3)
# Talos version # Talos version
current_talos_version=$(get_current_config "cluster.nodes.talos.version") prompt_if_unset_config "cluster.nodes.talos.version" "Talos version" "v1.10.4"
if [ -z "$current_talos_version" ] || [ "$current_talos_version" = "null" ]; then talos_version=$(wild-config "cluster.nodes.talos.version")
talos_version=$(prompt_with_default "Talos version" "v1.10.4" "${current_talos_version}")
wild-config-set "cluster.nodes.talos.version" "${talos_version}"
else
talos_version="$current_talos_version"
fi
# MetalLB IP address pool # MetalLB IP address pool
current_ip_pool=$(get_current_config "cluster.ipAddressPool") prompt_if_unset_config "cluster.ipAddressPool" "MetalLB IP address pool" "${SUBNET_PREFIX}.80-${SUBNET_PREFIX}.89"
if [ -z "$current_ip_pool" ] || [ "$current_ip_pool" = "null" ]; then ip_pool=$(wild-config "cluster.ipAddressPool")
ip_pool=$(prompt_with_default "MetalLB IP address pool" "${SUBNET_PREFIX}.80-${SUBNET_PREFIX}.89" "${current_ip_pool}")
wild-config-set "cluster.ipAddressPool" "${ip_pool}"
else
ip_pool="$current_ip_pool"
fi
# Load balancer IP (automatically set to first address in the pool) # Load balancer IP (automatically set to first address in the pool if not set)
current_lb_ip=$(get_current_config "cluster.loadBalancerIp") current_lb_ip=$(get_current_config "cluster.loadBalancerIp")
if [ -z "$current_lb_ip" ] || [ "$current_lb_ip" = "null" ]; then if [ -z "$current_lb_ip" ] || [ "$current_lb_ip" = "null" ]; then
lb_ip=$(echo "${ip_pool}" | cut -d'-' -f1) lb_ip=$(echo "${ip_pool}" | cut -d'-' -f1)
@@ -183,12 +160,8 @@ if [ "${SKIP_HARDWARE}" = false ]; then
fi fi
# External DNS # External DNS
current_owner_id=$(get_current_config "cluster.externalDns.ownerId") cluster_name=$(get_current_config "cluster.name")
if [ -z "$current_owner_id" ] || [ "$current_owner_id" = "null" ]; then prompt_if_unset_config "cluster.externalDns.ownerId" "External DNS owner ID" "external-dns-${cluster_name}"
cluster_name=$(get_current_config "cluster.name")
owner_id=$(prompt_with_default "External DNS owner ID" "external-dns-${cluster_name}" "${current_owner_id}")
wild-config-set "cluster.externalDns.ownerId" "${owner_id}"
fi
print_success "Cluster configuration completed" print_success "Cluster configuration completed"
echo "" echo ""
@@ -208,9 +181,8 @@ if [ "${SKIP_HARDWARE}" = false ]; then
print_info "Configure control plane nodes (you need at least 3 for HA):" print_info "Configure control plane nodes (you need at least 3 for HA):"
echo "" echo ""
current_vip=$(get_current_config "cluster.nodes.control.vip") prompt_if_unset_config "cluster.nodes.control.vip" "Control plane virtual IP" "${SUBNET_PREFIX}.90"
vip=$(prompt_with_default "Control plane virtual IP" "${SUBNET_PREFIX}.90" "${current_vip}") vip=$(wild-config "cluster.nodes.control.vip")
wild-config-set "cluster.nodes.control.vip" "${vip}"
# Automatically configure the first three IPs after VIP for control plane nodes # Automatically configure the first three IPs after VIP for control plane nodes
vip_last_octet=$(echo "$vip" | cut -d. -f4) vip_last_octet=$(echo "$vip" | cut -d. -f4)

View File

@@ -3,15 +3,11 @@
set -e set -e
set -o pipefail set -o pipefail
# Source common utilities
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/wild-common.sh"
# Initialize Wild-Cloud environment # Parse arguments
init_wild_env
UPDATE=false UPDATE=false
# Parse arguments
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
case $1 in case $1 in
--update) --update)
@@ -52,19 +48,18 @@ while [[ $# -gt 0 ]]; do
esac esac
done done
# Set up cloud directory (WC_HOME is where user's cloud will be) # Initialize Wild-Cloud environment
WC_HOME="$(pwd)"
export WC_HOME
# Template directory (in WC_ROOT, never written to) if [ -z "${WC_ROOT}" ]; then
TEMPLATE_DIR="${WC_ROOT}/setup/home-scaffold" print "WC_ROOT is not set."
echo "Using template directory: ${TEMPLATE_DIR}"
if [ ! -d "${TEMPLATE_DIR}" ]; then
echo "Error: Template directory not found at ${TEMPLATE_DIR}"
exit 1 exit 1
else
source "${WC_ROOT}/scripts/common.sh"
init_wild_env
fi fi
TEMPLATE_DIR="${WC_ROOT}/setup/home-scaffold"
# Check if cloud already exists # Check if cloud already exists
if [ -d ".wildcloud" ]; then if [ -d ".wildcloud" ]; then
echo "Wild-Cloud already exists in this directory." echo "Wild-Cloud already exists in this directory."
@@ -164,27 +159,26 @@ if [ ! -f "${WC_HOME}/config.yaml" ] || [ -z "$(get_current_config "operator.ema
echo "" echo ""
# Basic Information # Basic Information
current_email=$(get_current_config "operator.email") prompt_if_unset_config "operator.email" "Your email address (for Let's Encrypt certificates)" ""
email=$(prompt_with_default "Your email address (for Let's Encrypt certificates)" "" "${current_email}")
wild-config-set "operator.email" "${email}"
# Domain Configuration # Domain Configuration
current_base_domain=$(get_current_config "cloud.baseDomain") prompt_if_unset_config "cloud.baseDomain" "Your base domain name (e.g., example.com)" ""
base_domain=$(prompt_with_default "Your base domain name (e.g., example.com)" "" "${current_base_domain}")
wild-config-set "cloud.baseDomain" "${base_domain}" # Get base domain to use as default for cloud domain
base_domain=$(wild-config "cloud.baseDomain")
prompt_if_unset_config "cloud.domain" "Your public cloud domain" "cloud.${base_domain}"
# Get cloud domain to use as default for internal domain
domain=$(wild-config "cloud.domain")
prompt_if_unset_config "cloud.internalDomain" "Your internal cloud domain" "internal.${domain}"
current_domain=$(get_current_config "cloud.domain") # Derive cluster name from domain if not already set
domain=$(prompt_with_default "Your public cloud domain" "cloud.${base_domain}" "${current_domain}") current_cluster_name=$(get_current_config "cluster.name")
wild-config-set "cloud.domain" "${domain}" if [ -z "$current_cluster_name" ] || [ "$current_cluster_name" = "null" ]; then
cluster_name=$(echo "${domain}" | tr '.' '-' | tr '[:upper:]' '[:lower:]')
current_internal_domain=$(get_current_config "cloud.internalDomain") wild-config-set "cluster.name" "${cluster_name}"
internal_domain=$(prompt_with_default "Your internal cloud domain" "internal.${domain}" "${current_internal_domain}") print_info "Set cluster name to: ${cluster_name}"
wild-config-set "cloud.internalDomain" "${internal_domain}" fi
# Derive cluster name from domain
cluster_name=$(echo "${domain}" | tr '.' '-' | tr '[:upper:]' '[:lower:]')
wild-config-set "cluster.name" "${cluster_name}"
print_info "Set cluster name to: ${cluster_name}"
print_success "Basic configuration completed" print_success "Basic configuration completed"
echo "" echo ""

View File

@@ -3,13 +3,8 @@
set -e set -e
set -o pipefail set -o pipefail
# Source common utilities
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/wild-common.sh"
# Initialize Wild-Cloud environment
init_wild_env
# Parse arguments # Parse arguments
SKIP_INSTALL=false SKIP_INSTALL=false
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
@@ -53,8 +48,15 @@ while [[ $# -gt 0 ]]; do
esac esac
done done
# Check if we're in a wild-cloud directory # Initialize Wild-Cloud environment
check_wild_directory
if [ -z "${WC_ROOT}" ]; then
print "WC_ROOT is not set."
exit 1
else
source "${WC_ROOT}/scripts/common.sh"
init_wild_env
fi
# Check basic configuration # Check basic configuration
check_basic_config check_basic_config

View File

@@ -5,10 +5,13 @@
set -euo pipefail set -euo pipefail
# Check if WC_HOME is set # Initialize Wild-Cloud environment
if [ -z "${WC_HOME:-}" ]; then if [ -z "${WC_ROOT}" ]; then
echo "Error: WC_HOME environment variable not set. Run \`source .env\`." print "WC_ROOT is not set."
exit 1 exit 1
else
source "${WC_ROOT}/scripts/common.sh"
init_wild_env
fi fi
CONFIG_FILE="${WC_HOME}/config.yaml" CONFIG_FILE="${WC_HOME}/config.yaml"

View File

@@ -6,10 +6,13 @@
set -euo pipefail set -euo pipefail
# Check if WC_HOME is set # Initialize Wild-Cloud environment
if [ -z "${WC_HOME:-}" ]; then if [ -z "${WC_ROOT}" ]; then
echo "Error: WC_HOME environment variable not set. Run \`source .env\`." print "WC_ROOT is not set."
exit 1 exit 1
else
source "${WC_ROOT}/scripts/common.sh"
init_wild_env
fi fi
CONFIG_FILE="${WC_HOME}/config.yaml" CONFIG_FILE="${WC_HOME}/config.yaml"

View File

@@ -183,20 +183,28 @@ find_wc_home() {
# Initialize common Wild-Cloud environment variables # Initialize common Wild-Cloud environment variables
# Call this function at the beginning of scripts # Call this function at the beginning of scripts
init_wild_env() { init_wild_env() {
# Get WC_ROOT (where this script and templates live)
if [ -z "${WC_ROOT}" ]; then if [ -z "${WC_ROOT}" ]; then
WC_ROOT="$(cd "$(dirname "${BASH_SOURCE[1]}")/.." && pwd)" print "Fail"
export WC_ROOT exit 1
else
# Check if WC_ROOT is a valid directory
if [ ! -d "${WC_ROOT}" ]; then
echo "ERROR: WC_ROOT directory does not exist! Did you install the wild-cloud root?"
exit 1
fi fi
# Set up cloud directory (WC_HOME is where user's cloud is) # Check if WC_ROOT/bin is in path
# Look for .wildcloud directory in current path or ancestors if [[ ":$PATH:" != *":$WC_ROOT/bin:"* ]]; then
echo "ERROR: Your wildcloud seed bin path should be in your PATH environment."
exit 1
fi
WC_HOME="$(find_wc_home)"
if [ -z "${WC_HOME}" ]; then if [ -z "${WC_HOME}" ]; then
local found_home echo "ERROR: This command must be run from within a wildcloud home directory."
if found_home="$(find_wc_home)"; then exit 1
WC_HOME="$found_home" fi
export WC_HOME
fi
fi fi
} }

View File

@@ -2,13 +2,15 @@
set -e set -e
set -o pipefail set -o pipefail
if [ -z "${WC_HOME}" ]; then # Initialize Wild-Cloud environment
echo "Please source the wildcloud environment first. (e.g., \`source ./env.sh\`)" if [ -z "${WC_ROOT}" ]; then
print "WC_ROOT is not set."
exit 1 exit 1
else
source "${WC_ROOT}/scripts/common.sh"
init_wild_env
fi fi
source "${WC_ROOT}/bin/wild-common.sh"
CLUSTER_SETUP_DIR="${WC_HOME}/setup/cluster" CLUSTER_SETUP_DIR="${WC_HOME}/setup/cluster"
DOCKER_REGISTRY_DIR="${CLUSTER_SETUP_DIR}/docker-registry" DOCKER_REGISTRY_DIR="${CLUSTER_SETUP_DIR}/docker-registry"

View File

@@ -2,13 +2,15 @@
set -e set -e
set -o pipefail set -o pipefail
if [ -z "${WC_HOME}" ]; then # Initialize Wild-Cloud environment
echo "Please source the wildcloud environment first. (e.g., \`source ./env.sh\`)" if [ -z "${WC_ROOT}" ]; then
print "WC_ROOT is not set."
exit 1 exit 1
else
source "${WC_ROOT}/scripts/common.sh"
init_wild_env
fi fi
source "${WC_ROOT}/bin/wild-common.sh"
CLUSTER_SETUP_DIR="${WC_HOME}/setup/cluster" CLUSTER_SETUP_DIR="${WC_HOME}/setup/cluster"
EXTERNALDNS_DIR="${CLUSTER_SETUP_DIR}/externaldns" EXTERNALDNS_DIR="${CLUSTER_SETUP_DIR}/externaldns"

View File

@@ -21,14 +21,8 @@ echo
echo "Infrastructure setup complete!" echo "Infrastructure setup complete!"
echo echo
echo "Next steps:"
echo "1. Install Helm charts for non-infrastructure components"
INTERNAL_DOMAIN=$(wild-config cloud.internalDomain)
echo "2. Access the dashboard at: https://dashboard.${INTERNAL_DOMAIN}"
echo "3. Get the dashboard token with: ./bin/dashboard-token"
echo
echo "To verify components, run:" echo "To verify components, run:"
echo "- kubectl get pods -n cert-manager" echo "- kubectl get pods -n cert-manager"
echo "- kubectl get pods -n externaldns" echo "- kubectl get pods -n externaldns"
echo "- kubectl get pods -n kubernetes-dashboard" echo "- kubectl get pods -n kubernetes-dashboard"
echo "- kubectl get clusterissuers" echo "- kubectl get clusterissuers"

View File

@@ -2,13 +2,15 @@
set -e set -e
set -o pipefail set -o pipefail
if [ -z "${WC_HOME}" ]; then # Initialize Wild-Cloud environment
echo "Please source the wildcloud environment first. (e.g., \`source ./env.sh\`)" if [ -z "${WC_ROOT}" ]; then
print "WC_ROOT is not set."
exit 1 exit 1
else
source "${WC_ROOT}/scripts/common.sh"
init_wild_env
fi fi
source "${WC_ROOT}/bin/wild-common.sh"
CLUSTER_SETUP_DIR="${WC_HOME}/setup/cluster" CLUSTER_SETUP_DIR="${WC_HOME}/setup/cluster"
KUBERNETES_DASHBOARD_DIR="${CLUSTER_SETUP_DIR}/kubernetes-dashboard" KUBERNETES_DASHBOARD_DIR="${CLUSTER_SETUP_DIR}/kubernetes-dashboard"

View File

@@ -2,9 +2,13 @@
set -e set -e
set -o pipefail set -o pipefail
if [ -z "${WC_HOME}" ]; then # Initialize Wild-Cloud environment
echo "Please source the wildcloud environment first. (e.g., \`source ./env.sh\`)" if [ -z "${WC_ROOT}" ]; then
print "WC_ROOT is not set."
exit 1 exit 1
else
source "${WC_ROOT}/scripts/common.sh"
init_wild_env
fi fi
source "${WC_ROOT}/bin/wild-common.sh" source "${WC_ROOT}/bin/wild-common.sh"

View File

@@ -2,13 +2,15 @@
set -e set -e
set -o pipefail set -o pipefail
if [ -z "${WC_HOME}" ]; then # Initialize Wild-Cloud environment
echo "Please source the wildcloud environment first. (e.g., \`source ./env.sh\`)" if [ -z "${WC_ROOT}" ]; then
print "WC_ROOT is not set."
exit 1 exit 1
else
source "${WC_ROOT}/scripts/common.sh"
init_wild_env
fi fi
source "${WC_ROOT}/bin/wild-common.sh"
CLUSTER_SETUP_DIR="${WC_HOME}/setup/cluster" CLUSTER_SETUP_DIR="${WC_HOME}/setup/cluster"
METALLB_DIR="${CLUSTER_SETUP_DIR}/metallb" METALLB_DIR="${CLUSTER_SETUP_DIR}/metallb"

View File

@@ -2,13 +2,15 @@
set -e set -e
set -o pipefail set -o pipefail
if [ -z "${WC_HOME}" ]; then # Initialize Wild-Cloud environment
echo "Please source the wildcloud environment first. (e.g., \`source ./env.sh\`)" if [ -z "${WC_ROOT}" ]; then
print "WC_ROOT is not set."
exit 1 exit 1
else
source "${WC_ROOT}/scripts/common.sh"
init_wild_env
fi fi
source "${WC_ROOT}/bin/wild-common.sh"
CLUSTER_SETUP_DIR="${WC_HOME}/setup/cluster" CLUSTER_SETUP_DIR="${WC_HOME}/setup/cluster"
NFS_DIR="${CLUSTER_SETUP_DIR}/nfs" NFS_DIR="${CLUSTER_SETUP_DIR}/nfs"

View File

@@ -2,13 +2,15 @@
set -e set -e
set -o pipefail set -o pipefail
if [ -z "${WC_HOME}" ]; then # Initialize Wild-Cloud environment
echo "Please source the wildcloud environment first. (e.g., \`source ./env.sh\`)" if [ -z "${WC_ROOT}" ]; then
print "WC_ROOT is not set."
exit 1 exit 1
else
source "${WC_ROOT}/scripts/common.sh"
init_wild_env
fi fi
source "${WC_ROOT}/bin/wild-common.sh"
CLUSTER_SETUP_DIR="${WC_HOME}/setup/cluster" CLUSTER_SETUP_DIR="${WC_HOME}/setup/cluster"
TRAEFIK_DIR="${CLUSTER_SETUP_DIR}/traefik" TRAEFIK_DIR="${CLUSTER_SETUP_DIR}/traefik"

View File

@@ -2,13 +2,15 @@
set -e set -e
set -o pipefail set -o pipefail
if [ -z "${WC_HOME}" ]; then # Initialize Wild-Cloud environment
echo "Please source the wildcloud environment first. (e.g., \`source ./env.sh\`)" if [ -z "${WC_ROOT}" ]; then
print "WC_ROOT is not set."
exit 1 exit 1
else
source "${WC_ROOT}/scripts/common.sh"
init_wild_env
fi fi
source "${WC_ROOT}/bin/wild-common.sh"
CLUSTER_SETUP_DIR="${WC_HOME}/setup/cluster" CLUSTER_SETUP_DIR="${WC_HOME}/setup/cluster"
UTILS_DIR="${CLUSTER_SETUP_DIR}/utils" UTILS_DIR="${CLUSTER_SETUP_DIR}/utils"

View File

@@ -1,10 +1,13 @@
#!/bin/bash #!/bin/bash
set -e set -e
# Check if WC_HOME is set (wildcloud environment sourced) # Initialize Wild-Cloud environment
if [ -z "${WC_HOME}" ]; then if [ -z "${WC_ROOT}" ]; then
echo "Please source the wildcloud environment first. (e.g., \`source ./env.sh\`)" print "WC_ROOT is not set."
exit 1 exit 1
else
source "${WC_ROOT}/scripts/common.sh"
init_wild_env
fi fi
# Navigate to script directory # Navigate to script directory